Skip to main content

SqliteFile

Struct SqliteFile 

Source
pub struct SqliteFile { /* private fields */ }
Expand description

An open SQLite file, held for reading.

Implementations§

Source§

impl SqliteFile

Source

pub fn open(path: PathBuf) -> DbResult<SqliteFile>

Opens a SQLite database file read-only and starts a read transaction.

@param path - the database file

Source

pub fn page_size(&self) -> u32

Returns the file’s page size in bytes.

Source

pub fn page_count(&self) -> u32

Returns the number of pages in the file.

Source

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

Source

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.

Source

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

Source

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

Source

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.