final class BareName
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A bare name written as the value of a variable assignment in SET, such as TRADITIONAL in SET sql_mode = TRADITIONAL.

Rule: MYSQL-SET-WORD-001. When the assigned variable is a system variable, the server does not resolve the name as a column: it assigns the text of the last name part (b for a.b) as a string. Facts: assigned to a system variable (@@x, or a name with a scope keyword), the value is a known non-NULL VARCHAR; assigned to a name without a scope, which inside a stored program can be a declared variable whose value is an expression, it depends on the declarations of the enclosing program (ProgramVariable). In a trigger body NEW.x and OLD.x are a column of the row whatever the variable (the parser makes them Item_trigger_field, which is not turned into text), so they resolve as a column name does (MYSQL-COLUMN-LOOKUP-001). The qualifiers are kept and written back. Terminates: no child is derived. Source: https://dev.mysql.com/doc/refman/8.4/en/set-variable.html, set_var::set_var in sql/set_var.cc ("If the set value is a field, change

  • it to a string to allow things like SET table_type=MYISAM;").

Status: Implemented.

Reading a word assigned to a system variabledoctest
$set = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SET @@sql_mode = TRADITIONAL');
    [$set->statement->items[0]->value->word->value, $set->facts->scalar($set->statement->items[0]->value)->type->descriptor->name()] // => ['TRADITIONAL', 'VARCHAR']

Properties§

public Name $word
public QualifiedName|null $qualifier = null
public bool $system = true

Methods§

public function __construct(
    public Name $word,
    public QualifiedName|null $qualifier = null,
    public bool $system = true,
)

Parameters

$wordNameThe last name part, whose text is the value
$qualifierQualifiedName|nullThe name parts written before it
$systemboolWhether the assigned variable is known to be a system variable
Calls 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives a known string for a system variable, and the dependence on the enclosing program otherwise.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 11
public function render(Output $out): void

Writes the name parts separated by dots.

Parameters

$outOutput
Calls 3

Test cases 7§

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 5

Relations§

Instantiated in 1
Type checks 2
Type declarations 1