Skip to main content

ColumnDef

Struct ColumnDef 

Source
pub struct ColumnDef {
Show 23 fields pub name: String, pub ty: ColumnTypeName, pub nullable: bool, pub default: Option<Expr>, pub auto_increment: bool, pub is_primary_key: bool, pub is_unique: bool, pub unique_nulls_not_distinct: bool, pub constraint_deferrable: bool, pub constraint_initially_deferred: bool, pub check: Option<Expr>, pub user_type_ref: Option<String>, pub on_update_runtime: Option<Expr>, pub collation: Collation, pub collation_explicit: bool, pub collation_name: Option<String>, pub is_unsigned: bool, pub inline_enum_variants: Option<Vec<String>>, pub inline_set_variants: Option<Vec<String>>, pub generated_stored_expr: Option<Box<Expr>>, pub identity_always: bool, pub mysql_int_width: Option<MysqlIntWidth>, pub mysql_fsp: Option<u8>,
}

Fields§

§name: String§ty: ColumnTypeName§nullable: bool§default: Option<Expr>

DEFAULT <expr> literal supplied at CREATE TABLE. Engine evaluates this once (with an empty row) and caches the resulting Value on the column schema.

§auto_increment: bool

MySQL-style AUTO_INCREMENT — the engine maintains a counter per such column and fills the slot when INSERT leaves it unbound (omitted from a column-list INSERT or explicitly NULL).

§is_primary_key: bool

v7.9.13 — inline PRIMARY KEY column constraint. mailrs migration follow-up F1. Implies NOT NULL. Engine creates an implicit BTree index named <table>_pkey over this column at CREATE TABLE time, satisfying the parent-side index requirement for any FOREIGN KEY pointing at it.

§is_unique: bool

v7.13.0 — inline UNIQUE column constraint (mailrs round-5 G2). The CREATE TABLE handler folds this into a single-column TableConstraint::Unique so the engine path stays uniform with table-level UNIQUE.

§unique_nulls_not_distinct: bool

v7.38 (read01 P4.19) — UNIQUE NULLS NOT DISTINCT (PG 15+) on the inline column constraint: treat NULL keys as equal so only one NULL is allowed. Ignored unless is_unique. Folded into the table-level TableConstraint::Unique { nulls_not_distinct }.

§constraint_deferrable: bool

v7.39 (round 711) — DEFERRABLE [INITIALLY DEFERRED] written on the inline PK/UNIQUE column constraint. Consumed since round 621; carried since this round so the fold into the table-level constraint keeps it.

§constraint_initially_deferred: bool§check: Option<Expr>

v7.13.0 — inline CHECK (<expr>) column constraint (mailrs round-5 G3). Stored alongside the column so the CREATE TABLE handler can fold these into table-level CHECK constraints. Multiple inline CHECKs on the same column are concatenated with AND at the table level.

§user_type_ref: Option<String>

v7.17.0 Phase 1.4 — user-defined type reference. When the parser sees an unknown column-type ident (anything not in the built-in parse_column_type_name table), it sets ty = ColumnTypeName::Text and records the original name here. The engine resolves at CREATE TABLE time: if a catalog enum/domain with this name exists, the column is bound to it (label-checked on INSERT for enums; CHECK- constrained for domains); otherwise the CREATE TABLE errors with “unknown type”.

§on_update_runtime: Option<Expr>

v7.17.0 Phase 2.1 — MySQL-style ON UPDATE CURRENT_TIMESTAMP column attribute. When set, an UPDATE that does NOT explicitly bind this column overrides the new value with now() (engine clock). Pre-v7.17 SPG silently accepted the syntax and never fired the override — updated_at columns from mysqldump stayed pinned at their initial DEFAULT forever, an audit Tier-S silent-failure. Generalised as a stored expression source so future shapes (ON UPDATE CURRENT_TIMESTAMP(6), ON UPDATE LOCALTIMESTAMP) reuse the same field; v7.17 only accepts CURRENT_TIMESTAMP.

§collation: Collation

