classVariableRule
final class VariableRule
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
$lowering | Lowering | The lowering this rule belongs to |
Lowers a variable read, or a user variable assignment, at an expression position.
Parameters
$variable | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalls 7
- method-call VariableRule::user() line 75
- function-call
countline 75 - method-call VariableRule::assignment() line 76
- method-call VariableRule::legacySystem() line 78
- method-call VariableRule::system() line 79
- method-call VariableRule::scope() line 79
- static-call ImplementationGap::production() line 80
public function user(Node $name): UserVariableLowers a user variable name.
Parameters
$name | Node |
Returns
Called from 2
Calls 1
- new UserVariable line 89
public function assignment(Node $name, Node $value): VariableAssignmentLowers a user variable assignment.
Returns
Called from 2
Calls 2
- new VariableAssignment line 97
- method-call VariableRule::user() line 97
public function legacySystem(Form $form): SystemVariableLowers the system variable form of MySQL 5.6 and 5.7: a name and an optional component after it.
Parameters
$form | Form |
Returns
Called from 1
Calls 3
- method-call Form::node() line 105
- method-call VariableRule::scope() line 107
- new SystemVariable line 109
public function system(Node $name, ?VariableScope $scope): SystemVariableLowers a system variable name of MySQL 8.0 and later, read or assigned, under a scope.
Parameters
$name | Node | |
$scope | ?VariableScope |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 3
- new SystemVariable line 123
- new Name line 125
- static-call ImplementationGap::production() line 126
public function scope(Node $scope): ?VariableScopeLowers the optional scope written before a system variable name.
Parameters
$scope | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 3
- class-const VariableRule::UNSCOPED() line 138
- class-const VariableRule::SCOPES() line 142
- static-call ImplementationGap::production() line 142
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 $loweringTest cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.