pub struct SessionVariableSyntax {
pub user_variables: bool,
pub system_variables: bool,
pub variable_assignment: bool,
}Expand description
Dialect-owned MySQL session-variable syntax.
MySQL exposes user-defined @name variables and server @@[scope.]name system
variables as value expressions — distinct from a prepared-statement placeholder
(ParameterSyntax), which is a hole bound at execute time. Each flag is a
lexical gate: it decides whether the scanner recognises that sigil as a variable
token (Expr::SessionVariable) rather than a
stray byte. The two forms are independent — a dialect can accept @@sysvar without
@uservar — and are lookahead-disjoint (@@ needs a second @, @name an
identifier-start), so they never contend with each other.
Fields§
§user_variables: boolAccept @name user-defined session variables (MySQL). The sigil must abut an
identifier-start byte. Mutually exclusive with
ParameterSyntax::named_at: both claim @name, so enabling both is a
LexicalConflict::AtNameParameterVersusUserVariable.
system_variables: boolAccept @@name / @@global.name / @@session.name system variables (MySQL).
The @@ must abut an identifier-start byte; a scoped form folds the optional
global./session. prefix into the same token. Never contends with named_at
or user_variables — the second @ keeps @@ lookahead-disjoint from the
single-@ forms.
variable_assignment: boolAccept the MySQL SET variable-assignment statement grammar and its :=
assignment operator (MySQL).
Two facets of one behaviour that ship together in MySQL and nowhere else:
- Parser — a
SETbecomes a comma-separated list of heterogeneous assignments (SessionStatement::SetVariables):[GLOBAL|SESSION|LOCAL|PERSIST|PERSIST_ONLY] <var> {= | :=} <expr>, the@@[scope.]<var>spellings, user variables@v {= | :=} <expr>, andSET {CHARACTER SET | CHARSET} …. Each value is a full expression, unlike the generic PostgreSQLSET’s restricted literal/bareword value list, so the two grammars are distinct statements rather than one widened form. - Lexer —
:=lexes to theColonEqualsoperator token (MySQL’sSET_VAR), the same token PostgreSQL’s deprecated named-argument separator produces; the two never coexist in a shipped preset, so the shared token is unambiguous per dialect.
The two facets sit on independent axes, which is why this flag is a documented
exemption from the feature_dependencies registry
rather than a FeatureDependencyViolation variant. The parser facet is unreachable
without show_syntax.session_statements — the leader
that dispatches every SET/RESET/SHOW, so with it off no SET form parses at all
(measured: SET x = 1 is rejected as an unknown statement leader) — a genuine
cross-axis grammar dependency. The lexer facet, however, fires whether or not that
leader is on: with session_statements off, := still munches to one ColonEquals
token (measured), so the flag is not inert without its parser-side base. A registry
whose contract is inertness cannot own a flag that keeps changing tokenization while
its base is off, so the dependency is recorded here instead. See the exemption note on
feature_dependencies.
This is a route flag on the SET head — when on it dispatches the MySQL grammar before
the standard SET TIME ZONE / SET SESSION AUTHORIZATION forms are read (see the parser’s
parse_set) — but unlike the
access_control_account_grants route
it carries no GrammarConflict variant: the grammar it displaces is unconditional base
grammar with no rival feature flag, so there is no independently-expressible both-on state,
and MySQL (a shipped preset) already exercises the route deterministically. Registering it
would require promoting the standard SET config grammar to its own flag or converting this
field to an enum axis — see the GrammarConflict enum doc’s route-flag discussion.
Shared := claim with CallSyntax::named_argument (PostgreSQL named args): both
enable := lexing; shipped presets never arm both, so the token stays unambiguous.
Implementations§
Source§impl SessionVariableSyntax
impl SessionVariableSyntax
Sourcepub const LENIENT: Self
Available on crate feature lenient only.
pub const LENIENT: Self
lenient only.LENIENT: the @@[scope.]name MySQL system-variable form, additive over the
@name parameter that ParameterSyntax::LENIENT already lexes (@@ is
disjoint from @name by its second @). user_variables stays off: @name
is claimed as a named-at parameter here, and the two meanings cannot both hold
the trigger (a LexicalConflict).
Trait Implementations§
Source§impl Clone for SessionVariableSyntax
impl Clone for SessionVariableSyntax
Source§fn clone(&self) -> SessionVariableSyntax
fn clone(&self) -> SessionVariableSyntax
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more