classQueryRules
final class QueryRules
The entry rules of the query family: the methods other families and the statement dispatcher call.
Rule: MYSQL-QUERY-ENTRY-001. Scope: SELECT, set operations, VALUES and TABLE statements, WITH, table references, joins, grouping, ordering, limits, locking and INTO, in both grammar generations: the rules of Lowering/Query/Modern (8.0 and later), Lowering/Query/Legacy (5.6 and 5.7) and Lowering/Query/Shared. A query that a subquery, a derived table or a common table expression writes in the parentheses its syntax requires is answered without those parentheses; the construct that holds it writes them. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html. Status: Implemented.
Properties§
public Lowering $loweringMethods§
public function __construct(public Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers a query statement: a node of select (5.6, 5.7) or select_stmt (8.0 and later).
Parameters
$statement | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 2
- method-call QueryRules::query() line 69
- static-call Check::invariant() line 70
Lowers a query used inside another statement: a node of select, select_stmt, subselect,
subquery, table_subquery, row_subquery, query_expression, query_expression_parens,
query_expression_with_opt_locking_clauses or view_select_aux.
Parameters
$query | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 14
- new ExpressionRule line 84
- method-call UnionRule::statement() line 87
- new UnionRule line 87
- method-call ExpressionRule::statement() line 88
- method-call SubqueryRule::subselect() line 89
- new SubqueryRule line 89
- method-call ExpressionRule::subquery() line 90
- method-call ExpressionRule::expression() line 91
- new Trailer line 91
- method-call ExpressionRule::inner() line 92
- method-call ExpressionRule::locked() line 93
- method-call UnionRule::viewQuery() line 94
- static-call ImplementationGap::production() line 95
- method-call Lowering::form() line 95
Lowers the query of CREATE TABLE ... SELECT and INSERT ... SELECT of MySQL 5.6 and 5.7: a node of
create_select and the node of union_clause, opt_union_clause or union_opt that follows it.
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 4
- method-call UnionRule::chain() line 107
- new UnionRule line 107
- method-call BlockRule::create() line 107
- new BlockRule line 107
Lowers the parenthesized query of CREATE TABLE ... SELECT and INSERT ... SELECT of MySQL 5.6 and 5.7: the
node of create_select written in parentheses (create3, insert_values, insert_query_expression:
( create_select ) union_opt) and the node of union_opt that follows the parentheses. The
parentheses are kept as a parenthesized query; the holding statement writes nothing for them.
Returns
Throws
ImplementationGap When a production has no ruleCalls 5
- method-call UnionRule::chain() line 120
- new UnionRule line 120
- new ParenthesizedQuery line 120
- method-call BlockRule::create() line 120
- new BlockRule line 120
Lowers a row predicate: a node of where_clause or opt_where_clause; an absent clause is null.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call ClauseRule::predicate() line 130
- new ClauseRule line 130
Lowers ordering or grouping expressions: a node of opt_order_clause, order_clause, order_list
or group_list; an absent clause is empty. Integers stay the expressions they are.
Parameters
$clause | Node |
Returns
list<OrderItem>Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call ClauseRule::orderItems() line 142
- new ClauseRule line 142
Lowers one ordering expression: a node of order_expr, or a node of order_ident with the node of
order_dir that follows it.
Returns
Throws
ImplementationGap When a production has no ruleCalls 2
- method-call ClauseRule::item() line 153
- new ClauseRule line 153
Lowers a sort direction: a node of order_dir, opt_ordering_direction or ordering_direction; no
direction is null.
Parameters
$direction | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call ClauseRule::direction() line 164
- new ClauseRule line 164
Lowers a LIMIT clause: a node of opt_limit_clause, limit_clause, opt_simple_limit or
opt_limit_clause_init; an absent clause is null.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call TailRule::limit() line 175
- new TailRule line 175
Lowers one LIMIT operand: a node of limit_option.
Parameters
$option | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call TailRule::value() line 185
- new TailRule line 185
Lowers the table references of UPDATE and DELETE: a node of join_table_list or
table_reference_list.
Parameters
$list | Node |
Returns
list<Relation>Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call FromRule::members() line 197
- new FromRule line 197
Lowers an explicit partition selection: a node of opt_use_partition or use_partition; an absent
selection is empty.
Parameters
$selection | Node |
Returns
list<Name>Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call TableRule::partitions() line 209
- new TableRule line 209
Lowers an optional alias: a node of opt_table_alias or select_alias.
Parameters
$alias | Node |
Returns
?NameThrows
ImplementationGap When a production has no ruleCalls 4
- method-call ItemRule::alias() line 219
- new ItemRule line 219
- method-call TableRule::alias() line 219
- new TableRule line 219
Answers what is written before an optional alias: a node of opt_table_alias or select_alias.
Parameters
$alias | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalls 4
- method-call ItemRule::mark() line 229
- new ItemRule line 229
- method-call TableRule::mark() line 229
- new TableRule line 229
Lowers the column names of a derived table, view or VALUES alias: a node of
opt_derived_column_list; an absent list is empty.
Parameters
$list | Node |
Returns
list<Name>Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call TableRule::columns() line 241
- new TableRule line 241
public function with(Node $clause): ?WithClauseLowers a WITH clause: a node of opt_with_clause or with_clause; an absent clause is null.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call PrimaryRule::with() line 251
- new PrimaryRule line 251
public function selectItems(Node $list): list<SelectExpression|Star|TableWildcard>Lowers a select list: a node of select_item_list.
Parameters
$list | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 2
- method-call ItemRule::items() line 262
- new ItemRule line 262
Lowers the index names of an index hint or of CACHE INDEX: a node of opt_key_usage_list; an absent
list is empty. A list that names the primary key with PRIMARY is lowered by indexKeys().
Parameters
$list | Node |
Returns
list<Name>Throws
ImplementationGap When the list names PRIMARY or a production has no ruleTest cases 1
Calls 2
- method-call QueryRules::indexKeys() line 275
- static-call ImplementationGap::rule() line 276
public function indexKeys(Node $list): list<Name|PrimaryIndex>Lowers the indexes of an index hint or of CACHE INDEX, where PRIMARY names the primary key: a node of
opt_key_usage_list or key_usage_list; an absent list is empty.
Parameters
$list | Node |
Returns
list<Name|PrimaryIndex>Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 2
- method-call TableRule::indexes() line 291
- new TableRule line 291
Test cases 14§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 14
QueryRulesTest::testColumnAliasesAnswersNothingForNoListcallsQueryRulesTest::testDirectionAnswersNullForNoDirectioncallsQueryRulesTest::testIndexKeysAnswersNothingForNoListcallsQueryRulesTest::testIndexNamesAnswersNothingForNoListcallsQueryRulesTest::testLegacyParenthesizedQueryKeepsTheParenthesesAndTheUnioncallsQueryRulesTest::testLegacyQueryLowersCreateSelectWithItsUnioncallsQueryRulesTest::testLimitAnswersNullForAnAbsentClausecallsQueryRulesTest::testLimitValueLowersAnIntegercallsQueryRulesTest::testOrderingAnswersNothingForAnAbsentClausecallsQueryRulesTest::testPartitionsAnswersNothingForNoSelectioncallsQueryRulesTest::testSelectItemsLowersTheStarcallsQueryRulesTest::testTablesLowersTheReferencesOfAMultipleTableStatementcallsQueryRulesTest::testWhereAnswersNullForAnAbsentClausecallsQueryRulesTest::testWithAnswersNullForNoClausecalls