pub struct SqliteFile { /* private fields */ }Expand description
An open SQLite file, held for reading.
Implementations§
Source§impl SqliteFile
impl SqliteFile
Sourcepub fn open(path: PathBuf) -> DbResult<SqliteFile>
pub fn open(path: PathBuf) -> DbResult<SqliteFile>
Opens a SQLite database file read-only and starts a read transaction.
@param path - the database file
Sourcepub fn page_count(&self) -> u32
pub fn page_count(&self) -> u32
Returns the number of pages in the file.
Sourcepub fn catalog(&mut self, name: &[u8]) -> DbResult<DatabaseCatalog>
pub fn catalog(&mut self, name: &[u8]) -> DbResult<DatabaseCatalog>
Returns the file’s catalog, with indexes attached to their tables.
This goes through inillucent-catalog’s own loader rather than parsing the
schema again here. There is one schema reader in the workspace and this
is not a second one: an index’s key columns, its collations and its
descending flags all come from parsing CREATE INDEX against the
table it indexes, and a fixture import that got any of them wrong would
build a tree in an order the executor then assumes wrongly.
@param name - the name to attach the database under, normally main
Sourcepub fn schema(&mut self) -> DbResult<Vec<SchemaObject>>
pub fn schema(&mut self) -> DbResult<Vec<SchemaObject>>
Returns every row of sqlite_schema.
Reads the file’s own header encoding, not a fixed one. This and the
two record readers below used to build every RecordRef with
TextEncoding::Utf8 regardless of what the file’s header at offset 56
declared, so a UTF-16LE or UTF-16BE fixture came back with every text
field decoded as if it were UTF-8: two bytes per character, so ASCII
text like alpha read back as a\0l\0p\0h\0a\0. Pager::text_encoding
already parses that header field correctly - cursor.rs, mutate.rs
and schema.rs in inillucent-storage all read it before decoding a
record - this crate simply never asked.
Sourcepub fn object(&mut self, kind: &str, name: &str) -> DbResult<SchemaObject>
pub fn object(&mut self, kind: &str, name: &str) -> DbResult<SchemaObject>
Returns one named schema object.
@param kind - table or index
@param name - the object’s name
Sourcepub fn read_table(
&mut self,
root: u32,
columns: usize,
) -> DbResult<Vec<Vec<OwnedDatum>>>
pub fn read_table( &mut self, root: u32, columns: usize, ) -> DbResult<Vec<Vec<OwnedDatum>>>
Reads every row of a table b-tree.
The rowid is prepended as column 0, which is what a rowid-clustered tree
in the new format holds: SQLite stores the rowid in the cell key rather
than in the record, and an INTEGER PRIMARY KEY column’s record field is
NULL because of it. Prepending makes the row the new engine’s shape.
@param root - the table’s root page @param columns - how many record fields the table declares
Sourcepub fn read_index(
&mut self,
root: u32,
columns: usize,
) -> DbResult<Vec<Vec<OwnedDatum>>>
pub fn read_index( &mut self, root: u32, columns: usize, ) -> DbResult<Vec<Vec<OwnedDatum>>>
Reads every entry of an index b-tree.
An index entry’s record is the indexed columns followed by the rowid, so the returned row is already the new format’s index-tree row shape and no column is prepended.
@param root - the index’s root page @param columns - how many fields an entry holds, rowid included