BeginTx acquires a connection from the [Pool] and starts a transaction with [pgx.TxOptions] determining the transaction mode. Unlike [database/sql], the context only affects the begin command. i.e. there is no auto-rollback on context cancellation. [*Tx] is returned, which implements the [pgx.Tx] in
(ctx context.Context, txOptions pgx.TxOptions)
| 804 | // [*Tx] is returned, which implements the [pgx.Tx] interface. |
| 805 | // [Tx.Commit] or [Tx.Rollback] must be called on the returned transaction to finalize the transaction block. |
| 806 | func (p *Pool) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) { |
| 807 | c, err := p.Acquire(ctx) |
| 808 | if err != nil { |
| 809 | return nil, err |
| 810 | } |
| 811 | |
| 812 | t, err := c.BeginTx(ctx, txOptions) |
| 813 | if err != nil { |
| 814 | c.Release() |
| 815 | return nil, err |
| 816 | } |
| 817 | |
| 818 | return &Tx{t: t, c: c}, nil |
| 819 | } |
| 820 | |
| 821 | func (p *Pool) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) { |
| 822 | c, err := p.Acquire(ctx) |