Documentation
¶
Overview ¶
Package sqlguard adapts database/sql operations to operation.Engine. It does not install a driver, own the database, or enforce inside PostgreSQL itself.
Index ¶
- type DB
- func (d *DB) BeginTx(ctx context.Context, options *sql.TxOptions) (*Tx, error)
- func (d *DB) ExecContext(ctx context.Context, query string, args ...any) (result sql.Result, err error)
- func (d *DB) InTx(ctx context.Context, options *sql.TxOptions, fn func(*Tx) error) (err error)
- func (d *DB) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error)
- func (d *DB) QueryRowContext(ctx context.Context, query string, args ...any) *Row
- type Metadata
- type Row
- type Rows
- type Tx
- func (t *Tx) Commit() error
- func (t *Tx) Context() context.Context
- func (t *Tx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (t *Tx) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error)
- func (t *Tx) QueryRowContext(ctx context.Context, query string, args ...any) *Row
- func (t *Tx) Rollback() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) BeginTx ¶
BeginTx owns cancellation cleanup. It acquires a connection with the caller context, then begins with a noncanceling control context so database/sql cannot mark a transaction done before an asynchronous driver rollback actually ends. Begin/Commit/Rollback driver control calls may wait for driver network timeouts; the permit remains held throughout. Queries use caller cancellation normally.
func (*DB) ExecContext ¶
func (*DB) InTx ¶
InTx guarantees rollback on callback failure or panic, and commits only on a successful return. Use tx methods, not the outer DB wrapper, inside the body.
func (*DB) QueryContext ¶
QueryContext holds admission until Rows.Close or terminal iteration. Always defer Close. Abandoning rows without closing them retains the permit.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
func (*Rows) NextResultSet ¶
NextResultSet is explicit for multiple-result drivers; callers still close on exit.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}