classUserVariable
final class UserVariable
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.A user-defined variable read as a value: @name.
Variable names are compared without regard to letter case; the name is kept as written.
Rule: MYSQL-USER-VARIABLE-001. Facts: the type and the NULL fact are those of the value the session last assigned, 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/user-variables.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a = @total');
[$query->statement->where->right->name->value, $query->facts->scalar($query->statement->where->right)->type->missing[0]->describe()] // => ['total', 'the session state: user variable @total']Properties§
public Name $nameMethods§
public function __construct(public Name $name)Parameters
$name | Name | The variable name without the at sign |
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the dependence on the session.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new ScalarFact line 51
- new Dependent line 51
- new SessionState line 51
- class-const Nullability::Dependent() line 51
public function render(Output $out): voidWrites the at sign and the name without a space between them.
Parameters
$out | Output |
Calls 2
- method-call Output::symbol() line 59
- class-const NameUse::Label() line 59
Test cases 34§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 31
WindowRuleTest::testStableLowersEachFormcallsVariableRuleTest::testUserLowersEverySpellingOfAUserVariableNamecallsVariableRuleTest::testVariableLowersUserAndSystemVariablesOfEveryGenerationcallsBlockTest::testSelectReadsATrailingIntoWithoutClausesAsTheIntoAfterTheSelectListcallsBlockTest::testSelectRejectsTwoIntoClausescallsDiagnosticsRuleTest::testStatementLowersConditionInformationcallsDiagnosticsRuleTest::testStatementLowersStatementInformationcallsDiagnosticsRuleTest::testStatementLowersTheConditionNumberAsAVariablecallsSignalRuleTest::testOperandLowersLiteralsVariablesAndNamescallsPrecedenceTest::testAbsorbsTellsWhetherAFollowingOperatorBindsIntoTheRightEdgecallsPrecedenceTest::testTopIsTheLevelAtWhichAnExpressionStandscallsProgramFactsTest::testBodyKeepsAProgramStatementAndAnSqlStatementcallsReturnSearchTest::providerFoundFindsANestedReturncallsReturnSearchTest::providerFoundIsFalseWithoutReturncallsReturnSearchTest::testNestedAnswersNothingForAStatementWithoutNestedStatementscallsReturnSearchTest::testNestedAnswersTheElseStatementsBeforeTheBranchStatementscallsReturnSearchTest::testNestedAnswersTheStatementsAndHandlerStatementsOfABlockcallsPrepareTest::testDeriveStatementDerivesTheVariablecallsComparisonTest::testAVariableAssignmentAsLeftOperandIsRejectedcallsBetweenTest::testALowerBoundThatTakesTheAndIsRejectedcallsIntoVariablesTest::testRenderWritesTheTargetscallsQueryStatementTest::testAnIntoAfterTheSelectListIsRejectedcallsSelectTest::testAnIntoAfterTheClausesWithoutClausesIsRejectedcallsConditionDiagnosticsTest::testRefusesAStatementInformationItemcallsConditionDiagnosticsTest::testRenderWritesTheNumberAndTheItemscallsInformationItemTest::testRenderWritesAUserVariableTargetcallsInformationItemTest::testRenderWritesTheTargetsOfAStatementcallsStatementDiagnosticsTest::testRefusesAConditionInformationItemcallsStatementDiagnosticsTest::testRenderWritesTheItemscallsSignalItemTest::testRefusesTheReturnedSqlstatecallsSignalItemTest::testRenderWritesEveryKindOfValuecalls
Relations§
Instantiated in 1
Constant reads 1
Type checks 6
- instanceof SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::targets() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:112
- instanceof SqlSemantics\Platform\MySql\Statement\Call\Window\WindowFunction::__construct() packages/sql-semantics-mysql/src/Statement/Call/Window/WindowFunction.php:71
- instanceof SqlSemantics\Platform\MySql\Statement\Dml\Load\LoadTable::__construct() packages/sql-semantics-mysql/src/Statement/Dml/Load/LoadTable.php:99
- instanceof SqlSemantics\Platform\MySql\Statement\Dml\Prepared\Prepare::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Prepared/Prepare.php:48
- instanceof SqlSemantics\Platform\MySql\Statement\Query\Into\IntoVariables::__construct() packages/sql-semantics-mysql/src/Statement/Query/Into/IntoVariables.php:42
- instanceof SqlSemantics\Platform\MySql\Statement\Relation\Hint\TableSample::__construct() packages/sql-semantics-mysql/src/Statement/Relation/Hint/TableSample.php:40
Type declarations 9
- type SqlSemantics\Platform\MySql\Lowering\Leaf\VariableRule packages/sql-semantics-mysql/src/Lowering/Leaf/VariableRule.php:87
- type SqlSemantics\Platform\MySql\Lowering\Utility\Explain\OptionRule packages/sql-semantics-mysql/src/Lowering/Utility/Explain/OptionRule.php:74
- type SqlSemantics\Platform\MySql\Rules\Utility\ExplainFacts packages/sql-semantics-mysql/src/Rules/Utility/ExplainFacts.php:43
- type SqlSemantics\Platform\MySql\Statement\Dml\Prepared\Prepare packages/sql-semantics-mysql/src/Statement/Dml/Prepared/Prepare.php:39
- type SqlSemantics\Platform\MySql\Statement\Routine\Condition\Diagnostics\InformationItem packages/sql-semantics-mysql/src/Statement/Routine/Condition/Diagnostics/InformationItem.php:35
- type SqlSemantics\Platform\MySql\Statement\Utility\Explain\Explain packages/sql-semantics-mysql/src/Statement/Utility/Explain/Explain.php:55
- type SqlSemantics\Platform\MySql\Statement\Utility\Explain\ExplainConnection packages/sql-semantics-mysql/src/Statement/Utility/Explain/ExplainConnection.php:49
- type SqlSemantics\Platform\MySql\Statement\Utility\Set\UserAssignment packages/sql-semantics-mysql/src/Statement/Utility/Set/UserAssignment.php:37
- type SqlSemantics\Platform\MySql\Statement\Variable\VariableAssignment packages/sql-semantics-mysql/src/Statement/Variable/VariableAssignment.php:41