classTableRule
final class TableRule
Lowers the parts of a named table reference shared by every grammar generation.
Rule: MYSQL-TABLE-PARTS-001. Scope: single_table and the 5.x table_factor of a named table, opt_use_partition, use_partition, using_list, opt_table_alias, table_alias, opt_key_definition, opt_index_hints_list, index_hints_list, index_hint_definition, index_hint_type, index_hint_clause, opt_key_usage_list, key_usage_list, key_usage_element, opt_derived_column_list, simple_ident_list, opt_tablesample_clause, sampling_method, sampling_percentage. KEY and INDEX in an index hint are synonyms (the writer emits INDEX); PRIMARY names the primary key. Constructs: TableReference, IndexHint, PrimaryIndex, TableSample. Terminates: lists are flattened iteratively. Source: https://dev.mysql.com/doc/refman/8.4/en/join.html, https://dev.mysql.com/doc/refman/8.4/en/index-hints.html, https://dev.mysql.com/doc/refman/8.4/en/partitioning-selection.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function table(Node $table): TableReferenceLowers a named table with its partitions, alias, index hints and sampling clause.
Parameters
$table | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::factor() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:72
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::factor() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:54
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:73
Calls 12
- method-call Lowering::form() line 75
- class-const TableRule::TABLES() line 76
- static-call ImplementationGap::production() line 77
- new TableReference line 84
- method-call TableRule::alias() line 86
- method-call TableRule::partitions() line 87
- method-call TableRule::hints() line 88
- function-call
countline 89 - method-call TableRule::sample() line 89
- method-call TableRule::mark() line 90
- class-const OptionalWords::Written() line 91
- class-const OptionalWords::Omitted() line 91
Lowers an explicit partition selection; an absent selection is empty.
Parameters
$selection | Node |
Returns
list<Name>Throws
ImplementationGap When a production has no ruleCalled from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::partitions() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:209
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\TableRule::table() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TableRule.php:87
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\TableRule::partitions() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TableRule.php:110
Calls 4
- method-call Lowering::form() line 103
- method-call TableRule::partitions() line 110
- method-call TableRule::names() line 111
- static-call ImplementationGap::production() line 112
Lowers a comma-separated list of identifiers: using_list or simple_ident_list.
Parameters
$list | Node |
Returns
list<Name>Throws
ImplementationGap When a production has no ruleCalled from 4
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\JoinRule::step() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/JoinRule.php:177
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ReferenceRule::step() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ReferenceRule.php:129
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\TableRule::partitions() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TableRule.php:111
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\TableRule::columns() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TableRule.php:151
Calls 5
- method-call Lowering::form() line 124
- function-call
in_arrayline 128 - static-call ImplementationGap::production() line 129
- method-call Lists::items() line 132
- new Lists line 132
Lowers the column names of a derived table or common table expression; an absent list is empty.
Parameters
$list | Node |
Returns
list<Name>Throws
ImplementationGap When a production has no ruleCalled from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::with() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:174
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::columnAliases() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:241
Calls 3
- method-call Lowering::form() line 147
- method-call TableRule::names() line 151
- static-call ImplementationGap::production() line 152
Lowers an optional table alias; no alias is null.
Parameters
$alias | Node |
Returns
?NameThrows
ImplementationGap When a production has no ruleCalled from 5
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:98
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::function() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:115
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::alias() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:219
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\TableRule::table() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TableRule.php:86
Calls 3
- method-call Lowering::form() line 163
- function-call
in_arrayline 166 - static-call ImplementationGap::production() line 167
Answers what is written before an optional table alias; no alias answers AS, the mark of a table without alias.
Parameters
$alias | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 5
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:125
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::function() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:116
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::mark() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:229
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\TableRule::table() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TableRule.php:90
Calls 5
- method-call Lowering::form() line 187
- class-const AliasMark::As() line 189
- static-call ImplementationGap::production() line 192
- class-const AliasMark::Bare() line 197
- class-const AliasMark::Equals() line 199
Lowers the index hints of a table in written order.
Parameters
$list | Node |
Returns
list<IndexHint>Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 5
- method-call Lowering::form() line 212
- static-call ImplementationGap::production() line 217
- method-call Lists::items() line 224
- new Lists line 224
- method-call TableRule::hint() line 225
Lowers one index hint.
Parameters
$definition | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 9
- method-call Lowering::form() line 238
- class-const IndexHintAction::Use() line 240
- class-const IndexHintAction::Force() line 244
- class-const IndexHintAction::Ignore() line 245
- static-call ImplementationGap::production() line 246
- function-call
array_key_existsline 253 - class-const TableRule::SCOPES() line 253
- new IndexHint line 257
- method-call TableRule::indexes() line 257
public function indexes(Node $list): list<Name|PrimaryIndex>Lowers a list of index names, where PRIMARY names the primary key; an absent list is empty.
Parameters
$list | Node |
Returns
list<Name|PrimaryIndex>Throws
ImplementationGap When a production has no ruleCalled from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::indexKeys() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:291
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\TableRule::hint() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TableRule.php:257
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\TableRule::indexes() packages/sql-semantics-mysql/src/Lowering/Query/Shared/TableRule.php:273
Calls 6
- method-call Lowering::form() line 268
- method-call TableRule::indexes() line 273
- static-call ImplementationGap::production() line 276
- method-call Lists::items() line 279
- new Lists line 279
- new PrimaryIndex line 283
public function sample(Node $clause): ?TableSampleLowers a TABLESAMPLE clause; an absent clause is null.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 5
- method-call Lowering::form() line 298
- static-call ImplementationGap::production() line 303
- new TableSample line 308
- class-const SamplingMethod::System() line 309
- class-const SamplingMethod::Bernoulli() line 310
Private surface 3§
Implementation details, listed for orientation only.
private const TABLES = ['single_table: table_ident opt_use_partition opt_table_alias opt_key_definitio…private const SCOPES = ['index_hint_clause:' => null, 'index_hint_clause: FOR_SYM JOIN_SYM' => \SqlSem…private Lowering $loweringTest cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
TableRuleTestcalls
Relations§
Instantiated in 16
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::factor() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:72
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:98
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:125
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\JoinRule::step() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/JoinRule.php:177
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::factor() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:54
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:73
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:94
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::function() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:115
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::function() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:116
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::with() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:174
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ReferenceRule::step() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ReferenceRule.php:129
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::partitions() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:209
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::alias() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:219
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::mark() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:229
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::columnAliases() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:241
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::indexKeys() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:291
Method calls 18
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::factor() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:72
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:98
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:125
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\JoinRule::step() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/JoinRule.php:177
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::factor() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:54
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::parens() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:73
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::function() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:115
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\FactorRule::function() packages/sql-semantics-mysql/src/Lowering/Query/Modern/FactorRule.php:116
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::with() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:174
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ReferenceRule::step() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ReferenceRule.php:129
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::partitions() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:209
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::alias() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:219
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::mark() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:229
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::columnAliases() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:241
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::indexKeys() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:291