Skip to content

Commit c457de6

Browse files
committed
Fix doc discrepancies between Tx interface and pgxpool implementation
The error is not wrapped at the moment, but document that it may be. fixes #2104
1 parent a68e14f commit c457de6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pgxpool/tx.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ func (tx *Tx) Begin(ctx context.Context) (pgx.Tx, error) {
1818
return tx.t.Begin(ctx)
1919
}
2020

21-
// Commit commits the transaction and returns the associated connection back to the Pool. Commit will return ErrTxClosed
22-
// if the Tx is already closed, but is otherwise safe to call multiple times. If the commit fails with a rollback status
23-
// (e.g. the transaction was already in a broken state) then ErrTxCommitRollback will be returned.
21+
// Commit commits the transaction and returns the associated connection back to the Pool. Commit will return an error
22+
// where errors.Is(ErrTxClosed) is true if the Tx is already closed, but is otherwise safe to call multiple times. If
23+
// the commit fails with a rollback status (e.g. the transaction was already in a broken state) then ErrTxCommitRollback
24+
// will be returned.
2425
func (tx *Tx) Commit(ctx context.Context) error {
2526
err := tx.t.Commit(ctx)
2627
if tx.c != nil {
@@ -30,9 +31,9 @@ func (tx *Tx) Commit(ctx context.Context) error {
3031
return err
3132
}
3233

33-
// Rollback rolls back the transaction and returns the associated connection back to the Pool. Rollback will return ErrTxClosed
34-
// if the Tx is already closed, but is otherwise safe to call multiple times. Hence, defer tx.Rollback() is safe even if
35-
// tx.Commit() will be called first in a non-error condition.
34+
// Rollback rolls back the transaction and returns the associated connection back to the Pool. Rollback will return
35+
// where an error where errors.Is(ErrTxClosed) is true if the Tx is already closed, but is otherwise safe to call
36+
// multiple times. Hence, defer tx.Rollback() is safe even if tx.Commit() will be called first in a non-error condition.
3637
func (tx *Tx) Rollback(ctx context.Context) error {
3738
err := tx.t.Rollback(ctx)
3839
if tx.c != nil {

0 commit comments

Comments
 (0)