2
0

Resplit Begin and BeginEx

This is in preparation for a Begin / Tx interface that will similate
nested transactions with savepoints.

In addition, this passes the TxOptions struct by value and thereby
removes an allocation.
This commit is contained in:
Jack Christensen
2019-08-17 15:53:55 -05:00
parent f3c703a102
commit c3e41872a8
9 changed files with 44 additions and 35 deletions
+5 -2
View File
@@ -352,13 +352,16 @@ func (p *Pool) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults {
return &poolBatchResults{br: br, c: c}
}
func (p *Pool) Begin(ctx context.Context, txOptions *pgx.TxOptions) (*Tx, error) {
func (p *Pool) Begin(ctx context.Context) (*Tx, error) {
return p.BeginEx(ctx, pgx.TxOptions{})
}
func (p *Pool) BeginEx(ctx context.Context, txOptions pgx.TxOptions) (*Tx, error) {
c, err := p.Acquire(ctx)
if err != nil {
return nil, err
}
t, err := c.Begin(ctx, txOptions)
t, err := c.BeginEx(ctx, txOptions)
if err != nil {
return nil, err
}