classCreateTableRule
final class CreateTableRule
Lowers CREATE TABLE in its column list, query and LIKE forms.
Rule: MYSQL-CREATE-TABLE-LOWERING-001. Scope: the create alternative CREATE opt_table_options TABLE_SYM …, create2, create2a, create3, opt_table_options, table_options, table_option (5.x); create_table_stmt, opt_create_table_options_etc, opt_create_partitioning_etc, opt_duplicate_as_qe, as_create_query_expression (8.0 and later). The word AS before the query and the parentheses around LIKE t change nothing. The partitioning clause comes from the table change family, the query from the query family and IGNORE or REPLACE from the data manipulation family. Constructs: CreateTable, CreateTableLike, TableQuery. Terminates: every child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/create-table.html, https://dev.mysql.com/doc/refman/5.7/en/create-table.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers the 5.x create alternative of CREATE TABLE.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 9
- static-call ImplementationGap::production() line 55
- method-call CreateTableRule::temporary() line 57
- method-call Form::node() line 57
- new TableOptionRule line 61
- method-call CreateTableRule::enclosed() line 65
- new CreateTable line 66
- method-call TableOptionRule::options() line 66
- method-call CreateTableRule::legacyQuery() line 66
- new CreateTableLike line 67
public function enclosed(
QualifiedName $name,
Form $form,
int $temporary,
bool $exists,
): CreateTableLowers the 5.x forms that open a parenthesis after the table name: a column list, or a query.
Parameters
$name | QualifiedName | |
$form | Form | |
$temporary | int | |
$exists | bool |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 2
Called from 1
Calls 10
- new CreateTable line 83
- method-call ElementRule::elements() line 85
- new ElementRule line 85
- method-call Form::node() line 85
- method-call TableOptionRule::options() line 86
- new TableOptionRule line 86
- method-call CreateTableRule::legacyQuery() line 88
- method-call CreateTableRule::partitioned() line 92
- new TableQuery line 92
- static-call ImplementationGap::production() line 93
public function partitioned(
QualifiedName $name,
?Partitioning $partitioning,
TableQuery $query,
int $temporary,
bool $exists,
): CreateTableBuilds CREATE TABLE ... SELECT whose query is written in parentheses, with the partitioning inside them when one is written.
Parameters
$name | QualifiedName | |
$partitioning | ?Partitioning | |
$query | TableQuery | |
$temporary | int | |
$exists | bool |
Returns
Called from 1
Calls 1
- new CreateTable line 102
public function temporary(Node $options): intCounts the TEMPORARY words of 5.x: a node of opt_table_options.
Parameters
$options | Node |
Returns
intThrows
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 3
- static-call ImplementationGap::production() line 117
- method-call Spine::items() line 120
- new Spine line 120
public function legacyQuery(Node $part): ?TableQueryLowers the 5.x query part: a node of create3; none is null.
Parameters
$part | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\CreateTableRule::legacy() packages/sql-semantics-mysql/src/Lowering/TableDefinition/CreateTableRule.php:66
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\CreateTableRule::enclosed() packages/sql-semantics-mysql/src/Lowering/TableDefinition/CreateTableRule.php:88
Calls 2
- new TableQuery line 144
- static-call ImplementationGap::production() line 146
Lowers CREATE TABLE of MySQL 8.0 and later: a node of create_table_stmt.
Parameters
$statement | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 5
- method-call CreateTableRule::rest() line 163
- method-call ElementRule::elements() line 163
- new ElementRule line 163
- new CreateTableLike line 165
- static-call ImplementationGap::production() line 167
public function rest(
QualifiedName $name,
list<TableElement> $elements,
Node $rest,
int $temporary,
bool $exists,
): CreateTableLowers the options, partitioning and query after the 8.0 element list: a node of opt_create_table_options_etc.
Parameters
$name | QualifiedName | |
$elements | list<TableElement> | The elements already lowered |
$rest | Node | |
$temporary | int | |
$exists | bool |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\CreateTableRule::modern() packages/sql-semantics-mysql/src/Lowering/TableDefinition/CreateTableRule.php:163
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\CreateTableRule::modern() packages/sql-semantics-mysql/src/Lowering/TableDefinition/CreateTableRule.php:164
Calls 5
- method-call TableOptionRule::options() line 181
- new TableOptionRule line 181
- static-call ImplementationGap::production() line 183
- new CreateTable line 192
- method-call CreateTableRule::query() line 192
public function query(Node $part): ?TableQueryLowers the 8.0 query part: a node of opt_duplicate_as_qe; none is null.
Parameters
$part | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 2
- static-call ImplementationGap::production() line 207
- new TableQuery line 214
Private surface 1§
Implementation details, listed for orientation only.
private Lowering $loweringTest cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
CreateTableRuleTest::testEnclosedLowersAColumnListcallsCreateTableRuleTest::testLegacyLowersTheLikeFormcallsCreateTableRuleTest::testLegacyQueryLowersTheQueryPartcallsCreateTableRuleTest::testModernLowersCreateTablecallsCreateTableRuleTest::testPartitionedBuildsTheQueryFormcallsCreateTableRuleTest::testQueryLowersTheQueryPartcallsCreateTableRuleTest::testRestLowersOptionsPartitioningAndQuerycallsCreateTableRuleTest::testTemporaryCountsTheTemporaryWordscalls
Relations§
Instantiated in 2
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::statement() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:51
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:71
Method calls 2
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::statement() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:51
- method-call SqlSemantics\Platform\MySql\Lowering\TableDefinition\TableDefinitionRules::definition() packages/sql-semantics-mysql/src/Lowering/TableDefinition/TableDefinitionRules.php:71