Skip to main content

MemDatabase

Struct MemDatabase 

Source
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

Source

pub fn new() -> Self

Create a new empty in-memory database.

Source

pub fn set_collation_registry( &mut self, registry: Arc<Mutex<CollationRegistry>>, )

Propagate a shared collation registry to all tracked MemTables.

Source

pub fn table_count(&self) -> i32

Returns the number of tables in the database.

Source

pub fn next_root_page(&self) -> i32

Return the next root page that would be assigned by create_table.

Source

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).

Source

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).

Source

pub fn create_table(&mut self, num_columns: usize) -> i32

Create a table and return its root page number.

Source

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.

Source

pub fn get_table(&self, root_page: i32) -> Option<&MemTable>

Get a reference to a table by root page.

Source

pub fn get_table_mut(&mut self, root_page: i32) -> Option<&mut MemTable>

Get a mutable reference to a table by root page.

Source

pub fn undo_version(&self) -> MemDbVersionToken

Return the current undo-version token.

This is the identity captured in snapshots for savepoints/transactions.

Source

pub fn begin_undo(&mut self)

Begin a new undo region (transaction start).

Source

pub fn commit_undo(&mut self)

End the undo region (transaction committed/finished).

Source

pub fn rollback_to(&mut self, token: MemDbVersionToken)

Restore the database to a previously captured undo-version token.

Source

pub fn destroy_table(&mut self, root_page: i32)

Drop a table by root page and record undo information.

Source

pub fn upsert_row<V>(&mut self, root_page: i32, rowid: i64, values: V)
where V: Into<MemRowValues>,

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> MemDatabase

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 MemDatabase

Source§

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

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

impl Default for MemDatabase

Source§

fn default() -> Self

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more