Skip to content

Commit 7d882f9

Browse files
committed
Fix *dbTx.Exec not checking if it is already closed
#1908
1 parent 1d07b8b commit 7d882f9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tx.go

+4
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ func (tx *dbTx) Rollback(ctx context.Context) error {
264264

265265
// Exec delegates to the underlying *Conn
266266
func (tx *dbTx) Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error) {
267+
if tx.closed {
268+
return pgconn.CommandTag{}, ErrTxClosed
269+
}
270+
267271
return tx.conn.Exec(ctx, sql, arguments...)
268272
}
269273

0 commit comments

Comments
 (0)