Skip to content

keep reading numbers into text fields; roll back the transaction when its commit fails - #5

Open
evgeny-simplex wants to merge 5 commits into
simplex-chat:sqlcipherfrom
evgeny-simplex:ep/sqlcipher-sync
Open

evgeny-simplex wants to merge 5 commits into
simplex-chat:sqlcipherfrom
evgeny-simplex:ep/sqlcipher-sync

Conversation

@evgeny-simplex

@evgeny-simplex evgeny-simplex commented Nov 19, 2026 •

Copy link
Copy Markdown

Problem. The transaction functions roll back when the action throws, but not when COMMIT or RELEASE throws. A COMMIT that fails with SQLITE_BUSY keeps the transaction active (https://sqlite.org/lang_transaction.html), so every later BEGIN on the connection fails with "cannot start a transaction within a transaction".

Fix (Database/SQLite/Simple.hs, da0ac92):

  • a failed COMMIT or RELEASE is rolled back, and its error rethrown;
  • the rollback is skipped when no transaction is active, so the original error is kept;
  • outside a transaction, withSavepoint runs as withTransaction (ROLLBACK TO does not end a transaction, https://sqlite.org/lang_savepoint.html).

Text fields (720aba3): numbers are read into text fields, as in the fork since 2022; upstream reverted it (b8a1f83).

Build (b7cfe84): direct-sqlcipher pinned to 2330df3 in cabal.project and stack.yaml, as in CI and SimpleX.

Tests (test/Errors.hs, ebdab2b, c1e32db): busy COMMIT and RELEASE through a second connection, a transaction after a failed savepoint, COMMIT's own error rethrown.

CI passed on the same tree: https://github.com/simplex-chat/sqlcipher-simple/actions/runs/44637086587

@evgeny-simplex evgeny-simplex changed the title update to sqlite-simple 0.4.19.0; roll back the transaction when its commit fails roll back the transaction when its commit fails Nov 19, 2026
@evgeny-simplex evgeny-simplex changed the title roll back the transaction when its commit fails keep reading numbers into text fields; roll back the transaction when its commit fails Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants