final class SystemVariable
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @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.

Reading a scoped system variabledoctest
$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 $name
public VariableScope|null $scope = null
public Name|null $instance = null

Methods§

public function __construct(
    public Name $name,
    public VariableScope|null $scope = null,
    public Name|null $instance = null,
)

Parameters

$nameNameThe variable name
$scopeVariableScope|nullThe scope written before the name; the grammar reads GLOBAL or SESSION in an expression and also PERSIST and PERSIST_ONLY in SET
$instanceName|nullThe instance or component name of a structured variable
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the dependence on the server.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 4
public function render(Output $out): void

Writes both at signs, the scope, the instance and the name without spaces.

Parameters

$outOutput
Calls 4

Test cases 10§

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

Dedicated tests 5
Other tests reaching this symbol 5

Relations§

Instantiated in 5
Type declarations 4