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
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 encoding position -> logical column index mapping.
Length = physical_non_pk_count. usize::MAX for dropped slots.
Sourcepub fn encoding_positions(&self) -> &[u16]
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].
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.
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
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more