pub struct ColumnDefinitionSyntax {Show 13 fields
pub generated_column_shorthand: bool,
pub column_conflict_resolution_clause: bool,
pub typeless_column_definitions: bool,
pub typeless_generated_columns: bool,
pub joined_autoincrement_attribute: bool,
pub inline_primary_key_ordering: bool,
pub named_column_collate_constraint: bool,
pub identity_columns: bool,
pub compact_identity_columns: bool,
pub default_expression_requires_parens: bool,
pub column_default_requires_b_expr: bool,
pub column_collation: bool,
pub column_storage: bool,
}Expand description
Dialect-owned CREATE TABLE column-definition syntax accepted by the parser.
The column-level decorations inside a CREATE TABLE definition — the attributes and
restrictions that attach to a single column. Split out of the retired
SchemaChangeSyntax at its 16-field line as the column-definition axis, distinct from
the table-clause and constraint axes. Each flag is a grammar gate: when off the
decoration is left unconsumed and rejects.
Fields§
§generated_column_shorthand: boolAccept the keywordless generated-column shorthand <col> <type> AS (<expr>) [STORED|VIRTUAL], written without the leading GENERATED ALWAYS (MySQL,
SQLite). It folds onto the one GeneratedColumn
shape tagged
GeneratedColumnSpelling::Shorthand,
never a new node. PostgreSQL requires the GENERATED ALWAYS
keywords, so this is off there and the bare AS (…) after a column type is left
unconsumed and surfaces as a clean parse error.
column_conflict_resolution_clause: boolAccept the SQLite column-level ON CONFLICT <resolution> clause on an inline
NOT NULL / UNIQUE / PRIMARY KEY / CHECK constraint
(a INTEGER UNIQUE ON CONFLICT REPLACE), recording the resolution algorithm in
ColumnConstraint::conflict. SQLite-only; off in
every other preset, where the trailing ON after the constraint is left unconsumed
and surfaces as a clean parse error. Split out of
the retired sqlite_table_decorations bundle because column-level
conflict resolution is an independent grammar point from the trailing table options,
the typeless column, AUTOINCREMENT, and the inline-PRIMARY KEY ordering.
typeless_column_definitions: boolAccept a SQLite typeless column definition — a column named with no data type
(CREATE TABLE t (a, b)), leaving ColumnDef::data_type
unset. SQLite-only; off in every other preset, where a column with no type falls
through to parse_data_type and surfaces as a clean parse error. Split out of
the retired sqlite_table_decorations bundle because the typeless
column is an independent grammar point from the trailing table options,
AUTOINCREMENT, the column COLLATE, and the inline-PRIMARY KEY ordering.
typeless_generated_columns: boolAccept a column that omits its data type only when the column is a generated column —
DuckDB’s narrowing of the SQLite typeless rule. DuckDB requires a data type on every
column except a generated one: both the GENERATED { ALWAYS | BY DEFAULT } AS … form
and the keywordless AS (<expr>) shorthand may drop the type
(CREATE TABLE t (x INT, gen_x AS (x + 5)), engine-measured on libduckdb 1.5.4), while
a plain typeless column (x) or a typeless non-generated constraint (y DEFAULT 5) is
a parse error. On for DuckDB/Lenient. Off for ANSI/PostgreSQL/MySQL — a generated column
with no type falls through to parse_data_type and surfaces as a clean parse error — and
off for SQLite, which instead accepts any typeless column via the strictly wider
typeless_column_definitions, so
this narrow gate stays off there.
joined_autoincrement_attribute: boolAccept the SQLite joined AUTOINCREMENT column attribute — the bare one-word keyword
on an inline PRIMARY KEY column (a INTEGER PRIMARY KEY AUTOINCREMENT), recorded as
AutoIncrementSpelling::Joined so it
round-trips as one word. SQLite-only; off in every other preset, where the trailing
AUTOINCREMENT is left unconsumed and surfaces as a clean parse error. This gates
only the joined spelling: the underscored MySQL AUTO_INCREMENT attribute is a
separate surface gated by table_options, so the two spellings
toggle independently and neither preset admits the other’s word. Split out of
the retired sqlite_table_decorations bundle because the auto-increment
attribute is an independent grammar point from the typeless column, the column
COLLATE, and the inline-PRIMARY KEY ordering.
inline_primary_key_ordering: boolAccept an ASC/DESC sort-order qualifier on an inline PRIMARY KEY column
constraint (CREATE TABLE t (a INTEGER PRIMARY KEY DESC)), recorded in the
ColumnOption::PrimaryKey ascending field (ASC →
Some(true), DESC → Some(false), absent → None). SQLite-only; off in every other
preset, where the trailing ASC/DESC is left unconsumed and surfaces as a clean parse
error. Split out of the retired sqlite_table_decorations bundle because
the inline primary-key ordering is an independent grammar point from the trailing table
options, the typeless column, AUTOINCREMENT, and the column COLLATE.
named_column_collate_constraint: boolAccept a CONSTRAINT <name> prefix on a column COLLATE clause
(CREATE TABLE t (a TEXT CONSTRAINT c COLLATE nocase)): SQLite’s grammar makes COLLATE
an ordinary nameable column constraint, so a CONSTRAINT <name> symbol binds to it.
SQLite-only; off in every other preset (PostgreSQL and DuckDB engine-measured reject the
named form, where COLLATE any_name is a constraint alternative parallel to — not under —
the nameable constraint element), leaving the CONSTRAINT <name> prefix on a COLLATE
clause as a clean parse error. This gates only the named wrapper: the bare column
COLLATE surface (ColumnOption::Collate) is a separate
cross-dialect shape gated by column_collation, so the accepting
case needs both flags on. Split out of
the retired sqlite_table_decorations bundle because the named-COLLATE
wrapper is an independent grammar point from the inline-PRIMARY KEY ordering.
identity_columns: boolAccept the <col> <type> GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [(…)]
identity column (SQL:2003; PostgreSQL). On for ANSI/PostgreSQL/MySQL/DuckDB/
Lenient. SQLite has no IDENTITY (its auto-key is INTEGER PRIMARY KEY [AUTOINCREMENT]), so it is off; the IDENTITY keyword is then left unconsumed and
surfaces as a clean parse error. Gates only the AS IDENTITY reading — the
GENERATED ALWAYS AS (<expr>) computed column (which SQLite has) is unaffected.
compact_identity_columns: boolAccept the compact identity-column forms <col> <type> IDENTITY and
<col> <type> IDENTITY(<seed>, <increment>). The two numeric arguments map to the
same start/increment identity options as the standard generated form.
default_expression_requires_parens: boolRequire a parenthesized DEFAULT (expr) for a functional / general-expression
column default. On for MySQL: a column DEFAULT there admits only a literal, a
signed literal, the CURRENT_TIMESTAMP/NOW()/LOCALTIME/LOCALTIMESTAMP temporal
family, or a parenthesized expression — a bare function call or operator expression
(DEFAULT UUID(), DEFAULT 1 + 2) is an ER_PARSE_ERROR on mysql:8, while
DEFAULT (UUID()) parses. Off for ANSI/PostgreSQL/SQLite/DuckDB/Lenient, which accept
a bare expression default. When off, the default expression is read whole with no
wrapping requirement.
column_default_requires_b_expr: boolRestrict a column-constraint DEFAULT to PostgreSQL’s b_expr grammar class
(ColConstraintElem: DEFAULT b_expr), rather than the full a_expr used everywhere
else. b_expr is the “boolean-and-predicate-free” expression production: it keeps
arithmetic, comparison, ||, OPERATOR(...), ::, subscripts, COLLATE, and the
IS [NOT] DISTINCT FROM / IS [NOT] DOCUMENT tests, but excludes the a_expr-only
forms — AND/OR/NOT, IN, BETWEEN, LIKE/ILIKE/SIMILAR TO, IS [NOT] NULL/TRUE/FALSE/UNKNOWN, a quantified = ANY(...), and AT TIME ZONE. So
... DEFAULT 1 IN (1, 2) is a syntax error on PostgreSQL (the IN predicate is
a_expr-level), while the parenthesized DEFAULT (1 IN (1, 2)) — a c_expr reset to
a_expr — parses. On for PostgreSQL only; every other dialect (including DuckDB, which
otherwise inherits the PostgreSQL schema surface) reads the default as a full a_expr.
Note the asymmetry: ALTER COLUMN ... SET DEFAULT is a_expr even on PostgreSQL, so
this gates only the inline column-constraint site.
column_collation: boolAccept the column-definition COLLATE <collation> clause (a text COLLATE "C"). On for
PostgreSQL/SQLite/DuckDB/Lenient — all three spell a per-column collation inside the
column definition (PostgreSQL takes a qualified any_name, SQLite/DuckDB a single bare
identifier; the parser narrows the name grammar per dialect). Off for ANSI/MySQL, where a
column-level COLLATE is left unconsumed and surfaces as a clean parse error. Distinct
from the expression-level COLLATE gated by
ExpressionSyntax::collate on a different sub-struct — this one
qualifies a column, not an expression. (MySQL does spell a column COLLATE in its own
CHARACTER SET … COLLATE … attribute grammar, a distinct surface left to a follow-up.)
column_storage: boolAccept the per-column STORAGE {PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT} and
COMPRESSION <method> physical-storage clauses (PostgreSQL). The two travel together as a
single dialect unit — both are fixed-position clauses between a column’s type and its
constraint list. On for PostgreSQL/Lenient. Off for ANSI/MySQL/SQLite/DuckDB (DuckDB,
which otherwise inherits the PostgreSQL schema surface, rejects both), where the
STORAGE/COMPRESSION keyword is left unconsumed and surfaces as a clean parse error.
Implementations§
Trait Implementations§
Source§impl Clone for ColumnDefinitionSyntax
impl Clone for ColumnDefinitionSyntax
Source§fn clone(&self) -> ColumnDefinitionSyntax
fn clone(&self) -> ColumnDefinitionSyntax
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more