From 7d882f9aa7b33f88fcf9da6b795685c5821950fd Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Fri, 23 Feb 2024 18:02:28 -0600 Subject: [PATCH] Fix *dbTx.Exec not checking if it is already closed https://github.com/jackc/pgx/issues/1908 --- tx.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tx.go b/tx.go index 2914ada7d..9ecaa17e9 100644 --- a/tx.go +++ b/tx.go @@ -264,6 +264,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 ...interface{}) (commandTag pgconn.CommandTag, err error) { + if tx.closed { + return pgconn.CommandTag{}, ErrTxClosed + } + return tx.conn.Exec(ctx, sql, arguments...) }