classSystemVariable
final class SystemVariable
implements Scalar
uses Snapshot
@visibility public.A system variable read as a value or named as the target of SET: @@name, @@GLOBAL.name, @@instance.name.
A structured variable is written with the name of its instance or component before the variable name; DEFAULT.name names the instance default. Without a scope the session value is read when the variable has one and the global value otherwise.
Rule: MYSQL-SYSTEM-VARIABLE-001. Facts: the type and the NULL fact are those of the variable in the running server, which no context holds; the fact names the variable as missing session state. Diagnostics: none. Source: https://dev.mysql.com/doc/refman/8.4/en/using-system-variables.html, https://dev.mysql.com/doc/refman/8.4/en/structured-system-variables.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a = @@GLOBAL.sort_buffer_size');
[$query->statement->where->right->scope, $query->statement->where->right->name->value] // => [\SqlSemantics\Platform\MySql\Statement\Variable\VariableScope::Global, 'sort_buffer_size']Properties§
public Name $namepublic VariableScope|null $scope = nullpublic Name|null $instance = nullMethods§
public function __construct(
public Name $name,
public VariableScope|null $scope = null,
public Name|null $instance = null,
)Parameters
$name | Name | The variable name |
$scope | VariableScope|null | The scope written before the name; the grammar reads GLOBAL or SESSION in an expression and also PERSIST and PERSIST_ONLY in SET |
$instance | Name|null | The instance or component name of a structured variable |
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the dependence on the server.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new ScalarFact line 58
- new Dependent line 58
- new SessionState line 58
- class-const Nullability::Dependent() line 58
public function render(Output $out): voidWrites both at signs, the scope, the instance and the name without spaces.
Parameters
$out | Output |
Calls 4
- method-call Output::symbol() line 66
- method-call Output::keyword() line 68
- method-call Output::name() line 71
- class-const NameUse::Label() line 71
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
SystemVariableTest::testDeriveScalarNamesAnUnscopedVariableWithoutAScopecallsSystemVariableTest::testDeriveScalarNamesTheInstanceOfAStructuredVariablecallsSystemVariableTest::testDeriveScalarNamesTheVariableAsMissingSessionStatecallsSystemVariableTest::testRenderBuildsSqlFromAnExplicitStructurecallsSystemVariableTest::testRenderSpellsLocalAsSessioncalls
Other tests reaching this symbol 5
NameRuleTest::testOptionalLowersTheComponentOfALegacySystemVariablecallsVariableRuleTest::testLegacySystemLowersTheScopeAndComponentOfMySql5callsVariableRuleTest::testVariableLowersUserAndSystemVariablesOfEveryGenerationcallsSignalRuleTest::testOperandLowersLiteralsVariablesAndNamescallsSystemAssignmentTest::testRefusesAnUnresolvedWordcalls
Relations§
Instantiated in 5
- new SqlSemantics\Platform\MySql\Lowering\Leaf\VariableRule::legacySystem() packages/sql-semantics-mysql/src/Lowering/Leaf/VariableRule.php:109
- new SqlSemantics\Platform\MySql\Lowering\Leaf\VariableRule::system() packages/sql-semantics-mysql/src/Lowering/Leaf/VariableRule.php:123
- new SqlSemantics\Platform\MySql\Lowering\Leaf\VariableRule::system() packages/sql-semantics-mysql/src/Lowering/Leaf/VariableRule.php:124
- new SqlSemantics\Platform\MySql\Lowering\Leaf\VariableRule::system() packages/sql-semantics-mysql/src/Lowering/Leaf/VariableRule.php:125
- new SqlSemantics\Platform\MySql\Lowering\Utility\Set\ItemRule::unscoped() packages/sql-semantics-mysql/src/Lowering/Utility/Set/ItemRule.php:84
Type declarations 4
- type SqlSemantics\Platform\MySql\Lowering\Leaf\VariableRule packages/sql-semantics-mysql/src/Lowering/Leaf/VariableRule.php:103
- type SqlSemantics\Platform\MySql\Lowering\Leaf\VariableRule packages/sql-semantics-mysql/src/Lowering/Leaf/VariableRule.php:117
- type SqlSemantics\Platform\MySql\Statement\Server\Plugin\ComponentSetting packages/sql-semantics-mysql/src/Statement/Server/Plugin/ComponentSetting.php:40
- type SqlSemantics\Platform\MySql\Statement\Utility\Set\SystemAssignment packages/sql-semantics-mysql/src/Statement/Utility/Set/SystemAssignment.php:41