Documentation
¶
Index ¶
- type SharedSubTx
- func (tx *SharedSubTx) Begin(ctx context.Context) (pgx.Tx, error)
- func (tx *SharedSubTx) Commit(ctx context.Context) error
- func (tx *SharedSubTx) Conn() *pgx.Conn
- func (tx *SharedSubTx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (tx *SharedSubTx) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func (tx *SharedSubTx) LargeObjects() pgx.LargeObjects
- func (tx *SharedSubTx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
- func (tx *SharedSubTx) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- func (tx *SharedSubTx) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- func (tx *SharedSubTx) Rollback(ctx context.Context) error
- func (tx *SharedSubTx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
- type SharedTx
- func (e *SharedTx) Begin(ctx context.Context) (pgx.Tx, error)
- func (e *SharedTx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (e *SharedTx) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func (e *SharedTx) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- func (e *SharedTx) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- type SharedTxRow
- type SharedTxRows
- func (r *SharedTxRows) Close()
- func (r *SharedTxRows) CommandTag() pgconn.CommandTag
- func (r *SharedTxRows) Conn() *pgx.Conn
- func (r *SharedTxRows) Err() error
- func (r *SharedTxRows) FieldDescriptions() []pgconn.FieldDescription
- func (r *SharedTxRows) Next() bool
- func (r *SharedTxRows) RawValues() [][]byte
- func (r *SharedTxRows) Scan(dest ...any) error
- func (r *SharedTxRows) Values() ([]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SharedSubTx ¶
type SharedSubTx struct {
// contains filtered or unexported fields
}
SharedSubTx wraps a pgx.Tx such that it unlocks SharedTx when it commits or rolls back.
func (*SharedSubTx) Conn ¶
func (tx *SharedSubTx) Conn() *pgx.Conn
func (*SharedSubTx) Exec ¶
func (tx *SharedSubTx) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
func (*SharedSubTx) LargeObjects ¶
func (tx *SharedSubTx) LargeObjects() pgx.LargeObjects
func (*SharedSubTx) Prepare ¶
func (tx *SharedSubTx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
func (*SharedSubTx) QueryRow ¶
func (tx *SharedSubTx) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
func (*SharedSubTx) SendBatch ¶
func (tx *SharedSubTx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
type SharedTx ¶
type SharedTx struct {
// contains filtered or unexported fields
}
SharedTx can be used to wrap a test transaction in cases where multiple callers may want to access it concurrently during the course of a single test case. Normally this is not allowed and an access will error with "conn busy" if another caller is already using it.
This is a test-only construct because in non-test environments an executor is a full connection pool which can support concurrent access without trouble. Many test cases use single test transactions, and that's where code written to use a connection pool can become problematic.
SharedTx uses a channel for synchronization and does *not* guarantee FIFO ordering for callers.
Avoid using SharedTx if possible because while it works, problems encountered by use of concurrent accesses will be more difficult to debug than otherwise, so it's better to not go there at all if it can be avoided.
func NewSharedTx ¶
func NewSharedTx(tx pgx.Tx) *SharedTx
type SharedTxRow ¶
type SharedTxRow struct {
// contains filtered or unexported fields
}
SharedTxRow wraps a pgx.Row such that it unlocks SharedExecutor when the row finishes scanning.
func (*SharedTxRow) Scan ¶
func (r *SharedTxRow) Scan(dest ...any) error
type SharedTxRows ¶
type SharedTxRows struct {
// contains filtered or unexported fields
}
SharedTxRows wraps a pgx.Rows such that it unlocks SharedExecutor when the rows are closed.
func (*SharedTxRows) Close ¶
func (r *SharedTxRows) Close()
func (*SharedTxRows) CommandTag ¶
func (r *SharedTxRows) CommandTag() pgconn.CommandTag
All of these are simple pass throughs.
func (*SharedTxRows) Conn ¶
func (r *SharedTxRows) Conn() *pgx.Conn
func (*SharedTxRows) Err ¶
func (r *SharedTxRows) Err() error
func (*SharedTxRows) FieldDescriptions ¶
func (r *SharedTxRows) FieldDescriptions() []pgconn.FieldDescription
func (*SharedTxRows) Next ¶
func (r *SharedTxRows) Next() bool
func (*SharedTxRows) RawValues ¶
func (r *SharedTxRows) RawValues() [][]byte
func (*SharedTxRows) Scan ¶
func (r *SharedTxRows) Scan(dest ...any) error
func (*SharedTxRows) Values ¶
func (r *SharedTxRows) Values() ([]interface{}, error)