Skip to main content

Module attribution

Module attribution 

Source
Expand description

Best-effort, dependency-free attribution primitives that reconnect a carved deleted row to the live table it most plausibly belonged to.

A deleted row in free space has lost its hard table linkage (the b-tree that owned it no longer points at it). This module supplies the two structural facts the forensic layer needs to reattach it honestly:

  1. column_names — a hand-rolled CREATE TABLE column-name extractor (no SQL-parser dependency). It returns the declared column names when it can parse them with confidence, or None so the caller falls back to generic c0..cN rather than emit wrong names.
  2. column_affinity — each column’s declared affinity (file-format §3.1), the shape used to match a freed row whose page linkage is gone.

Pure string/structure work: panic-free, forbid(unsafe), no new deps.

Structs§

LiveTable
A live (schema-present) table, as read from sqlite_master: its name, b-tree rootpage, and per-column shape used to attribute a freed row whose page linkage is gone.

Enums§

Affinity
Column type affinity as defined by the SQLite file format (§3.1, “Type Affinity”). Derived from a column’s declared type by the documented substring rules, in priority order. A column with no declared type is Blob (SQLite’s “BLOB or no datatype” affinity).

Functions§

column_affinity
Compute a column’s Affinity from its declared type string per the file-format §3.1 rules, applied in the documented priority order: INT → TEXT → BLOB/none → REAL → NUMERIC. Case-insensitive; an empty (no) declared type is Affinity::Blob.
column_defs
Best-effort extraction of (column_name, declared_type) for each column declared in a CREATE TABLE statement, without a SQL-parser dependency.
column_names
Just the column names from column_defs (the common need). None when the body cannot be parsed with confidence.