diff --git a/AUTHORS b/AUTHORS index a261819f..ec346e20 100644 --- a/AUTHORS +++ b/AUTHORS @@ -25,6 +25,7 @@ Asta Xie <xiemengjun at gmail.com> B Lamarche <blam413 at gmail.com> Bes Dollma <bdollma@thousandeyes.com> Bogdan Constantinescu <bog.con.bc at gmail.com> +Brad Higgins <brad at defined.net> Brian Hendriks <brian at dolthub.com> Bulat Gaifullin <gaifullinbf at gmail.com> Caine Jette <jette at alum.mit.edu> @@ -134,6 +135,7 @@ Ziheng Lyu <zihenglv at gmail.com> Barracuda Networks, Inc. Counting Ltd. +Defined Networking Inc. DigitalOcean Inc. Dolthub Inc. dyves labs AG diff --git a/transaction.go b/transaction.go index 4a4b6100..8c502f49 100644 --- a/transaction.go +++ b/transaction.go @@ -13,18 +13,32 @@ type mysqlTx struct { } func (tx *mysqlTx) Commit() (err error) { - if tx.mc == nil || tx.mc.closed.Load() { + if tx.mc == nil { return ErrInvalidConn } + if tx.mc.closed.Load() { + err = tx.mc.error() + if err == nil { + err = ErrInvalidConn + } + return + } err = tx.mc.exec("COMMIT") tx.mc = nil return } func (tx *mysqlTx) Rollback() (err error) { - if tx.mc == nil || tx.mc.closed.Load() { + if tx.mc == nil { return ErrInvalidConn } + if tx.mc.closed.Load() { + err = tx.mc.error() + if err == nil { + err = ErrInvalidConn + } + return + } err = tx.mc.exec("ROLLBACK") tx.mc = nil return