pub struct ExistenceGuards {
pub if_exists: bool,
pub view_if_not_exists: bool,
pub create_database_if_not_exists: bool,
}Expand description
Dialect-owned IF [NOT] EXISTS existence guards on DDL statements.
The SQL existence guards — IF EXISTS on DROP/ALTER, IF NOT EXISTS on
CREATE — are dialect data: each flag decides whether the parser admits
the guard at one statement site, and when off the IF [NOT] EXISTS is left
unconsumed and surfaces as a clean parse error (the same reject mechanism the other
grammar gates use). They live in their own sub-struct rather than scattered through
the retired SchemaChangeSyntax because their bundle membership differs per dialect: leaving a
coarse if_exists bundle in SchemaChangeSyntax made every new dialect bolt on a
separate exception flag (view_if_not_exists, create_database_if_not_exists), so a
dedicated per-site table is the shape that does not accrete one exception per dialect.
Two-level spelling convention (uniform across the dialect-data knobs): a top-level
FeatureSet assembly spells every field explicitly, while a sub-preset const of a
knob like this one may struct-update-derive from a sibling with ..Self::OTHER (the
SelectSyntax::DUCKDB precedent) — the base preset stays the exhaustive source of
truth and the derived one records only its deltas.
Fields§
§if_exists: boolAccept IF EXISTS on DROP/ALTER TABLE (and on their column/constraint
sub-actions) and IF NOT EXISTS on ADD COLUMN (PostgreSQL, MySQL, SQLite;
not ANSI, whose DROP/ALTER has no existence guard). One flag gates the
drop/alter/add-column existence guards together because a dialect that spells one
spells them all; the ALTER TABLE/ADD COLUMN sites additionally require
IndexAlterSyntax::alter_table_extended (SQLite keeps this guard on for its
DROP … IF EXISTS while its plain-ALTER surface stays off).
view_if_not_exists: boolAccept IF NOT EXISTS on a plain (non-materialized) CREATE VIEW (SQLite).
PostgreSQL admits IF NOT EXISTS only on a CREATE MATERIALIZED VIEW (that
form is always accepted, independent of this flag), and MySQL has no view
existence guard at all, so off there; SQLite spells CREATE VIEW IF NOT EXISTS
over a regular view. When off, the IF NOT EXISTS is left unconsumed on a plain
view and surfaces as a clean parse error.
create_database_if_not_exists: boolAccept the CREATE DATABASE IF NOT EXISTS <name> existence guard (MySQL; also
SQLite has no CREATE DATABASE at all, so off there). PostgreSQL’s CREATE DATABASE has no IF NOT EXISTS, so this is a dedicated site rather than a reuse
of if_exists — that one is on in PostgreSQL, which must still
reject CREATE DATABASE IF NOT EXISTS. When off, the IF NOT EXISTS is left
unconsumed and surfaces as a clean parse error.
Implementations§
Trait Implementations§
Source§impl Clone for ExistenceGuards
impl Clone for ExistenceGuards
Source§fn clone(&self) -> ExistenceGuards
fn clone(&self) -> ExistenceGuards
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more