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: u64The generation of this snapshot.
Implementations§
Source§impl StaticCatalog
impl StaticCatalog
Sourcepub fn empty() -> StaticCatalog
pub fn empty() -> StaticCatalog
Returns a catalog with one main database and no objects.
Sourcepub fn with_eponymous(self, table: TableInfo) -> StaticCatalog
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
Sourcepub fn table_named(&self, folded: &[u8]) -> Option<&TableInfo>
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
Sourcepub fn with_table(self, table: TableInfo) -> StaticCatalog
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
impl CatalogView for StaticCatalog
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
fn database_count(&self) -> usize
Returns the number of attached databases.
Source§fn database_name(&self, index: usize) -> &[u8] ⓘ
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>
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>
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>
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>
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
fn generation(&self) -> u64
Returns the generation of the snapshot.