forked from mirror/go-sqlcipher
Merge pull request #300 from sqweek/issue184
Fix inconsistent tx state with database/sql.
This commit is contained in:
commit
e118d44513
|
@ -296,6 +296,12 @@ func (ai *aggInfo) Done(ctx *C.sqlite3_context) {
|
||||||
// Commit transaction.
|
// Commit transaction.
|
||||||
func (tx *SQLiteTx) Commit() error {
|
func (tx *SQLiteTx) Commit() error {
|
||||||
_, err := tx.c.exec("COMMIT")
|
_, err := tx.c.exec("COMMIT")
|
||||||
|
if err != nil && err.(Error).Code == C.SQLITE_BUSY {
|
||||||
|
// sqlite3 will leave the transaction open in this scenario.
|
||||||
|
// However, database/sql considers the transaction complete once we
|
||||||
|
// return from Commit() - we must clean up to honour its semantics.
|
||||||
|
tx.c.exec("ROLLBACK")
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue