classViewRule
final class ViewRule
Lowers CREATE VIEW, ALTER VIEW and DROP VIEW.
Rule: MYSQL-VIEW-LOWERING-001. Scope: view_replace_or_algorithm, view_replace, view_algorithm, view_suid, view_tail, view_list_opt, view_list, view_select, view_query_block, view_check_option, alter_view_stmt, drop_view_stmt, and the alter and drop alternatives of views (5.x). The definer comes from the leaf rules, the query from the query family. Constructs: CreateView, AlterView, DropView, ViewDefinition. Terminates: every child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/create-view.html, https://dev.mysql.com/doc/refman/8.4/en/alter-view.html, https://dev.mysql.com/doc/refman/8.4/en/drop-view.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function create(Node $tail, ?Node $prefix, ?Account $definer): CreateViewLowers CREATE VIEW: a node of view_tail, the node of view_replace_or_algorithm when one is written, and the definer.
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 3
- method-call ViewRule::prefix() line 85
- new CreateView line 87
- method-call ViewRule::definition() line 87
public function prefix(Node $prefix): array{bool, ViewAlgorithm|null}Lowers the OR REPLACE and ALGORITHM prefix: a node of view_replace_or_algorithm.
Parameters
$prefix | Node |
Returns
array{bool, ViewAlgorithm|null}Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 3
- method-call ViewRule::replace() line 101
- method-call ViewRule::algorithm() line 102
- static-call ImplementationGap::production() line 104
public function replace(Node $replace): boolConfirms OR REPLACE: a node of view_replace.
Parameters
$replace | Node |
Returns
boolThrows
ImplementationGap When the production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::prefix() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:101
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::prefix() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:102
Calls 1
- static-call ImplementationGap::production() line 117
public function algorithm(Node $algorithm): ViewAlgorithmLowers an algorithm clause: a node of view_algorithm.
Parameters
$algorithm | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::prefix() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:102
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::prefix() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:103
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::alter() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:207
Calls 2
- class-const ViewRule::ALGORITHMS() line 129
- static-call ImplementationGap::production() line 129
public function definition(
Node $tail,
?ViewAlgorithm $algorithm,
?Account $definer,
): ViewDefinitionLowers the definition after the definer: a node of view_tail.
Parameters
$tail | Node | |
$algorithm | ?ViewAlgorithm | |
$definer | ?Account |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::create() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:87
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::alter() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:207
Calls 7
- function-call
array_key_existsline 141 - class-const ViewRule::SECURITY() line 141
- static-call ImplementationGap::production() line 142
- method-call ViewRule::columns() line 145
- method-call ViewRule::derived() line 146
- class-const ViewRule::CHECKS() line 155
- new ViewDefinition line 159
Lowers a 5.x column list: a node of view_list_opt; none is null.
Parameters
$list | Node |
Returns
list<Name>|nullThrows
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 3
- static-call ImplementationGap::production() line 175
- method-call Spine::items() line 178
- new Spine line 178
Lowers an 8.0 column list: a node of opt_derived_column_list; none is null.
Parameters
$list | Node |
Returns
list<Name>|nullThrows
ImplementationGap When a production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:146
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\View\ViewRule::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/View/ViewRule.php:147
Lowers ALTER VIEW: the form of a 5.x alter alternative or of alter_view_stmt.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::statement() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:53
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:72
Calls 6
- class-const ViewRule::ALTERS() line 205
- static-call ImplementationGap::production() line 205
- new AlterView line 207
- method-call ViewRule::definition() line 207
- method-call Form::node() line 207
- method-call ViewRule::algorithm() line 207
Lowers DROP VIEW: the form of the 5.x drop alternative or of drop_view_stmt.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::statement() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:54
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:73
Calls 3
- static-call ImplementationGap::production() line 218
- new DropView line 221
- method-call Form::node() line 221
Private surface 5§
Implementation details, listed for orientation only.
private const ALGORITHMS = ['view_algorithm: ALGORITHM_SYM EQ UNDEFINED_SYM' => \SqlSemantics\Platform\MyS…private const CHECKS = ['view_check_option:' => null, 'view_check_option: WITH CHECK_SYM OPTION' => \S…private const SECURITY = ['view_suid:' => null, 'view_suid: SQL_SYM SECURITY_SYM DEFINER_SYM' => \SqlSem…private const ALTERS = ['alter: ALTER view_algorithm definer_opt view_tail' => [1, 2, 3], 'alter: ALTE…private Lowering $loweringTest cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
ViewRuleTest::testAlgorithmLowersTheAlgorithmcallsViewRuleTest::testAlterLowersAlterViewcallsViewRuleTest::testColumnsLowersALegacyColumnListcallsViewRuleTest::testCreateLowersAViewTailcallsViewRuleTest::testDefinitionLowersTheTailcallsViewRuleTest::testDerivedLowersAnAbsentColumnListcallsViewRuleTest::testDropLowersDropViewcallsViewRuleTest::testPrefixLowersReplaceAndAlgorithmcallsViewRuleTest::testReplaceConfirmsOrReplacecalls
Relations§
Instantiated in 4
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::statement() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:53
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::statement() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:54
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:68
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::createView() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:86
Method calls 5
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::statement() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:53
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::statement() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:54
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:72
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:73
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::createView() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:86