Skip to main content

Module header

Module header 

Source
Expand description

Database file header (page 0).

The first 28 bytes of every .sqlrite file identify the format and point at the schema catalog. The rest of page 0 is reserved for future use.

Structs§

DbHeader
Parsed header. page_count includes page 0 itself.

Constants§

FORMAT_VERSION_BASELINE
The version a brand-new write defaults to when no FTS index forces a bump. Existing databases keep their on-disk version unchanged across reads + non-FTS writes; FTS-bearing saves switch to V5, freelist-bearing saves switch to V6.
FORMAT_VERSION_V4
On-disk format revision. Bump when the page layout changes incompatibly.
FORMAT_VERSION_V5
FORMAT_VERSION_V6
MAGIC
File magic. Distinct from SQLite’s "SQLite format 3\0" so the formats can’t be confused on inspection.

Functions§

decode_header
Decodes the header from a PAGE_SIZE-sized buffer. Returns an error if magic bytes, format version, or page size don’t match what we wrote. V4, V5, and V6 are accepted; the result’s format_version echoes what was on disk so a no-op resave preserves it. freelist_head is read from bytes [28..32] for V6 files; V4/V5 files have a zero reserved region there, so the field decodes as 0 either way.
encode_header
Encodes the header into a PAGE_SIZE-sized buffer.