final class NameAssignment
    implements SetItem
    uses Snapshot
Public API: explicitly declared with @visibility public.

An assignment to a variable named without @@: SET x = v, SET GLOBAL x = v, SET a.x = v.

Rule: MYSQL-SET-ITEM-001 (names). With a scope keyword the name is a system variable assigned in that scope. Without one, inside a stored program the name is a variable the program declares when it declares one, and NEW.x in a trigger is a column of the new row; otherwise it is a system variable assigned in the scope inherited from an earlier item (SetVariables::scopeOf()). A qualifier names the component or key cache instance of a structured system variable; DEFAULT.x is the instance default. The value is derived as an expression at a position that sees no relation, a keyword value has no facts, and a bare name value is its text for a system variable (MYSQL-SET-WORD-001). Diagnostics: none. Terminates: the parts are leaves. Source: https://dev.mysql.com/doc/refman/8.4/en/set-variable.html, https://dev.mysql.com/doc/refman/8.4/en/set-statement.html, https://dev.mysql.com/doc/refman/8.4/en/structured-system-variables.html. Status: Implemented.

Reading a scoped name assignmentdoctest
$set = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SET SESSION sort_buffer_size = DEFAULT');
    [$set->statement->items[0]->scope, $set->statement->items[0]->name->value, $set->statement->items[0]->value] // => [\SqlSemantics\Platform\MySql\Statement\Variable\VariableScope::Session, 'sort_buffer_size', \SqlSemantics\Platform\MySql\Statement\Utility\Set\SetWord::Default]

Properties§

public Name $name
public Scalar|SetWord $value
public VariableScope|null $scope = null
public Name|null $qualifier = null

Methods§

public function __construct(
    public Name $name,
    public Scalar|SetWord $value,
    public VariableScope|null $scope = null,
    public Name|null $qualifier = null,
)

Parameters

$nameNameThe assigned name
$valueScalar|SetWordThe value: an expression, or a keyword the grammar accepts there
$scopeVariableScope|nullThe scope keyword written before the name
$qualifierName|nullThe component, key cache instance or trigger row written before the name
Calls 1
public function deriveItem(Derivation $derivation): void

Derives the value.

Parameters

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

Writes the scope, the name, an equals sign and the value.

Parameters

$outOutput
Calls 4

Test cases 9§

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

Dedicated tests 2
Other tests reaching this symbol 7

Relations§

Instantiated in 1
Type checks 3
Type declarations 2