v7.17.0 Phase 2.5 — text collation derived from the post-fix COLLATE <name> clause (and / or the table-level COLLATE=<name> for MySQL dumps that don’t repeat it per column). Pre-2.5 SPG accepted the clause and discarded the name, leaving every column byte-compared — a Tier-S silent failure when the customer expected _ci / case_insensitive semantics. Parser normalises the raw collation name into the variants in Collation. Default Binary preserves the legacy compare path.

§collation_explicit: bool

v7.39 (round 370, M4 P4a) — whether collation came from an explicit COLLATE <name> clause rather than the default. Under the MySQL dialect a text column with NO explicit clause takes the folding default collation, while an explicit COLLATE utf8mb4_bin stays byte-wise — and both resolve to Collation::Binary, so this flag is the only thing that tells them apart.

§collation_name: Option<String>

v7.39 (round 676) — the collation name AS WRITTEN, because collation above cannot carry it: Collation is a two-variant MySQL enum and from_collation_name folds C, POSIX, en_US and default all into Binary. pg_attribute.attcollation needs to tell them apart.

§is_unsigned: bool

v7.17.0 Phase 4.4 — MySQL UNSIGNED modifier flag. Pre- 4.4 SPG accepted and discarded the keyword, leaving negative values silently accepted on a column the customer declared INT UNSIGNED NOT NULL. Now: the engine rejects negative INSERT / UPDATE values on UNSIGNED int columns. SPG widening to u64-shaped storage is out of v7.17 scope; the upper bound remains the signed-type max (i64::MAX for BIGINT UNSIGNED), which still strictly exceeds what every mailrs / Rails app actually uses.

§inline_enum_variants: Option<Vec<String>>

v7.17.0 Phase 3.P0-36 — MySQL inline ENUM('a','b','c') value list captured at parse time. When Some, the parser recognised ENUM(...) in the type slot; the engine validates INSERT cells against this list at column_def_to_schema time and persists the variants on ColumnSchema.inline_enum_variants. None for all non-ENUM columns.

§inline_set_variants: Option<Vec<String>>

v7.17.0 Phase 3.P0-37 — MySQL inline SET('a','b','c') value list. Distinct from ENUM (subset semantics rather than pick-one). None for all non-SET columns.

§generated_stored_expr: Option<Box<Expr>>

v7.37.7(sentori Epic 3 P1)— GENERATED ALWAYS AS (<expr>) STORED computed-column source. When Some, the engine stores the Display-form of the parsed expression on ColumnSchema.generated_stored_expr at CREATE TABLE time and re-evaluates the expression against every INSERT / UPDATE candidate row, overwriting whatever the caller supplied for this column. Boxed to keep ColumnDef from blowing past the large_enum_variant clippy ceiling (Expr widens with vector literals).

§identity_always: bool

v7.38 (read01) — GENERATED ALWAYS AS IDENTITY (as opposed to GENERATED BY DEFAULT AS IDENTITY). Both flavours set auto_increment; this additionally marks the ALWAYS one, whose explicit INSERT value PG rejects (“cannot insert a non-DEFAULT value into column …”) unless the INSERT carries OVERRIDING SYSTEM VALUE. Only meaningful when the column is also an identity column.

§mysql_int_width: Option<MysqlIntWidth>

v7.39 (round 386, type-fidelity epic P1) — the declared MySQL narrow integer width (TINYINT / MEDIUMINT), captured before the type collapses to SmallInt / Int. The engine copies it to ColumnSchema.mysql_int_width at CREATE TABLE time so the write path can enforce the real range. None for every other column and under the PG dialect.

§mysql_fsp: Option<u8>

v7.39 (round 424, type-fidelity epic) — the declared MySQL fractional-seconds precision of a temporal column (DATETIME(3) is Some(3); a bare DATETIME / TIME / TIMESTAMP is Some(0), MySQL’s default). The engine copies it to ColumnSchema.mysql_fsp at CREATE TABLE time so the write path can truncate and the render path can pad. None under the PG dialect, where temporal columns keep full microseconds.

Trait Implementations§

Source§

impl Clone for ColumnDef

Source§

fn clone(&self) -> ColumnDef

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 ColumnDef

Source§

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

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

impl Display for ColumnDef

Source§

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

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

impl PartialEq for ColumnDef

Source§

fn eq(&self, other: &ColumnDef) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ColumnDef

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.