classFactorRule
final class FactorRule
Lowers the table factors of the 5.x grammars, where one rule writes both derived tables and nested joins.
Rule: MYSQL-FACTOR-LEGACY-001. Scope: table_factor (5.x), select_derived_union, select_derived, select_derived_init. Parentheses whose content is a single SELECT, with its union, ORDER BY and LIMIT, are a derived table under the alias after them; without alias, directly inside further parentheses that carry one, they are a parenthesized query of that derived table. Parentheses around other references are a nested join, which takes no alias, union, ORDER BY or LIMIT; a SELECT anywhere else among table references is not inside parentheses. The server rejects those forms with ER_SYNTAX_ERROR while parsing, before any name is resolved: the actions of table_factor, select_derived_union and select_derived_init in sql_yacc.yy of 5.6 and the contextualize() of PT_table_factor_select_sym, PT_table_factor_parenthesis and PT_select_derived_union_* in sql/parse_tree_nodes of 5.7. Constructs: DerivedTable, NestedRelation, TableList, ParenthesizedQuery. Terminates: the union is walked in a loop; recursion follows nested parentheses. Source: https://dev.mysql.com/doc/refman/5.7/en/derived-tables.html, https://dev.mysql.com/doc/refman/5.7/en/join.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers a 5.x table factor.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleAnalysisException When a SELECT is not the first reference inside parentheses ("we are not in parentheses": ER_SYNTAX_ERROR of the 5.6 `select_derived_init` action and of 5.7 `PT_table_factor_select_sym::contextualize`)Called from 1
Calls 5
- method-call TableRule::table() line 72
- new TableRule line 72
- new AnalysisException line 75
- method-call FactorRule::parens() line 77
- new DerivedTable line 79
Lowers a parenthesized 5.x table factor: a query when it is a derived table without alias, else the relation.
Parameters
$form | Form |
Throws
ImplementationGap When a production has no ruleAnalysisException When a nested join has an alias, a union, an ORDER BY or a LIMIT (ER_SYNTAX_ERROR of the 5.6 `table_factor` and `select_derived_union` actions and of 5.7 `PT_table_factor_parenthesis` and `PT_select_derived_union_*::contextualize`)Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::factor() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:77
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::content() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:164
Calls 23
- method-call Form::node() line 91
- static-call ImplementationGap::production() line 96
- method-call TableRule::alias() line 98
- new TableRule line 98
- method-call Lowering::form() line 100
- class-const FactorRule::UNIONS() line 101
- method-call ExpressionRule::quantifier() line 102
- new ExpressionRule line 102
- method-call SubqueryRule::operand() line 102
- new SubqueryRule line 102
- method-call UnionRule::ordering() line 108
- new UnionRule line 108
- method-call FactorRule::content() line 109
- function-call
is_arrayline 110 - new AnalysisException line 112
- new NestedRelation line 115
- function-call
countline 115 - new TableList line 115
- function-call
array_reverseline 119 - method-call Chain::query() line 123
- new Chain line 123
- new DerivedTable line 125
- method-call TableRule::mark() line 125
Lowers the content of 5.x parentheses: the query block of a derived table, the query of an inner derived table without alias, or the references of a nested join.
Parameters
$derived | Node |
Throws
ImplementationGap When a production has no ruleAnalysisException When a nested join has an alias or a unionCalled from 1
Calls 13
- method-call Lowering::form() line 137
- static-call ImplementationGap::production() line 144
- method-call FactorRule::single() line 146
- method-call JoinRule::list() line 148
- new JoinRule line 148
- new ItemRule line 151
- method-call BlockRule::expression() line 153
- new BlockRule line 153
- method-call ItemRule::options() line 153
- method-call ItemRule::items() line 153
- method-call BlockRule::derived() line 162
- method-call FactorRule::parens() line 164
- new ParenthesizedQuery line 166
Answers the table factor a reference list consists of when it is a single parenthesized or SELECT factor, else null.
Parameters
$list | Node |
Returns
?FormCalled from 1
Calls 1
- method-call Lowering::form() line 174
Private surface 2§
Implementation details, listed for orientation only.
private const UNIONS = ['select_derived_union: select_derived_union UNION_SYM union_option query_speci…private Lowering $loweringTest cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
FactorRuleTestcallsFactorRuleTestcalls