aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlite3.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 4d81917..86f686c 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -292,6 +292,12 @@ func (ai *aggInfo) Done(ctx *C.sqlite3_context) {
// Commit transaction.
func (tx *SQLiteTx) Commit() error {
_, 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
}