Skip to main content

IndexAlterSyntax

Struct IndexAlterSyntax 

Source
pub struct IndexAlterSyntax {
Show 21 fields pub rename_constraint: bool, pub alter_table_set_options: bool, pub drop_primary_key: bool, pub alter_column_add_identity: bool, pub index_storage_parameters: bool, pub drop_behavior: bool, pub index_drop_on_table: bool, pub index_concurrently: bool, pub index_using_method: bool, pub partial_index: bool, pub index_if_not_exists: bool, pub index_nulls_order: bool, pub alter_table_extended: bool, pub alter_table_multiple_actions: bool, pub alter_existence_guards: bool, pub alter_nested_column_paths: bool, pub alter_column_set_data_type: bool, pub routine_arg_types: bool, pub routine_arg_defaults: bool, pub routine_arg_modes: bool, pub routine_language_string: bool,
}
Expand description

Dialect-owned CREATE INDEX / ALTER TABLE / DROP syntax accepted by the parser.

The clause-level gates on the index, alter-table, and drop statements — the object-DDL surface that decorates an already-dispatched statement rather than deciding its leading keyword. Split out of the retired SchemaChangeSyntax at its 16-field line as the index/alter/drop axis, distinct from the whole-statement-dispatch axis. Each flag is a grammar gate: when off the keyword is left unconsumed and rejects.

Fields§

§rename_constraint: bool

Accept PostgreSQL ALTER TABLE … RENAME CONSTRAINT <old> TO <new>.

§alter_table_set_options: bool

Accept ALTER TABLE … SET (<name> = <value>, …) table options.

§drop_primary_key: bool

Accept the unnamed ALTER TABLE … DROP PRIMARY KEY action.

§alter_column_add_identity: bool

Accept ALTER TABLE … ALTER COLUMN <name> ADD GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY [(…)].

§index_storage_parameters: bool

Accept CREATE INDEX … (<keys>) WITH (<name> = <value>, …) storage parameters.

§drop_behavior: bool

Accept a trailing CASCADE / RESTRICT drop behaviour on DROP statements and ALTER TABLE ... DROP actions (the SQL standard <drop behavior>; PostgreSQL). A dialect that does not model dependency behaviour leaves it off.

§index_drop_on_table: bool

Accept MySQL’s DROP INDEX <name> ON <table> [ALGORITHM [=] {DEFAULT | INPLACE | INSTANT | COPY}] [LOCK [=] {DEFAULT | NONE | SHARED | EXCLUSIVE}] — the index drop that names its owning table with a mandatory ON and carries the online-DDL ALGORITHM/LOCK execution hints (drop_index_stmt/opt_index_lock_and_algorithm, sql_yacc.yy). Server-measured on mysql:8: the ON <table> is mandatory (DROP INDEX i with no ON is ER_PARSE_ERROR), the tail admits at most one ALGORITHM and one LOCK in either order, and no trailing CASCADE/RESTRICT. On for MySQL only. Off elsewhere, where DROP INDEX <name> [, …] stays the shared name-list drop; enabling it would make the mandatory-ON form displace that name-list drop, so Lenient forgoes it to keep the more permissive bare-name form (a documented conflict resolution). With the flag off a DROP INDEX i ON t leaves ON unconsumed and surfaces as a clean parse error.

§index_concurrently: bool

Accept CREATE INDEX CONCURRENTLY (PostgreSQL builds the index without an exclusive table lock). Not ANSI.

§index_using_method: bool

Accept the CREATE INDEX … USING <method> access-method clause (PostgreSQL btree/hash/gin/gist/…; MySQL USING BTREE). Not ANSI.

§partial_index: bool

Accept a trailing WHERE <predicate> partial-index clause on CREATE INDEX (PostgreSQL, SQLite). Not ANSI.

§index_if_not_exists: bool

Accept the IF NOT EXISTS guard on CREATE INDEX (PostgreSQL/SQLite/DuckDB). On for ANSI/PostgreSQL/SQLite/DuckDB/Lenient. MySQL has no CREATE INDEX IF NOT EXISTS (engine-measured ER_PARSE_ERROR on mysql:8), so it is off; the IF NOT EXISTS is then left unconsumed and the following index name surfaces as a clean parse error. Distinct from the CREATE TABLE/CREATE DATABASE guards, which MySQL does admit.

§index_nulls_order: bool

