Skip to content
Permalink
Browse files
fix cobar TRANSACTION
  • Loading branch information
董玉增 committed Mar 27, 2016
1 parent 66312f7 commit deb085abeb1a53643d094a11ce3bb33f00ba7287
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
@@ -67,7 +67,8 @@ func (mc *mysqlConn) Begin() (driver.Tx, error) {
errLog.Print(ErrInvalidConn)
return nil, driver.ErrBadConn
}
err := mc.exec("START TRANSACTION")
//err := mc.exec("START TRANSACTION")
err := mc.exec("SET AUTOCOMMIT=0")
if err == nil {
return &mysqlTx{mc}, err
}
@@ -17,6 +17,7 @@ func (tx *mysqlTx) Commit() (err error) {
return ErrInvalidConn
}
err = tx.mc.exec("COMMIT")
err = tx.mc.exec("SET AUTOCOMMIT=1")
tx.mc = nil
return
}
@@ -26,6 +27,7 @@ func (tx *mysqlTx) Rollback() (err error) {
return ErrInvalidConn
}
err = tx.mc.exec("ROLLBACK")
err = tx.mc.exec("SET AUTOCOMMIT=1")
tx.mc = nil
return
}

0 comments on commit deb085a

Please sign in to comment.