final class VariableRule
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.

Lowers user-defined variables, system variables and their scopes.

Rule: MYSQL-VARIABLE-001. Scope: variable, variable_aux, opt_var_ident_type (5.6, 5.7); rvalue_system_or_user_variable, rvalue_system_variable, opt_rvalue_system_variable_type, in_expression_user_variable_assignment, lvalue_variable, opt_set_var_ident_type (8.0 and later). @name is a user variable, @name := expr an assignment, @@[scope.][instance.]name a system variable. LOCAL is the scope SESSION; DEFAULT.name names the instance default. Constructs: UserVariable, VariableAssignment, SystemVariable, VariableScope. Terminates: every child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/user-variables.html, https://dev.mysql.com/doc/refman/8.4/en/using-system-variables.html. Status: Implemented.

Methods§

public function __construct(private Lowering $lowering)

Parameters

$loweringLoweringThe lowering this rule belongs to
public function variable(Node $variable): Scalar

Lowers a variable read, or a user variable assignment, at an expression position.

Parameters

$variableNode

Returns

Throws

ImplementationGap When the production has no rule
Calls 7
public function legacySystem(Form $form): SystemVariable

Lowers the system variable form of MySQL 5.6 and 5.7: a name and an optional component after it.

Parameters

$formForm
Called from 1
Calls 3
public function system(Node $name, ?VariableScope $scope): SystemVariable

Lowers a system variable name of MySQL 8.0 and later, read or assigned, under a scope.

Parameters

$nameNode
$scope?VariableScope

Throws

ImplementationGap When the production has no rule
Test cases 1
Called from 1
Calls 3

Private surface 3§

Implementation details, listed for orientation only.

private const SCOPES = ['opt_var_ident_type: GLOBAL_SYM .' => \SqlSemantics\Platform\MySql\Statement\V…
private const UNSCOPED = ['opt_var_ident_type:' => true, 'opt_rvalue_system_variable_type:' => true, 'op…
private Lowering $lowering

Test cases 2§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 2

Relations§

Instantiated in 1
Type declarations 1