SQLite immutable connection
A SQLite immutable connection treats its database file as permanently unchanging and skips locking and change detection.
The immutable URI parameter is a caller promise, not a mechanism that freezes a file. It opens the database read-only, but is stronger than mode=ro: another writer must not change the file. Violating the promise can produce incorrect results or SQLITE_CORRUPT. [1]
In a constructed DELETE-journal schedule, an immutable connection kept generation 0 after a writer committed generation 1; a fresh connection saw 1. In the WAL schedule, both retained and fresh immutable connections saw main-file generation 0 while an ordinary reader saw committed generation 2. All those read views passed integrity_check. [3]
Normal read-only WAL access still participates in the WAL protocol. It needs readable sidecar files or permission to create them. Immutable is not a generic workaround for those permissions. For fixed read-only distribution, SQLite recommends preparing the database in DELETE journal mode. [4]
A frozen post-process-exit copy can still require rollback recovery. In Hesela's constructed hot-journal cases on two SQLite builds, immutable access returned all 12 uncommitted records while integrity_check reported ok; ordinary read-only access returned SQLITE_READONLY_ROLLBACK (776). Normal recovery on a separate writable copy restored committed records before immutable access. Unlike the mutable-file cases above, no writer remained alive during these reads. These are software process-exit observations, not physical power-loss tests. [5]
Relations
Citations
- SQLite: URI parameters, mode and immutable
- Hesela: measured SQLite reader contracts, nine constructed schedules
- Hesela: SQLite immutable-reader observations and provenance
- SQLite: Write-Ahead Logging, section 5, read-only databases
- Hesela: two-build frozen SQLite crash-copy reader matrix, 400 constructed observations