Skip to main content

TableSchema

Struct TableSchema 

Source
pub struct TableSchema {
    pub name: String,
    pub columns: Vec<ColumnDef>,
    pub primary_key_columns: Vec<u16>,
    pub indices: Vec<IndexDef>,
    pub check_constraints: Vec<TableCheckDef>,
    pub foreign_keys: Vec<ForeignKeySchemaEntry>,
    /* private fields */
}
Expand description

Table schema stored in the _schema table.

Fields§

§name: String§columns: Vec<ColumnDef>§primary_key_columns: Vec<u16>§indices: Vec<IndexDef>§check_constraints: Vec<TableCheckDef>§foreign_keys: Vec<ForeignKeySchemaEntry>

Implementations§

Source§

impl TableSchema

Source

pub fn new( name: String, columns: Vec<ColumnDef>, primary_key_columns: Vec<u16>, indices: Vec<IndexDef>, check_constraints: Vec<TableCheckDef>, foreign_keys: Vec<ForeignKeySchemaEntry>, ) -> Self

Source

pub fn with_drops( name: String, columns: Vec<ColumnDef>, primary_key_columns: Vec<u16>, indices: Vec<IndexDef>, check_constraints: Vec<TableCheckDef>, foreign_keys: Vec<ForeignKeySchemaEntry>, dropped_non_pk_slots: Vec<u16>, ) -> Self

Source

pub fn rebuild(self) -> Self

Rebuild caches (preserving dropped slots). Use after mutating fields in place.

Source

pub fn has_checks(&self) -> bool

Returns true if any column-level or table-level CHECK constraints exist.

Source

pub fn decode_col_mapping(&self) -> &[usize]

Physical encoding position -> logical column index mapping. Length = physical_non_pk_count. usize::MAX for dropped slots.

Source

pub fn encoding_positions(&self) -> &[u16]

Logical non-PK order -> physical encoding position. encoding_positions()[i] is the physical slot for non_pk_indices()[i].

Source

pub fn physical_non_pk_count(&self) -> usize

Total physical non-PK column count (live + dropped slots).

Source

pub fn dropped_non_pk_slots(&self) -> &[u16]

Physical encoding slots that have been dropped via DROP COLUMN.

Source

pub fn without_column(&self, drop_pos: usize) -> Self

Return a new schema with the column at drop_pos marked as dropped. Row data is not rewritten; decode skips the slot. Logical positions above drop_pos shift down; table-level CHECKs referencing it are filtered out.

Source§

impl TableSchema

Source

pub fn serialize(&self) -> Vec<u8>

Source

pub fn deserialize(data: &[u8]) -> Result<Self>

Source

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

Get column index by name (case-insensitive).

Source

pub fn non_pk_indices(&self) -> &[usize]

Get indices of non-PK columns (columns stored in the B+ tree value).

Source

pub fn pk_indices(&self) -> &[usize]

Get the PK column indices as usize.

Source

pub fn index_by_name(&self, name: &str) -> Option<&IndexDef>

Get index definition by name (case-insensitive).

Source

pub fn index_table_name(table_name: &str, index_name: &str) -> Vec<u8>

Get the KV table name for an index.

Trait Implementations§

Source§

impl Clone for TableSchema

Source§

fn clone(&self) -> TableSchema

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TableSchema

Source§

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

Formats the value using the given formatter. 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<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> 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