Skip to main content

StaticCatalog

Struct StaticCatalog 

Source
pub struct StaticCatalog {
    pub databases: Vec<(Vec<u8>, u32)>,
    pub tables: Vec<Rc<TableInfo>>,
    pub eponymous: Vec<Rc<TableInfo>>,
    pub generation: u64,
}
Expand description

A catalog held in memory, which is what a test binds against and what the loader produces once it has read sqlite_schema.

Fields§

§databases: Vec<(Vec<u8>, u32)>

The attached databases, in attachment order, with their cookies.

§tables: Vec<Rc<TableInfo>>

Every table, in no particular order.

Shared rather than owned, because binding a statement used to clone one. BoundSource.table was a TableInfo by value, so every table reference in every statement deep-copied the catalog’s entry: two name vectors, a ColumnInfo per column each with its own heap fields, the full CREATE text, and an IndexInfo per index with its own column vector. Forty-odd allocations to bind one WHERE id = ?1, measured at 2,938 ns of prepare.point’s 6,093 - 48% of the statement’s whole compile. An Rc makes it a refcount bump.

§eponymous: Vec<Rc<TableInfo>>

The eponymous virtual tables the connection’s modules provide.

generate_series, json_each, json_tree, pragma_table_info: the name is the table, so they belong to no database and have no sqlite_schema row. They are searched last, so a real table called generate_series shadows the module rather than the other way round - which is SQLite’s order and the only safe one, because the file was there first.

Filled by the engine from its module registry on every catalog refresh. Nothing used to fill it, and the eponymous form did not exist: FROM generate_series(1,10) was no such table, which also left json_each unreachable from SQL by any route, because JsonWalkModule refuses CREATE VIRTUAL TABLE outright.

§generation: u64

The generation of this snapshot.

Implementations§

Source§

impl StaticCatalog

Source

pub fn empty() -> StaticCatalog

Returns a catalog with one main database and no objects.

Source

pub fn with_eponymous(self, table: TableInfo) -> StaticCatalog

Adds an eponymous virtual table, returning the catalog.

@param table - the module’s table, as its declaration describes it

Source

pub fn table_named(&self, folded: &[u8]) -> Option<&TableInfo>

Adds a table, returning the catalog, for building fixtures. Returns one table by folded name, searching every database.

Attachment order, main first, which is the order an unqualified name resolves in. A module asking about a name it was given as an argument wants the same table the statement that named it would have found.

@param folded - the table’s ASCII-folded name

Source

pub fn with_table(self, table: TableInfo) -> StaticCatalog

Returns this catalog with one more table in it.

@param table - the table to add

Trait Implementations§

Source§

impl CatalogView for StaticCatalog

Source§

fn shared_table( &self, database: Option<&[u8]>, folded: &[u8], ) -> Option<Rc<TableInfo>>

Returns a table as a shared pointer; the trait method’s override.

@param database - the schema qualifier, if the statement wrote one @param folded - the table’s folded name

Source§

fn database_count(&self) -> usize

Returns the number of attached databases.

Source§

fn database_name(&self, index: usize) -> &[u8] ⓘ

Returns the name of an attached database by index.

Source§

fn database_index(&self, folded: &[u8]) -> Option<usize>

Returns the index of an attached database by folded name.

Source§

fn find_table( &self, database: Option<&[u8]>, folded: &[u8], ) -> Option<&TableInfo>

Returns a table by name, searching in SQLite’s own order.

Source§

fn every_table(&self) -> Vec<&TableInfo>

Returns the table an index belongs to, and the index.

Source§

fn tables_of(&self, database: usize) -> Vec<&TableInfo>

Returns every table of one attached database.

Returns the schema cookie of an attached database.

Source§

fn generation(&self) -> u64

Returns the generation of the snapshot.

Source§

fn find_index( &self, database: Option<&[u8]>, folded: &[u8], ) -> Option<(&TableInfo, &IndexInfo)>

Returns the table an index belongs to, together with the index. Read more
Source§

fn find_trigger( &self, database: Option<&[u8]>, folded: &[u8], ) -> Option<(&TableInfo, &TriggerInfo)>

Returns the table a trigger is attached to, together with the trigger. Read more
Source§

impl Clone for StaticCatalog

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StaticCatalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StaticCatalog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for StaticCatalog

Source§

impl PartialEq for StaticCatalog

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for StaticCatalog

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.