final class BlockFacts
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.

Derives a BEGIN ... END block: its label, its declarations in order, and its statements.

Rule: MYSQL-PROGRAM-BLOCK-001. The block opens a scope inside the scope of its position. Each variable declaration adds its names to the scope of everything after it; a name declared twice in one block is reported (ER_SP_DUP_VAR) and keeps its first meaning, while a name of an outer block or a parameter is hidden. A condition or cursor declared twice in one block is reported (ER_SP_DUP_COND, ER_SP_DUP_CURS), and so is a condition value a handler of the block already handles, by the same handler or an earlier one (ER_SP_DUP_HANDLER). Variables and conditions are declared before cursors and handlers (ER_SP_VARCOND_AFTER_CURSHNDLR), cursors before handlers (ER_SP_CURSOR_AFTER_HANDLER). The query of a cursor is derived as a nested query; the conditions of a handler by MYSQL-PROGRAM-CONDITIONS-001; the statement of a handler in the scope of the declarations before it without the labels outside the handler. Terminates: one pass over the declarations; nested statements are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/begin-end.html, https://dev.mysql.com/doc/refman/8.4/en/declare.html, https://dev.mysql.com/doc/refman/8.4/en/local-variable-scope.html. Status: Implemented.

Methods§

public function ordered(int $stage, int $kind, Derivation $derivation): void

Reports a declaration written after a kind of declaration it must precede.

Parameters

$stageintThe latest kind declared so far: 0 variables and conditions, 1 cursors, 2 handlers
$kindintThe kind of this declaration: 0 a variable or condition, 1 a cursor
$derivationDerivation
Called from 3
Calls 4
public function distinct(
    list<Name> $declared,
    Name $name,
    ProgramRule $rule,
    Derivation $derivation,
    ProgramScope $scope,
): void

Reports a name the block already declared for the same kind of object.

Parameters

$declaredlist<Name>The names of that kind the block declared before
$nameName
$ruleProgramRule
$derivationDerivation
$scopeProgramScope
Called from 2
Calls 3
public function handled(
    list<Condition> $handled,
    Condition $condition,
    Derivation $derivation,
    ProgramScope $scope,
): list<Condition>

Checks a condition value of a handler and answers the values the handlers of the block handle with it.

Parameters

$handledlist<Condition>The values the handlers of the block handle so far
$conditionCondition
$derivationDerivation
$scopeProgramScope

Returns

list<Condition>
Called from 1
Calls 7
public function variables(
    VariableDeclaration $declaration,
    list<Name> $declared,
    Derivation $derivation,
    ProgramScope $scope,
): ProgramScope

Derives a variable declaration and answers the scope in which its names are visible.

Parameters

$declarationVariableDeclaration
$declaredlist<Name>The variable names the block declared before
$derivationDerivation
$scopeProgramScope
Called from 1
Calls 8

Test cases 1§

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

Dedicated tests 1

Relations§

Instantiated in 1
Method calls 1