Ver Fonte

transactions: check if the netConn ist valid

Julien Schmidt há 12 anos atrás
pai
commit
36cccb2433
1 ficheiros alterados com 2 adições e 2 exclusões
  1. 2 2
      transaction.go

+ 2 - 2
transaction.go

@@ -14,7 +14,7 @@ type mysqlTx struct {
 }
 
 func (tx *mysqlTx) Commit() (err error) {
-	if tx.mc == nil {
+	if tx.mc == nil || tx.mc.netConn == nil {
 		return errInvalidConn
 	}
 	err = tx.mc.exec("COMMIT")
@@ -23,7 +23,7 @@ func (tx *mysqlTx) Commit() (err error) {
 }
 
 func (tx *mysqlTx) Rollback() (err error) {
-	if tx.mc == nil {
+	if tx.mc == nil || tx.mc.netConn == nil {
 		return errInvalidConn
 	}
 	err = tx.mc.exec("ROLLBACK")