Accept the per-key NULLS FIRST / NULLS LAST null-ordering modifier on a CREATE INDEX column (PostgreSQL/SQLite 3.30+). On for ANSI/PostgreSQL/SQLite/DuckDB/ Lenient. MySQL has no index-key NULLS ordering (engine-measured ER_PARSE_ERROR on mysql:8; it orders NULLs implicitly), so it is off; the NULLS keyword is then left unconsumed and surfaces as a clean parse error. Independent of the ORDER BY null ordering, which is a separate grammar position.

§alter_table_extended: bool

Accept the extended ALTER TABLE surface beyond SQLite’s lenient action set: the table-level IF EXISTS, comma-separated multiple actions, ALTER COLUMN …, the ADD PRIMARY KEY/UNIQUE/FOREIGN KEY table constraints, and the IF [NOT] EXISTS guard on ADD/DROP COLUMN (PostgreSQL/MySQL). On for ANSI/PostgreSQL/ MySQL/DuckDB/Lenient. Off for SQLite, whose ALTER TABLE (engine-measured via rusqlite) admits RENAME TO/RENAME COLUMN, a single ADD [COLUMN] <def> / ADD [CONSTRAINT …] CHECK (…), and a single DROP [COLUMN] / DROP CONSTRAINT — those stay accepted with the flag off; every other form is left unconsumed and surfaces as a clean parse error. Distinct from ExistenceGuards::if_exists, which stays on for SQLite (its DROP TABLE IF EXISTS is valid) — only the ALTER existence guard is gated here.

§alter_table_multiple_actions: bool

Accept a comma-separated multi-action ALTER TABLE list (ALTER TABLE t ADD COLUMN a INT, DROP COLUMN b). On for ANSI/PostgreSQL/MySQL/Lenient. Off for DuckDB (parse-rejects with “Only one ALTER command per statement is supported”, probed on 1.5.4) and moot for SQLite (its alter_table_extended is already off, so the multi-action loop is never entered). Only reachable where alter_table_extended is on; with the flag off the first action parses and a trailing comma surfaces as a clean parse error.

§alter_existence_guards: bool

Accept an IF EXISTS / IF NOT EXISTS existence guard inside ALTER TABLE — the table-level ALTER TABLE IF EXISTS t … and the per-action ADD COLUMN IF NOT EXISTS / DROP [COLUMN|CONSTRAINT] IF EXISTS guards. On for PostgreSQL/DuckDB/Lenient (and unused by SQLite, whose non-alter_table_extended path parses no guard, so it rides that gate — FeatureDependencyViolation::AlterExistenceGuardsWithoutAlterTableExtended). MySQL supports the extended ALTER TABLE surface (multi-action lists, ADD/DROP CONSTRAINT, ALTER COLUMN) but not these guards (ALTER TABLE IF EXISTS, ADD COLUMN IF NOT EXISTS, DROP COLUMN IF EXISTS are each ER_PARSE_ERROR on mysql:8), so it is off there; the IF keyword is then read as a name and surfaces as a clean parse error. Distinct from ExistenceGuards::if_exists, which MySQL keeps on for DROP TABLE IF EXISTS.

§alter_nested_column_paths: bool

Accept dotted nested-column paths in DuckDB ALTER TABLE column targets for the actions the engine parses (ADD COLUMN s.k, DROP COLUMN s.k, and old-side RENAME COLUMN s.k TO k2). The gate does not affect ALTER COLUMN or the rename destination: DuckDB 1.5.4 parse-rejects dotted paths in those positions.

§alter_column_set_data_type: bool

Accept the PostgreSQL ALTER TABLE … ALTER COLUMN actions beyond SET/DROP DEFAULTSET DATA TYPE <type> (and its bare TYPE <type> synonym, with an optional USING <expr>) plus SET/DROP NOT NULL. On for PostgreSQL/DuckDB/Lenient. MySQL’s ALTER COLUMN admits only SET/DROP DEFAULT — it changes a column’s type with MODIFY/CHANGE — so ALTER COLUMN i SET DATA TYPE …/SET NOT NULL/DROP NOT NULL are ER_PARSE_ERROR on mysql:8; with the flag off those actions surface as a clean parse error. SQLite never reaches the action (its alter_table_extended is off), so this is moot there — it rides that gate (FeatureDependencyViolation::AlterColumnSetDataTypeWithoutAlterTableExtended).

§routine_arg_types: bool

