From 17d4f7d59115cf1c387ab8dc845fa261b9f42f26 Mon Sep 17 00:00:00 2001 From: CyJay Date: Wed, 4 Feb 2026 10:55:45 +0800 Subject: [PATCH] =?UTF-8?q?stdlib=E5=8C=85=E6=B7=BB=E5=8A=A0GetTxFromDrive?= =?UTF-8?q?rTx=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdlib/sql.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stdlib/sql.go b/stdlib/sql.go index 576d3c60f..0b2009ef9 100644 --- a/stdlib/sql.go +++ b/stdlib/sql.go @@ -907,3 +907,10 @@ type wrapTx struct { func (wtx wrapTx) Commit() error { return wtx.tx.Commit(wtx.ctx) } func (wtx wrapTx) Rollback() error { return wtx.tx.Rollback(wtx.ctx) } + +func GetTxFromDriverTx(driverTx driver.Tx) (pgx.Tx, bool) { + if wtx, ok := driverTx.(wrapTx); ok { + return wtx.tx, true + } + return nil, false +}