pub struct ColumnSchema {Show 13 fields
pub name: String,
pub ty: DataType,
pub nullable: bool,
pub default: Option<Value>,
pub runtime_default: Option<String>,
pub auto_increment: bool,
pub user_enum_type: Option<String>,
pub user_domain_type: Option<String>,
pub on_update_runtime: Option<String>,
pub collation: Collation,
pub is_unsigned: bool,
pub inline_enum_variants: Option<Vec<String>>,
pub inline_set_variants: Option<Vec<String>>,
}Fields§
§name: String§ty: DataType§nullable: bool§default: Option<Value>Optional DEFAULT value, frozen at CREATE TABLE time. None
means “no default” (so omitted columns become NULL, or error
out when the column is NOT NULL). Literal defaults take this
path.
runtime_default: Option<String>v7.9.21 — for DEFAULT expressions that need INSERT-time
evaluation (e.g. DEFAULT now(), DEFAULT CURRENT_TIMESTAMP),
the Display form of the expression. The engine re-parses
it on each INSERT default-fill, evaluates against an empty
row context, and coerces to the column type. mailrs G4.
Persisted in catalog FILE_VERSION 15+; older catalogs
deserialise with None.
auto_increment: boolMySQL-style AUTO_INCREMENT. When set, an INSERT that leaves
this column unbound (or sets it to NULL) gets the next integer
computed from the column’s current max + 1.
user_enum_type: Option<String>v7.17.0 Phase 1.4 — when the column is bound to a user-
defined ENUM type (the parser saw an unknown type ident
and the engine resolved it against catalog.enum_types),
this carries the enum name so INSERT/UPDATE can validate
the cell value against the enum’s labels. ty is
DataType::Text in that case. Persisted in catalog
FILE_VERSION 29+; older catalogs deserialise with None.
user_domain_type: Option<String>v7.17.0 Phase 1.5 — when the column is bound to a user-
defined DOMAIN (the parser saw an unknown type ident and
the engine resolved it against catalog.domain_types),
this carries the domain name. ty is the domain’s base
type; INSERT/UPDATE re-evaluates the domain’s CHECK list
- NOT NULL against the cell value. Persisted in catalog FILE_VERSION 30+; older catalogs deserialise with None.
on_update_runtime: Option<String>v7.17.0 Phase 2.1 — MySQL ON UPDATE CURRENT_TIMESTAMP
column attribute. When Some(expr_src), an UPDATE that
does NOT bind this column overrides the new value with
the engine-evaluated expression (always now() in
v7.17.0). Stored as Display-form source so storage
stays free of spg-sql; the engine re-parses at UPDATE
time. Persisted in catalog FILE_VERSION 32+; older
catalogs deserialise with None — preserves the existing
“silent ignore” behaviour for snapshots written before
the upgrade.
collation: Collationv7.17.0 Phase 2.5 — text collation. Pre-2.5 SPG accepted
COLLATE <name> clauses but discarded the name, so a
column declared COLLATE "case_insensitive" (or any
MySQL _ci collation) still compared byte-wise — a
Tier-S silent failure where WHERE name = 'foo' never
matched stored 'Foo'. This carries the parser-derived
classification so the engine’s WHERE evaluator can route
text equality through a case-aware compare. Binary (the
default) preserves the prior byte-wise behaviour. Only
CaseInsensitive lands in the catalog appendix — Binary
columns stay implicit, keeping snapshots compact.
Persisted in catalog FILE_VERSION 34+; older catalogs
deserialise every column as Binary.
is_unsigned: boolv7.17.0 Phase 4.4 — MySQL UNSIGNED modifier flag. Drives
engine-side INSERT / UPDATE range enforcement (rejects
negative values on UNSIGNED int columns). Pre-4.4 the
parser consumed and discarded the keyword silently, so
every UNSIGNED column quietly accepted negatives — a
Tier-A correctness drift. Sparse: only UNSIGNED columns
land in the catalog appendix; the default false keeps
snapshots compact for the common signed-int path.
Persisted in catalog FILE_VERSION 35+; older catalogs
deserialise every column as is_unsigned = false.
inline_enum_variants: Option<Vec<String>>v7.17.0 Phase 3.P0-36 — MySQL inline ENUM('a','b','c')
value list. Distinct from user_enum_type (which points
to a separately CREATE TYPE’d PG enum); this carries the
column-local list MySQL DDL declares inline. When Some,
ty is DataType::Text and INSERT/UPDATE validates the
cell value against this list. Variant ORDER is preserved
(MySQL uses it for ORDER BY col). Sparse: only ENUM
columns land in the catalog appendix.
Persisted in catalog FILE_VERSION 41+; older catalogs
deserialise with None — preserves silent-drop behaviour
for snapshots written before P0-36.
inline_set_variants: Option<Vec<String>>v7.17.0 Phase 3.P0-37 — MySQL inline SET('a','b','c')
variant list. Storage is TEXT (canonical comma-joined in
definition order, de-duplicated). INSERT/UPDATE validates
every comma-separated token against this list. Sparse:
only SET columns land in the catalog appendix.
Persisted in catalog FILE_VERSION 42+; older catalogs
deserialise with None.
Implementations§
Source§impl ColumnSchema
impl ColumnSchema
pub fn new( name: impl Into<String>, ty: DataType, nullable: bool, ) -> ColumnSchema
Sourcepub fn with_default(self, default: Value) -> ColumnSchema
pub fn with_default(self, default: Value) -> ColumnSchema
Builder-style helper to attach a default value to an otherwise
plain column schema. Used by the engine when CREATE TABLE
specifies column TYPE DEFAULT <expr>.
Sourcepub fn with_runtime_default(self, expr: impl Into<String>) -> ColumnSchema
pub fn with_runtime_default(self, expr: impl Into<String>) -> ColumnSchema
v7.9.21 — builder for runtime-evaluated defaults
(DEFAULT now(), DEFAULT CURRENT_TIMESTAMP, …).
expr is the Expr’s Display form, re-parsed by the
engine at each INSERT.
Sourcepub const fn with_auto_increment(self) -> ColumnSchema
pub const fn with_auto_increment(self) -> ColumnSchema
Builder-style helper to mark a column as AUTO_INCREMENT.
Trait Implementations§
Source§impl Clone for ColumnSchema
impl Clone for ColumnSchema
Source§fn clone(&self) -> ColumnSchema
fn clone(&self) -> ColumnSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColumnSchema
impl Debug for ColumnSchema
Source§impl PartialEq for ColumnSchema
impl PartialEq for ColumnSchema
Source§fn eq(&self, other: &ColumnSchema) -> bool
fn eq(&self, other: &ColumnSchema) -> bool
self and other values to be equal, and is used by ==.