Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ac04e5f

Browse files
methanebrad-defined
andauthored
Transaction Commit/Rollback returns conn's cached error (#1702)
If a transaction connection has a cached error, return it instead of ErrInvalidConn during Commit/Rollback operations. Fix #1690 Co-authored-by: brad-defined <77982333+brad-defined@users.noreply.github.com>
1 parent 1bee809 commit ac04e5f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

‎AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Asta Xie <xiemengjun at gmail.com>
2525
B Lamarche <blam413 at gmail.com>
2626
Bes Dollma <bdollma@thousandeyes.com>
2727
Bogdan Constantinescu <bog.con.bc at gmail.com>
28+
Brad Higgins <brad at defined.net>
2829
Brian Hendriks <brian at dolthub.com>
2930
Bulat Gaifullin <gaifullinbf at gmail.com>
3031
Caine Jette <jette at alum.mit.edu>
@@ -134,6 +135,7 @@ Ziheng Lyu <zihenglv at gmail.com>
134135

135136
Barracuda Networks, Inc.
136137
Counting Ltd.
138+
Defined Networking Inc.
137139
DigitalOcean Inc.
138140
Dolthub Inc.
139141
dyves labs AG

‎transaction.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,32 @@ type mysqlTx struct {
1313
}
1414

1515
func (tx *mysqlTx) Commit() (err error) {
16-
if tx.mc == nil ||tx.mc.closed.Load() {
16+
if tx.mc == nil {
1717
return ErrInvalidConn
1818
}
19+
if tx.mc.closed.Load() {
20+
err = tx.mc.error()
21+
if err == nil {
22+
err = ErrInvalidConn
23+
}
24+
return
25+
}
1926
err = tx.mc.exec("COMMIT")
2027
tx.mc = nil
2128
return
2229
}
2330

2431
func (tx *mysqlTx) Rollback() (err error) {
25-
if tx.mc == nil ||tx.mc.closed.Load() {
32+
if tx.mc == nil {
2633
return ErrInvalidConn
2734
}
35+
if tx.mc.closed.Load() {
36+
err = tx.mc.error()
37+
if err == nil {
38+
err = ErrInvalidConn
39+
}
40+
return
41+
}
2842
err = tx.mc.exec("ROLLBACK")
2943
tx.mc = nil
3044
return

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /