pub struct MemDatabase {
pub tables: SwissIndex<i32, MemTable>,
/* private fields */
}Expand description
Shared in-memory database backing the VDBE engine’s cursor operations.
Maps root page numbers to in-memory tables. The Connection layer populates this when processing CREATE TABLE and passes it to the engine.
Fields§
§tables: SwissIndex<i32, MemTable>Tables indexed by root page number.
Implementations§
Source§impl MemDatabase
impl MemDatabase
Sourcepub fn set_collation_registry(
&mut self,
registry: Arc<Mutex<CollationRegistry>>,
)
pub fn set_collation_registry( &mut self, registry: Arc<Mutex<CollationRegistry>>, )
Propagate a shared collation registry to all tracked MemTables.
Sourcepub fn table_count(&self) -> i32
pub fn table_count(&self) -> i32
Returns the number of tables in the database.
Sourcepub fn next_root_page(&self) -> i32
pub fn next_root_page(&self) -> i32
Return the next root page that would be assigned by create_table.
Sourcepub fn set_next_root_page(&mut self, val: i32)
pub fn set_next_root_page(&mut self, val: i32)
Advance the root page counter so future allocations start at val.
Used to prevent MemDatabase root pages from colliding with pager- allocated pages (e.g. when materializing sqlite_master temp tables).
Sourcepub fn allocate_root_page(&mut self) -> i32
pub fn allocate_root_page(&mut self) -> i32
Allocate and return the next root page number without creating a table.
Used by OpenAutoindex which needs a unique page number for a
MemPageStore-backed index cursor but must NOT pollute self.tables
(a spurious MemTable entry would cause get_table() to return
Some, misleading open_storage_cursor into treating the page as a
table B-tree).
Sourcepub fn create_table(&mut self, num_columns: usize) -> i32
pub fn create_table(&mut self, num_columns: usize) -> i32
Create a table and return its root page number.
Sourcepub fn create_table_at(&mut self, root_page: i32, num_columns: usize)
pub fn create_table_at(&mut self, root_page: i32, num_columns: usize)
Create a table at a specific root page number.
Used by the storage layer (5A.3) when the root page is allocated
from the pager rather than auto-assigned. Advances
next_root_page past root_page if necessary so that future
create_table() calls do not collide.
Sourcepub fn get_table(&self, root_page: i32) -> Option<&MemTable>
pub fn get_table(&self, root_page: i32) -> Option<&MemTable>
Get a reference to a table by root page.
Sourcepub fn get_table_mut(&mut self, root_page: i32) -> Option<&mut MemTable>
pub fn get_table_mut(&mut self, root_page: i32) -> Option<&mut MemTable>
Get a mutable reference to a table by root page.
Sourcepub fn undo_version(&self) -> MemDbVersionToken
pub fn undo_version(&self) -> MemDbVersionToken
Return the current undo-version token.
This is the identity captured in snapshots for savepoints/transactions.
Sourcepub fn begin_undo(&mut self)
pub fn begin_undo(&mut self)
Begin a new undo region (transaction start).
Sourcepub fn commit_undo(&mut self)
pub fn commit_undo(&mut self)
End the undo region (transaction committed/finished).
Sourcepub fn rollback_to(&mut self, token: MemDbVersionToken)
pub fn rollback_to(&mut self, token: MemDbVersionToken)
Restore the database to a previously captured undo-version token.
Sourcepub fn destroy_table(&mut self, root_page: i32)
pub fn destroy_table(&mut self, root_page: i32)
Drop a table by root page and record undo information.
pub fn upsert_row<V>(&mut self, root_page: i32, rowid: i64, values: V)where
V: Into<MemRowValues>,
Sourcepub fn remove_column_from_rows(
&mut self,
root_page: i32,
removed_slot: usize,
) -> bool
pub fn remove_column_from_rows( &mut self, root_page: i32, removed_slot: usize, ) -> bool
Remove a column slot from every row in a TEMP table.
The pre-rewrite table image is recorded as one undo entry, so an enclosing statement savepoint restores row widths, UNIQUE metadata, and the column count together.
Sourcepub fn insert_auto_row<V>(
&mut self,
root_page: i32,
values: V,
rowid_value_column: Option<usize>,
) -> Option<i64>where
V: Into<MemRowValues>,
pub fn insert_auto_row<V>(
&mut self,
root_page: i32,
values: V,
rowid_value_column: Option<usize>,
) -> Option<i64>where
V: Into<MemRowValues>,
Allocate an implicit rowid and insert the row, recording one undo entry
for both the rowid counter advance and the row mutation. If
rowid_value_column is present, that column is patched to the allocated
rowid before insertion.
Sourcepub fn delete_rowid(&mut self, root_page: i32, rowid: i64) -> bool
pub fn delete_rowid(&mut self, root_page: i32, rowid: i64) -> bool
Delete a row by rowid, recording undo information for rollback.
Trait Implementations§
Source§impl Clone for MemDatabase
impl Clone for MemDatabase
Source§fn clone(&self) -> MemDatabase
fn clone(&self) -> MemDatabase
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more