final class SetVariables
    implements Statement
    uses Snapshot
Public API: explicitly declared with @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.
Reading the scope an assignment inheritsdoctest
$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> $items

Methods§

public function __construct(list<SetItem> $items)

Parameters

$itemslist<SetItem>The assignments in order; at least one
Calls 2
public function scopeOf(int $position): ?VariableScope

Answers 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

$positionint

Throws

InvalidConstruction When the position is not one of the items
Calls 1
public function deriveStatement(Derivation $derivation): void

Derives every assignment in order; the statement returns no rows.

Parameters

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

Writes SET and the assignments separated by commas.

Parameters

$outOutput
Calls 1

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

Relations§

Instantiated in 2
Type checks 1
Type declarations 1