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
Limitations
- A per-connection state sample does not identify which other connection is retaining WAL history.