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

A local variable of a stored program named where only a variable is accepted: a LIMIT operand or an INTO target.

Rule: MYSQL-PROGRAM-VARIABLE-001. A bare name in LIMIT or after INTO denotes a variable or parameter declared by the enclosing stored program; outside one the server reports an undeclared variable. The declaration is runtime program state the analysis context does not hold, so the type and the NULL fact depend on it. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html (LIMIT), https://dev.mysql.com/doc/refman/8.4/en/select-into.html. Status: Implemented.

Reading a program variable used as a row countdoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t LIMIT n');
    $query->statement->limit->count->name->value // => 'n'

Properties§

public Name $name

Methods§

public function __construct(public Name $name)

Parameters

$nameNameThe variable name
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Depends on the declaration of the variable in the enclosing stored program.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the name.

Parameters

$outOutput
Calls 2

Test cases 2§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 1

Relations§

Instantiated in 2
Type checks 2