...
1 package pgxpool
2
3 import (
4 "context"
5
6 "github.com/jackc/pgx/v5"
7 "github.com/jackc/pgx/v5/pgconn"
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
22
23
24 func (tx *Tx) Commit(ctx context.Context) error {
25 err := tx.t.Commit(ctx)
26 if tx.c != nil {
27 tx.c.Release()
28 tx.c = nil
29 }
30 return err
31 }
32
33
34
35
36 func (tx *Tx) Rollback(ctx context.Context) error {
37 err := tx.t.Rollback(ctx)
38 if tx.c != nil {
39 tx.c.Release()
40 tx.c = nil
41 }
42 return err
43 }
44
45 func (tx *Tx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) {
46 return tx.t.CopyFrom(ctx, tableName, columnNames, rowSrc)
47 }
48
49 func (tx *Tx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults {
50 return tx.t.SendBatch(ctx, b)
51 }
52
53 func (tx *Tx) LargeObjects() pgx.LargeObjects {
54 return tx.t.LargeObjects()
55 }
56
57
58
59
60
61
62
63
64 func (tx *Tx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error) {
65 return tx.t.Prepare(ctx, name, sql)
66 }
67
68 func (tx *Tx) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) {
69 return tx.t.Exec(ctx, sql, arguments...)
70 }
71
72 func (tx *Tx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) {
73 return tx.t.Query(ctx, sql, args...)
74 }
75
76 func (tx *Tx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row {
77 return tx.t.QueryRow(ctx, sql, args...)
78 }
79
80 func (tx *Tx) Conn() *pgx.Conn {
81 return tx.t.Conn()
82 }
83
View as plain text