Browse Source

transactions: check if the netConn ist valid

Julien Schmidt 12 years ago
parent
commit
36cccb2433
1 changed files with 2 additions and 2 deletions
  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")