classProgramVariable
final class ProgramVariable
implements Scalar
uses Snapshot
@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.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t LIMIT n');
$query->statement->limit->count->name->value // => 'n'Properties§
public Name $nameMethods§
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDepends on the declaration of the variable in the enclosing stored program.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new ScalarFact line 52
- new Dependent line 52
- new SessionState line 52
- class-const Nullability::Dependent() line 52
public function render(Output $out): voidWrites the name.
Parameters
$out | Output |
Calls 2
- method-call Output::name() line 60
- class-const NameUse::Column() line 60
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
ProgramVariableTestcalls
Other tests reaching this symbol 1
Relations§
Instantiated in 2
Type checks 2
- instanceof SqlSemantics\Platform\MySql\Statement\Query\Clause\RowLimit::__construct() packages/sql-semantics-mysql/src/Statement/Query/Clause/RowLimit.php:45
- instanceof SqlSemantics\Platform\MySql\Statement\Query\Into\IntoVariables::__construct() packages/sql-semantics-mysql/src/Statement/Query/Into/IntoVariables.php:42