Skip to main content

SessionVariableSyntax

Struct SessionVariableSyntax 

Source
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: bool

Accept @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: bool

Accept @@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: bool

Accept 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 SET becomes 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>, and SET {CHARACTER SET | CHARSET} …. Each value is a full expression, unlike the generic PostgreSQL SET’s restricted literal/bareword value list, so the two grammars are distinct statements rather than one widened form.
  • Lexer:= lexes to the ColonEquals operator token (MySQL’s SET_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

Source

pub const ANSI: Self

The ANSI predefined value.

Source§

impl SessionVariableSyntax

Source

pub const LENIENT: Self

Available on crate feature 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).

Source§

impl SessionVariableSyntax

Source

pub const MYSQL: Self

Available on crate feature mysql only.

The MYSQL preset for session variable syntax.

Trait Implementations§

Source§

impl Clone for SessionVariableSyntax

Source§

fn clone(&self) -> SessionVariableSyntax

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 SessionVariableSyntax

Source§

impl Debug for SessionVariableSyntax

Source§

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

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

impl Eq for SessionVariableSyntax

Source§

impl PartialEq for SessionVariableSyntax

Source§

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

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.