Accept a routine reference’s parenthesized argument-type list — DROP FUNCTION f(INT), GRANT EXECUTE ON FUNCTION f(INT) … (PostgreSQL overload-disambiguation). On for ANSI/PostgreSQL/DuckDB/Lenient. MySQL identifies a routine by name alone, so the arg list is a syntax error there (DROP FUNCTION f(INT) → engine-measured ER_PARSE_ERROR on mysql:8); with the flag off the ( is left unconsumed and surfaces as a clean parse error. Off for SQLite too (it has no stored routines — routines is already off, so this is moot there).

§routine_arg_defaults: bool

Accept a CREATE FUNCTION parameter default — func_arg DEFAULT <expr> / func_arg = <expr> (PostgreSQL func_arg_with_default). On for ANSI/PostgreSQL/DuckDB/Lenient. MySQL’s routine parameters are [IN|OUT|INOUT] name type with no default, so a DEFAULT/= after the type is a syntax error there (ER_PARSE_ERROR on mysql:8); with the flag off the DEFAULT/= is left unconsumed and the parameter-list close surfaces as a clean parse error. Distinct from routine_arg_types (which gates the reference-site arg-type list on DROP/GRANT): this gates the definition-site default on CREATE FUNCTION. Off for SQLite too (no stored routines — routines is already off, so this is moot there).

§routine_arg_modes: bool

Accept a CREATE FUNCTION parameter argument mode — the arg_class prefix IN/OUT/INOUT/VARIADIC before the parameter (PostgreSQL func_arg). On for ANSI/PostgreSQL/DuckDB/Lenient. MySQL’s CREATE FUNCTION parameters are name type with no mode (the IN/OUT/INOUT modes are a stored-procedure form, a distinct statement), so a mode keyword before a CREATE FUNCTION parameter is a syntax error there; with the flag off the keyword is left for the name/type parse (a reserved mode keyword like IN/VARIADIC then surfaces as a clean parse error). A sibling of routine_arg_defaults: both gate independent definition-site CREATE FUNCTION parameter facets that MySQL’s grammar omits. Off for SQLite too (no stored routines — routines is already off, so this is moot there).

§routine_language_string: bool

Accept a string-constant (Sconst) spelling of the routine LANGUAGE name — LANGUAGE 'sql'/E'sql'/$$sql$$ — alongside the bare word, PostgreSQL’s NonReservedWord_or_Sconst operand (the same shape the DO … LANGUAGE argument spells). On for PostgreSQL/Lenient. MySQL’s routine LANGUAGE admits only the bare word SQLLANGUAGE 'SQL' is engine-measured ER_PARSE_ERROR (1064) on mysql:8 for both CREATE FUNCTION and CREATE PROCEDURE — so off there; with the flag off a string in the LANGUAGE position falls through to the bare-word parse, which rejects the string as MySQL does. Off for ANSI too: the SQL-standard <language name> is a bare identifier (SQL/C/ADA/…), not a string. A bit-string (b'…'/x'…') or national (N'…') constant is never an Sconst, so it stays a reject even where the flag is on (matching PostgreSQL). Off for SQLite too (no stored routines — routines is already off, so this is moot there).

Implementations§

Source§

impl IndexAlterSyntax

Source

pub const ANSI: Self

The ANSI predefined value.

Source§

impl IndexAlterSyntax

Source

pub const LENIENT: Self

Available on crate feature lenient only.

The LENIENT preset for index alter syntax.

Source§

impl IndexAlterSyntax

Source

pub const MYSQL: Self

Available on crate feature mysql only.

The MYSQL preset for index alter syntax.

Source§

impl IndexAlterSyntax

Source

pub const POSTGRES: Self

Available on crate feature postgres only.

The POSTGRES preset for index alter syntax.

Source§

impl IndexAlterSyntax

Source

pub const QUILTDB: Self

Available on crate feature quiltdb only.

Index and extended ALTER syntax enabled by this preset.

Source§

impl IndexAlterSyntax

Source

pub const SQLITE: Self

Available on crate feature sqlite only.

The SQLITE preset for index alter syntax.

Trait Implementations§

Source§

impl Clone for IndexAlterSyntax

Source§

fn clone(&self) -> IndexAlterSyntax

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 Copy for IndexAlterSyntax

Source§

impl Debug for IndexAlterSyntax

Source§

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

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

impl Eq for IndexAlterSyntax

Source§

impl PartialEq for IndexAlterSyntax

Source§

fn eq(&self, other: &IndexAlterSyntax) -> 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 IndexAlterSyntax

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, 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.