Skip to main content

Module catalog

Module catalog 

Source
Expand description

An SQLite catalog, encrypted with SQLCipher under its catalog key.

Enums§

CatalogError
Why a catalog did not open.

Constants§

BUSY_TIMEOUT
How long a statement waits for another connection’s lock before it fails busy. It is rusqlite’s own default, stated so it is chosen, not inherited; a caller that must not wait inside SQLite sets zero for the call and restores this.
SCHEMA_VERSION
The schema version this build makes and reads. Version 2 added the time each uuid was first stored to a tenant catalog’s vcon table; version 3 added each tenant’s metadata level to server.sqlite; version 4 added the places of packed versions and the pack tables to a tenant catalog.

Functions§

backup
Copies the catalog source is open on to a new file at to, kept under key, which must be the key source was opened with. It uses SQLite’s online backup API and copies every page in one step, so the copy is the catalog as one commit left it, the WAL’s committed frames included, while other connections go on writing. to must not exist: it is made empty first, so a file already there is never written over. The copy and its directory are synced.
copy_under
Writes every row, the schema and its version of the catalog at path, kept under old, to a new file beside it kept under new, and returns that file’s path. The old file is only read. A file left there by an interrupted run is replaced.
open
Opens the catalog at path under key, making it with schema if it is new.
reencrypt
Re-encrypts the catalog at path, kept under old, so that it is kept under new: every row, the schema and its version are written to a new file under new, which then replaces the old one by rename. A crash leaves either the whole old file or the whole new one, and nothing of the old file’s pages is carried into the new one. A file left by an interrupted run is replaced.
replace
Makes copy the catalog at path: it is synced, renamed over path, and the directory synced. Every connection to either file must be closed. Their WAL files must be empty, as a last close leaves them; one still holding frames would sit beside the wrong file, so it is refused.