...
1 package pgxpool
2
3 import (
4 "context"
5
6 "github.com/jackc/pgconn"
7 "github.com/jackc/pgx/v4"
8 )
9
10
11 type Tx struct {
12 t pgx.Tx
13 c *Conn
14 }
15
16
17 func (tx *Tx) Begin(ctx context.Context) (pgx.Tx, error) {
18 return tx.t.Begin(ctx)
19 }
20
21 func (tx *Tx) BeginFunc(ctx context.Context, f func(pgx.Tx) error) error {
22 return tx.t.BeginFunc(ctx, f)
23 }
24
25
26
27
28 func (tx *Tx) Commit(ctx context.Context) error {
29 err := tx.t.Commit(ctx)
30 if tx.c != nil {
31 tx.c.Release()
32 tx.c = nil
33 }
34 return err
35 }
36
37
38
39
40 func (tx *Tx) Rollback(ctx context.Context) error {
41 err := tx.t.Rollback(ctx)
42 if tx.c != nil {
43 tx.c.Release()
44 tx.c = nil
45 }
46 return err
47 }
48
49 func (tx *Tx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) {
50 return tx.t.CopyFrom(ctx, tableName, columnNames, rowSrc)
51 }
52
53 func (tx *Tx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults {
54 return tx.t.SendBatch(ctx, b)
55 }
56
57 func (tx *Tx) LargeObjects() pgx.LargeObjects {
58 return tx.t.LargeObjects()
59 }
60
61
62
63
64
65
66
67
68 func (tx *Tx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error) {
69 return tx.t.Prepare(ctx, name, sql)
70 }
71
72 func (tx *Tx) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) {
73 return tx.t.Exec(ctx, sql, arguments...)
74 }
75
76 func (tx *Tx) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) {
77 return tx.t.Query(ctx, sql, args...)
78 }
79
80 func (tx *Tx) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row {
81 return tx.t.QueryRow(ctx, sql, args...)
82 }
83
84 func (tx *Tx) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
85 return tx.t.QueryFunc(ctx, sql, args, scans, f)
86 }
87
88 func (tx *Tx) Conn() *pgx.Conn {
89 return tx.t.Conn()
90 }
91
View as plain text