Skip to content

Commit 36cccb2

Browse files
committed
transactions: check if the netConn ist valid
1 parent 3c1e4f1 commit 36cccb2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

transaction.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type mysqlTx struct {
1414
}
1515

1616
func (tx *mysqlTx) Commit() (err error) {
17-
if tx.mc == nil {
17+
if tx.mc == nil || tx.mc.netConn == nil {
1818
return errInvalidConn
1919
}
2020
err = tx.mc.exec("COMMIT")
@@ -23,7 +23,7 @@ func (tx *mysqlTx) Commit() (err error) {
2323
}
2424

2525
func (tx *mysqlTx) Rollback() (err error) {
26-
if tx.mc == nil {
26+
if tx.mc == nil || tx.mc.netConn == nil {
2727
return errInvalidConn
2828
}
2929
err = tx.mc.exec("ROLLBACK")

0 commit comments

Comments
 (0)