Skip to main content

BTreeTable

Struct BTreeTable 

Source
pub struct BTreeTable {
    pub root_page: i64,
    pub name: String,
    pub primary_key_columns: Vec<(String, SortOrder)>,
    pub has_rowid: bool,
    pub is_strict: bool,
    pub has_autoincrement: bool,
    pub unique_sets: Vec<UniqueSet>,
    pub foreign_keys: Vec<Arc<ForeignKey>>,
    pub check_constraints: Vec<CheckConstraint>,
    pub rowid_alias_conflict_clause: Option<ResolveType>,
    pub has_virtual_columns: bool,
    pub logical_to_physical_map: Vec<usize>,
    /* private fields */
}

Fields§

§root_page: i64§name: String§primary_key_columns: Vec<(String, SortOrder)>§has_rowid: bool§is_strict: bool§has_autoincrement: bool§unique_sets: Vec<UniqueSet>§foreign_keys: Vec<Arc<ForeignKey>>§check_constraints: Vec<CheckConstraint>§rowid_alias_conflict_clause: Option<ResolveType>

ON CONFLICT clause for the INTEGER PRIMARY KEY constraint. Stored here because rowid-alias PKs have their UniqueSet removed.

§has_virtual_columns: bool§logical_to_physical_map: Vec<usize>

Implementations§

Source§

impl BTreeTable

Source

pub fn new( root_page: i64, name: String, primary_key_columns: Vec<(String, SortOrder)>, columns: Vec<Column>, characteristics: BTreeCharacteristics, unique_sets: Vec<UniqueSet>, foreign_keys: Vec<Arc<ForeignKey>>, check_constraints: Vec<CheckConstraint>, rowid_alias_conflict_clause: Option<ResolveType>, ) -> Self

Source

pub fn columns(&self) -> &[Column]

Source

pub fn columns_mut(&mut self) -> ColumnsMut<'_>

Source

pub fn type_check_table_ref( table: &Arc<BTreeTable>, schema: &Schema, ) -> Arc<BTreeTable>

Create a table reference for TypeCheck where custom type columns have their ty_str replaced with the base type name, and where virtual columns are skipped. This ensures TypeCheck validates the encoded value against the correct base type (e.g., BLOB) rather than accepting any STRICT type via the wildcard arm.

Source

pub fn input_type_check_table_ref( table: &Arc<BTreeTable>, schema: &Schema, only_columns: Option<&ColumnMask>, ) -> Result<Arc<BTreeTable>>

Create a table ref for pre-encode TypeCheck that validates user input against the type’s declared value input type (or base if not declared). For UPDATE, only_columns limits which columns are checked — non-SET columns hold encoded values and must be skipped (set to ANY).

Source

pub fn resolve_custom_type_affinities(&mut self, schema: &Schema)

Override column type metadata for custom type columns so that SQLite’s name-based type/affinity rules use the BASE type instead of the custom type name (e.g. “doubled” contains “DOUB” which would incorrectly map to REAL instead of INTEGER).

Source

pub fn propagate_domain_constraints(&mut self, schema: &Schema) -> Result<()>

Propagate domain NOT NULL and CHECK constraints to table columns. For each column whose type resolves to a domain, this:

  • Sets the column’s NOT NULL flag if any domain in the chain has NOT NULL
  • Adds domain CHECK constraints (with value rewritten to the column name) to the table’s check_constraints list
Source

pub fn get_rowid_alias_column(&self) -> Option<(usize, &Column)>

Source

pub fn has_virtual_columns(&self) -> bool

Source

pub fn column_layout(&self) -> Result<ColumnLayout, TryReserveError>

Build a ColumnLayout for this table’s register mapping.

Source

pub fn get_column(&self, name: &str) -> Option<(usize, &Column)>

Returns the column position and column for a given column name. Returns None if the column name is not found. E.g. if table is CREATE TABLE t (a, b, c) then get_column(“b”) returns (1, &Column { .. })

Source

pub fn from_sql(sql: &str, root_page: i64) -> Result<BTreeTable>

Source

pub fn to_sql(&self) -> String

Reconstruct the SQL for the table. FIXME: this makes us incompatible with SQLite since sqlite stores the user-provided SQL as is in sqlite_schema.sql For example, if a user creates a table like: CREATE TABLE t (x), we store it as CREATE TABLE t (x), whereas sqlite stores it with the original extra whitespace.

Source

pub fn column_collations(&self) -> Result<Vec<CollationSeq>>

Source

pub fn logical_to_physical_column(&self, logical: usize) -> usize

Source

pub fn build_logical_to_physical_map( columns: &[Column], primary_key_columns: &[(String, SortOrder)], has_rowid: bool, ) -> Vec<usize>

Source

pub fn try_build_logical_to_physical_map( columns: &[Column], primary_key_columns: &[(String, SortOrder)], has_rowid: bool, ) -> Result<Vec<usize>, TryReserveError>

Source

pub fn prepare_generated_columns(&mut self) -> Result<()>

Source

pub fn shift_generated_column_indices_after_drop( &mut self, dropped_index: usize, ) -> Result<()>

Trait Implementations§

Source§

impl Clone for BTreeTable

Source§

fn clone(&self) -> BTreeTable

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 BTreeTable

Source§

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

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

impl TryClone for BTreeTable

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> ErasedDestructor for T
where T: 'static,

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: 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = !

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