pub struct PriorSnapshot { /* private fields */ }Expand description
A read-only, page-addressable image of the database AS IT WAS BEFORE the last
transaction (design §4/§5). The temporal inverse of CommitSnapshot:
prior[pgno] is the rollback-journal image where present, else the live main
page. Diffing this against the current database yields the last transaction’s
deletions (rowid present here, absent now) and modifications (present in both,
values differ — the journal carries the OLD value).
Returned by Database::rollback_prior as a DISTINCT type, never a
Database, so prior/deleted rows can never be read as “live”
(secure-by-design). Shares ONE b-tree/overflow walk with the live and
commit-snapshot reads via the internal PageSource seam.
Implementations§
Source§impl PriorSnapshot
impl PriorSnapshot
Sourcepub fn tables(&self) -> Vec<SnapshotTable>
pub fn tables(&self) -> Vec<SnapshotTable>
The user tables AS OF the prior state, parsed from the snapshot’s OWN page 1
(the prior sqlite_master), NOT the live database — so a DROP/CREATE in the
last transaction is interpreted against the prior schema. Best-effort and
panic-free: an unreadable page-1 schema yields an empty vector.
Sourcepub fn schema_sql(&self) -> BTreeMap<String, String>
pub fn schema_sql(&self) -> BTreeMap<String, String>
The PRIOR sqlite_master as a name -> CREATE SQL map for every user
table, parsed from the snapshot’s OWN page 1 — the prior-schema half of the
Detector-B sidecar schema-change comparison
(docs/design/drop-recreate-attribution.md).
The counterpart to Database::schema_sql read against the pre-transaction
state the -journal preserves, so a DROP/CREATE/ALTER in the last
transaction is interpreted against the prior schema. Best-effort and
panic-free: an unreadable prior page-1 schema yields an empty map.
Sourcepub fn read_table(
&self,
rootpage: u32,
column_count: usize,
) -> Result<Vec<(i64, Vec<Value>)>, Error>
pub fn read_table( &self, rootpage: u32, column_count: usize, ) -> Result<Vec<(i64, Vec<Value>)>, Error>
Read every row of the table b-tree rooted at rootpage AS OF the prior
state, in rowid order, resolving overflow chains through the snapshot’s OWN
pages. The snapshot-scoped counterpart to Database::read_table: a typed
Error (never a panic) on a cyclic/over-deep b-tree or overflow chain.
Sourcepub fn grew_db(&self) -> bool
pub fn grew_db(&self) -> bool
Whether the last transaction GREW the database (a journal page number exceeded the current main-db page count). Pages beyond the prior size are new — their pre-images were not journaled — which bounds what rolls back.
Sourcepub fn read_table_with_pages(
&self,
rootpage: u32,
column_count: usize,
) -> Result<Vec<(i64, Vec<Value>, u32)>, Error>
pub fn read_table_with_pages( &self, rootpage: u32, column_count: usize, ) -> Result<Vec<(i64, Vec<Value>, u32)>, Error>
Read the table rooted at rootpage AS OF the prior state, returning each
row’s rowid, values, AND the 1-based LEAF page it was decoded from — the
per-row page provenance the forensic diff attaches to a recovered prior
row. Shares decode_leaf_cell with the standard read; a typed Error
(never a panic) on a cyclic/over-deep b-tree.
Trait Implementations§
Source§impl Clone for PriorSnapshot
impl Clone for PriorSnapshot
Source§fn clone(&self) -> PriorSnapshot
fn clone(&self) -> PriorSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more