classSetVariables
final class SetVariables
implements Statement
uses Snapshot
@visibility public.SET with a list of assignments: variables, the connection character sets, and in MySQL 5.6 a password.
Rule: MYSQL-SET-001. The assignments run in the order written. A scope keyword written before a variable name (SET GLOBAL a = 1) also applies to every later assignment that names a variable without a scope of its own (b in SET GLOBAL a = 1, b = 2); a scope written inside @@ applies to its own variable only, and @x assignments have no scope. scopeOf() answers that inherited scope. Each item derives its own parts (MYSQL-SET-ITEM-001); the statement returns no rows and provides no declaration. Terminates: one pass over the items. Source: https://dev.mysql.com/doc/refman/8.4/en/set-variable.html ("the most recent GLOBAL, PERSIST, PERSIST_ONLY, or SESSION modifier in
- the statement is used for following assignments that have no modifier
- specified"). Status: Implemented.
$set = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SET GLOBAL a = 1, b = ON');
[$set->statement->scopeOf(1), $set->toString()] // => [\SqlSemantics\Platform\MySql\Statement\Variable\VariableScope::Global, 'SET GLOBAL a = 1, b = ON']Properties§
public non-empty-list<SetItem> $itemsMethods§
public function __construct(list<SetItem> $items)Parameters
$items | list<SetItem> | The assignments in order; at least one |
Calls 2
- static-call Check::listOf() line 49
- class-const SetItem::class() line 49
public function scopeOf(int $position): ?VariableScopeAnswers the scope a variable assignment at a position assigns in: its own, or the last one written before it by a name assignment.
Null means that no scope applies: none is written, so a system variable is assigned in the session, or the item is no system variable assignment.
Parameters
$position | int |
Returns
Throws
InvalidConstruction When the position is not one of the itemsCalls 1
- static-call Check::input() line 63
public function deriveStatement(Derivation $derivation): voidDerives every assignment in order; the statement returns no rows.
Parameters
$derivation | Derivation |
public function render(Output $out): voidWrites SET and the assignments separated by commas.
Parameters
$out | Output |
Calls 1
- method-call Output::keyword() line 96
Test cases 32§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 28
BlockRuleTest::testBlockLowersAnUnlabeledBlockcallsBlockRuleTest::testDeclarationLowersAConditionAndAHandlercallsFlowRuleTest::testChoiceLowersASearchedCasecallsFlowRuleTest::testChoiceLowersASimpleCasecallsFlowRuleTest::testConditionalLowersTheBranchesAndTheElsecallsFlowRuleTest::testLoopLowersLoopWhileAndRepeatcallsStatementRuleTest::testStatementRoutesEveryKindOfProgramStatementcallsStatementRuleTest::testStatementsLowersTheListInOrdercallsSequenceTest::testItemsAnswersTheMembersInSourceOrdercallsTriggerRuleTest::testCreateLowersATriggerOfEveryLayoutcallsSetRuleTest::testUnscopedRoutesALonePasswordToTheAccountFamilycallsValueRuleTest::testWordLowersABareNamecallsProgramFactsTest::testBodyKeepsAProgramStatementAndAnSqlStatementcallsReturnSearchTest::providerFoundFindsANestedReturncallsReturnSearchTest::providerFoundIsFalseWithoutReturncallsReturnSearchTest::testNestedAnswersNothingForAStatementWithoutNestedStatementscallsReturnSearchTest::testNestedAnswersTheElseStatementsBeforeTheBranchStatementscallsReturnSearchTest::testNestedAnswersTheStatementsAndHandlerStatementsOfABlockcallsRowAliasesTest::testVisibleResolvesTheOldRowToTheTriggerTablecallsBareNameTest::testDeriveScalarDependsOnTheProgramOtherwisecallsBareNameTest::testDeriveScalarIsTextForASystemVariablecallsNameAssignmentTest::testDeriveItemLeavesAnUnscopedWordToTheProgramcallsNamesExpressionTest::testDeriveItemReportsTheRefusalcallsPasswordAssignmentTest::testDeriveItemDerivesNothingcallsSetCharacterSetTest::testDeriveItemDerivesNothingcallsSetNamesTest::testDeriveItemDerivesNothingcallsSystemAssignmentTest::testDeriveItemDerivesTheVariableAndTheValuecallsUserAssignmentTest::testDeriveItemDerivesTheVariableAndTheValuecalls