final class FactorRule
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql\Lowering\Query". Code outside that scope must not name this declaration.

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

$loweringLoweringThe lowering this rule belongs to
public function factor(Form $form): Relation

Lowers a 5.x table factor.

Parameters

$formForm

Returns

Throws

ImplementationGap When a production has no rule
AnalysisException 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
public function parens(Form $form): Query|Relation

Lowers a parenthesized 5.x table factor: a query when it is a derived table without alias, else the relation.

Parameters

$formForm

Throws

ImplementationGap When a production has no rule
AnalysisException 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
Calls 23
public function content(Node $derived): Block|Query|list<Relation>

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

$derivedNode

Returns

Throws

ImplementationGap When a production has no rule
AnalysisException When a nested join has an alias or a union
Called from 1
Calls 13
public function single(Node $list): ?Form

Answers the table factor a reference list consists of when it is a single parenthesized or SELECT factor, else null.

Parameters

$listNode

Returns

Called from 1
Calls 1

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 $lowering

Test cases 2§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 2

Relations§

Instantiated in 1
Method calls 1