Expand description
Page allocator for save_database (SQLR-6).
Replaces the bare next_free_page: u32 counter that the staging code
used to thread through every stage_*_btree function. The allocator
draws from three pools, in order of preference:
- Per-table preferred pool — pages the table previously occupied,
seeded by [
set_preferred]. An unchanged table’s stage produces byte-identical pages at the same numbers, so the diff pager skips every write for it. - Global freelist — pages dropped tables/indexes used to occupy plus the trunk pages of the previously-persisted freelist.
- Extend —
next_extend++, monotonic past the current high water.
After staging finishes, [high_water] is the new page_count and
[used] enumerates every page actually written this save (so the
caller can compute the new freelist as old_live − used).
Structs§
- Page
Allocator - Hands out page numbers during a save.