classBlockFacts
final class BlockFacts
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 derive(Block $block, Derivation $derivation, ProgramScope $scope): voidDerives the block in the scope of its position.
Parameters
$block | Block | |
$derivation | Derivation | |
$scope | ProgramScope |
Called from 1
Calls 17
- method-call LabelFacts::enter() line 52
- new LabelFacts line 52
- new Environment line 53
- method-call BlockFacts::ordered() line 61
- method-call BlockFacts::variables() line 62
- function-call
array_pushline 63 - method-call BlockFacts::distinct() line 66
- class-const ProgramRule::DuplicateCondition() line 66
- method-call ConditionFacts::value() line 67
- new ConditionFacts line 67
- function-call
maxline 72 - class-const ProgramRule::DuplicateCursor() line 73
- method-call Derivation::query() line 74
- method-call BlockFacts::handled() line 80
- method-call BodyFacts::statement() line 82
- new BodyFacts line 82
- method-call BodyFacts::statements() line 85
public function ordered(int $stage, int $kind, Derivation $derivation): voidReports a declaration written after a kind of declaration it must precede.
Parameters
$stage | int | The latest kind declared so far: 0 variables and conditions, 1 cursors, 2 handlers |
$kind | int | The kind of this declaration: 0 a variable or condition, 1 a cursor |
$derivation | Derivation |
Called from 3
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:61
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:65
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:71
Calls 4
- method-call Derivation::report() line 97
- new ProgramProblem line 97
- class-const ProgramRule::DeclarationAfterCursorOrHandler() line 97
- class-const ProgramRule::CursorAfterHandler() line 100
public function distinct(
list<Name> $declared,
Name $name,
ProgramRule $rule,
Derivation $derivation,
ProgramScope $scope,
): voidReports a name the block already declared for the same kind of object.
Parameters
$declared | list<Name> | The names of that kind the block declared before |
$name | Name | |
$rule | ProgramRule | |
$derivation | Derivation | |
$scope | ProgramScope |
Called from 2
Calls 3
- method-call ProgramScope::holds() line 111
- method-call Derivation::report() line 112
- new ProgramProblem line 112
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
$handled | list<Condition> | The values the handlers of the block handle so far |
$condition | Condition | |
$derivation | Derivation | |
$scope | ProgramScope |
Returns
list<Condition>Called from 1
Calls 7
- new ConditionFacts line 125
- method-call ConditionFacts::value() line 126
- method-call ConditionFacts::meaning() line 127
- method-call ConditionFacts::same() line 132
- method-call Derivation::report() line 133
- new ProgramProblem line 133
- class-const ProgramRule::DuplicateHandler() line 133
public function variables(
VariableDeclaration $declaration,
list<Name> $declared,
Derivation $derivation,
ProgramScope $scope,
): ProgramScopeDerives a variable declaration and answers the scope in which its names are visible.
Parameters
$declaration | VariableDeclaration | |
$declared | list<Name> | The variable names the block declared before |
$derivation | Derivation | |
$scope | ProgramScope |
Returns
Called from 1
Calls 8
- method-call Derivation::relation() line 149
- method-call ProgramScope::holds() line 152
- method-call Derivation::report() line 153
- new ProgramProblem line 153
- class-const ProgramRule::DuplicateVariable() line 153
- new Environment line 158
- new VisibleRelation line 158
- method-call ProgramScope::declared() line 160
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
BlockFactsTestcalls