classNameAssignment
final class NameAssignment
implements SetItem
uses Snapshot
@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.
$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 $namepublic Scalar|SetWord $valuepublic VariableScope|null $scope = nullpublic Name|null $qualifier = nullMethods§
public function __construct(
public Name $name,
public Scalar|SetWord $value,
public VariableScope|null $scope = null,
public Name|null $qualifier = null,
)Parameters
$name | Name | The assigned name |
$value | Scalar|SetWord | The value: an expression, or a keyword the grammar accepts there |
$scope | VariableScope|null | The scope keyword written before the name |
$qualifier | Name|null | The component, key cache instance or trigger row written before the name |
Calls 1
- static-call Check::input() line 53
public function deriveItem(Derivation $derivation): voidDerives the value.
Parameters
$derivation | Derivation |
Calls 4
- method-call Operands::single() line 62
- new Operands line 62
- method-call Derivation::scalar() line 62
- method-call Derivation::environment() line 62
public function render(Output $out): voidWrites the scope, the name, an equals sign and the value.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 72
- method-call Output::name() line 75
- class-const NameUse::Label() line 75
- method-call Output::node() line 81
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
BlockRuleTest::testBlockLowersAnUnlabeledBlockcallsBlockRuleTest::testDeclarationLowersAConditionAndAHandlercallsFlowRuleTest::testChoiceLowersASearchedCasecallsFlowRuleTest::testChoiceLowersASimpleCasecallsFlowRuleTest::testLoopLowersLoopWhileAndRepeatcallsRowAliasesTest::testVisibleResolvesTheOldRowToTheTriggerTablecallsBareNameTest::testDeriveScalarDependsOnTheProgramOtherwisecalls
Relations§
Instantiated in 1
Type checks 3
- instanceof SqlSemantics\Platform\MySql\Rules\Routine\TriggerAssignments::check() packages/sql-semantics-mysql/src/Rules/Routine/TriggerAssignments.php:46
- instanceof SqlSemantics\Platform\MySql\Statement\Utility\Set\SetVariables::scopeOf() packages/sql-semantics-mysql/src/Statement/Utility/Set/SetVariables.php:68
- instanceof SqlSemantics\Platform\MySql\Statement\Utility\Set\SetVariables::scopeOf() packages/sql-semantics-mysql/src/Statement/Utility/Set/SetVariables.php:73