sqlite-transaction-state · shipping · also sqlite3_txn_state, SQLITE_TXN_NONE, SQLITE_TXN_READ, SQLITE_TXN_WRITE

SQLite transaction state

SQLite transaction state reports whether a named database on a connection currently has no transaction, a read transaction or a write transaction.

sqlite3_txn_state(D, S) reports the state of schema S. With a NULL schema argument it returns the highest state across schemas: NONE (0), READ (1) or WRITE (2). An unknown schema name returns -1. The aggregate is not an inventory of individual databases. [1] [2]

Autocommit is a different signal. BEGIN DEFERRED disables autocommit before the first database access establishes a read or write transaction. Thus disabled autocommit does not by itself prove that a read snapshot exists. [3] [4]

Hesela's 84-run backup study observed this distinction on two builds. BEGIN alone left the main schema at NONE between steps; BEGIN plus SELECT retained READ after backup completion or cancellation. The study did not test attached-schema aggregation. [5]

Diagnostic implication: sample the actual backup source schema and track transaction ownership and lifetime separately. A state value is not a snapshot identifier, age, checkpoint-backlog measurement or permission to roll back unrelated pooled work.

Relations

related
SQLite Online Backup API, SQLite WAL end mark, Checkpoint starvation, Storage snapshot

Limitations

  • A per-connection state sample does not identify which other connection is retaining WAL history.

Citations

  1. SQLite C API: Determine the transaction state of a database (accessed 2026-10-21)
  2. SQLite C API: Allowed return values from sqlite3_txn_state() (accessed 2026-10-21)
  3. SQLite C API: Test For Auto-Commit Mode (accessed 2026-10-21)
  4. SQLite: DEFERRED, IMMEDIATE and EXCLUSIVE transactions (accessed 2026-10-21)
  5. Hesela: source-read ownership after backup cleanup, two-build experiment and limits (accessed 2026-10-21)

JSON: /data/terms/sqlite-transaction-state.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. SQLite transaction state. Hesela. 2026-10-21. https://hesela.dev/terms/sqlite-transaction-state/