classBodyFacts
final class BodyFacts
Derives the statements of a stored program at their position.
Rule: MYSQL-PROGRAM-BODY-001. A statement of the stored program language is derived in the scope of its position. Any other SQL statement is first checked against the restrictions of the program kind (MYSQL-PROGRAM-RESTRICTIONS-001) and, in a trigger, a SET statement against MYSQL-TRIGGER-ASSIGNMENT-001. A query is then derived as a nested query whose enclosing scope holds the parameters and local variables, so it returns no rows of the statement that defines the program; any other statement as an inspected request read at the environment of the position, so it sees the same parameters and variables: its parts receive their facts and its diagnostics are kept, while it declares nothing and returns nothing. Limit: a nested statement finds a column of its own tables before a variable of the same name, where the server prefers the variable; that needs a resolution order the core does not offer. An external routine body holds no SQL and derives nothing. Terminates: one pass over the list; nested statements are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/local-variable-scope.html, https://dev.mysql.com/doc/refman/8.4/en/stored-program-restrictions.html. Status: Implemented.
Methods§
public function statements(
list<Node> $statements,
Derivation $derivation,
ProgramScope $scope,
): voidDerives the statements of a list in order.
Parameters
$statements | list<Node> | |
$derivation | Derivation | |
$scope | ProgramScope |
Called from 4
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:85
- method-call SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::branches() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:44
- method-call SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::branches() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:46
- method-call SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::loop() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:60
Calls 1
- method-call BodyFacts::statement() line 48
public function statement(Node $statement, Derivation $derivation, ProgramScope $scope): voidDerives one statement of a program.
Parameters
$statement | Node | |
$derivation | Derivation | |
$scope | ProgramScope |
Called from 5
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:82
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BodyFacts::statements() packages/sql-semantics-mysql/src/Rules/Routine/BodyFacts.php:48
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::routine() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:82
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::trigger() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:96
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::event() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:106
Calls 7
- method-call Node::deriveProgram() line 58
- method-call ProgramRestrictions::check() line 63
- new ProgramRestrictions line 63
- method-call TriggerAssignments::check() line 66
- new TriggerAssignments line 66
- method-call Derivation::query() line 69
- method-call Derivation::inspected() line 71
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
BodyFactsTestcalls
Relations§
Instantiated in 8
- new SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:82
- new SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:85
- new SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::branches() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:44
- new SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::branches() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:46
- new SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::loop() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:60
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::routine() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:82
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::trigger() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:96
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::event() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:106
Method calls 8
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:82
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::derive() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:85
- method-call SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::branches() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:44
- method-call SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::branches() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:46
- method-call SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::loop() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:60
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::routine() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:82
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::trigger() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:96
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::event() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:106