Documentation
¶
Overview ¶
Package stdsqlexec is the sqlkit.Executor over database/sql.
It runs statements through a *sql.DB, or through the *sql.Tx a context carries, and gives transactions the contract every executor shares: whoever begins commits, a nested scope joins and flattens rather than taking a savepoint, and an error, a panic or a cancelled context rolls back.
Index ¶
- func ContextWithTx(ctx context.Context, tx *sql.Tx) context.Context
- func TxFromContext(ctx context.Context) (*sql.Tx, bool)
- type Executor
- func (e *Executor) DB() *sql.DB
- func (e *Executor) Dialect() sqlkit.Dialect
- func (e *Executor) Do(ctx context.Context, fn func(ctx context.Context) error) error
- func (e *Executor) Exec(ctx context.Context, statement sqlkit.Statement) (int64, error)
- func (e *Executor) ExecStatement(ctx context.Context, query string, args ...any) error
- func (e *Executor) InTransaction(ctx context.Context) bool
- func (e *Executor) Query(ctx context.Context, statement sqlkit.Statement, ...) error
- func (e *Executor) QueryStatement(ctx context.Context, query string, args ...any) (sqlkit.Rows, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithTx ¶
ContextWithTx returns a context carrying an open transaction, so that a caller that began one itself can have the executor join it. The executor uses this transaction and neither commits nor rolls it back.
The key is this package's own, so a transaction a task store carries is not visible here. A host that wants one transaction across both reads it from the store's context and passes it here.
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor runs statements through a *sql.DB, or through the *sql.Tx a context carries.
func New ¶
New returns an executor over a database handle and the dialect of the database behind it. A nil handle or dialect is a configuration error.
func (*Executor) Dialect ¶
Dialect implements sqlkit.Executor.
func (*Executor) Do ¶
Do implements sqlkit.Executor.
func (*Executor) Exec ¶
Exec implements sqlkit.Executor.
func (*Executor) ExecStatement ¶
ExecStatement implements sqlkit.Execer, so that the schema runner can drive this executor.
func (*Executor) InTransaction ¶
InTransaction implements sqlkit.Executor.