Skip to content

Commit

Permalink
Exec checks if tx is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
jackc committed Oct 24, 2022
1 parent 3e825ec commit 3ad9995
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ func (tx *dbTx) Rollback(ctx context.Context) error {

// Exec delegates to the underlying *Conn
func (tx *dbTx) Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error) {
if tx.closed {
return pgconn.CommandTag{}, ErrTxClosed
}

return tx.conn.Exec(ctx, sql, arguments...)
}

Expand Down

0 comments on commit 3ad9995

Please sign in to comment.