SQLite query_only
SQLite query_only is a connection setting that rejects data-changing SQL without making its database handles truly read-only.
With query_only enabled, CREATE, DELETE, DROP, INSERT and UPDATE return SQLITE_READONLY. Checkpoint and COMMIT operations remain possible, and sqlite3_db_readonly is unaffected. The setting therefore does not certify zero filesystem writes. [1]
In two constructed schedules, query_only readers rejected a main-table update but observed later committed generations through normal reads in both DELETE and WAL modes. Read permission, transaction snapshot lifetime and the immutable file promise are separate boundaries. [3]
In a third schedule, that same SQL-restricting setting allowed TRUNCATE checkpoint: the main-file hash changed and the WAL shrank from 8,272 bytes to zero. All records still matched generation 2. SQL write rejection did not prevent these file-state changes. [3]
query_only is not an evidence-preservation sandbox. On a read-write connection, a read in the constructed hot-journal fixture restored the main file to its committed bytes despite query_only being enabled. Both tested builds agreed; these process-exit observations do not establish physical durability. Preserve original evidence and inspect a separate working copy. [4]
Relations
Citations
- SQLite: PRAGMA query_only
- Hesela: SQLite immutable-reader observations and provenance
- Hesela: two-build frozen SQLite crash-copy reader matrix, 400 constructed observations
Further reading
- Hesela: measured SQLite reader contracts, nine constructed schedules
- Hesela: native reproduction code, full observations, source receipts and checks
Sources & caveats
- The nine-case experiment used SQLite 3.45.1 and sequential calls. File hashes and lengths were observed through the operating system, without syscall tracing, power cuts or proof of stable-media persistence. [3]