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
impl TableSchema
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
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
pub fn has_virtual_columns(&self) -> bool
Sourcepub fn rebuild(self) -> Self
pub fn rebuild(self) -> Self
Rebuild caches (preserving dropped slots). Use after mutating fields in place.
Sourcepub fn has_checks(&self) -> bool
pub fn has_checks(&self) -> bool
Returns true if any column-level or table-level CHECK constraints exist.
Sourcepub fn decode_col_mapping(&self) -> &[usize]
pub fn decode_col_mapping(&self) -> &[usize]
Physical position -> logical column index. usize::MAX for dropped slots.
Sourcepub fn encoding_positions(&self) -> &[u16]
pub fn encoding_positions(&self) -> &[u16]
Logical non-PK order -> physical encoding position.
Sourcepub fn physical_non_pk_count(&self) -> usize
pub fn physical_non_pk_count(&self) -> usize
Total physical non-PK column count (live + dropped slots).
Sourcepub fn dropped_non_pk_slots(&self) -> &[u16]
pub fn dropped_non_pk_slots(&self) -> &[u16]
Physical encoding slots that have been dropped via DROP COLUMN.
Sourcepub fn without_column(&self, drop_pos: usize) -> Self
pub fn without_column(&self, drop_pos: usize) -> Self
Return a new schema with the column at drop_pos marked as dropped.
Source§impl TableSchema
impl TableSchema
pub fn serialize(&self) -> Vec<u8> ⓘ
pub fn deserialize(data: &[u8]) -> Result<Self>
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Get column index by name (case-insensitive).
Sourcepub fn non_pk_indices(&self) -> &[usize]
pub fn non_pk_indices(&self) -> &[usize]
Get indices of non-PK columns (columns stored in the B+ tree value).
Sourcepub fn pk_indices(&self) -> &[usize]
pub fn pk_indices(&self) -> &[usize]
Get the PK column indices as usize.
Sourcepub fn index_by_name(&self, name: &str) -> Option<&IndexDef>
pub fn index_by_name(&self, name: &str) -> Option<&IndexDef>
Get index definition by name (case-insensitive).
Trait Implementations§
Source§impl Clone for TableSchema
impl Clone for TableSchema
Source§fn clone(&self) -> TableSchema
fn clone(&self) -> TableSchema
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TableSchema
impl RefUnwindSafe for TableSchema
impl Send for TableSchema
impl Sync for TableSchema
impl Unpin for TableSchema
impl UnsafeUnpin for TableSchema
impl UnwindSafe for TableSchema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more