classInsertRule
final class InsertRule
Lowers INSERT and REPLACE of every release.
Rule: MYSQL-INSERT-LOWERING-001. Scope: insert, replace, insert2, insert_table, table_name_with_opt_use_partition (5.6); insert_stmt, replace_stmt, opt_INTO (5.7 and later); insert_lock_option, replace_lock_option, opt_low_priority, opt_insert_update, opt_insert_update_list, opt_values_reference. The head becomes InsertInto; the source decides the statement class: rows of VALUES (InsertRows), SET assignments (InsertSet) or a query (InsertQuery). INTO is optional and has no meaning (DmlNoise). Terminates: the parts are strict subtrees. Source: https://dev.mysql.com/doc/refman/8.4/en/insert.html, https://dev.mysql.com/doc/refman/8.4/en/replace.html, https://dev.mysql.com/doc/refman/5.6/en/insert.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers a node of insert_stmt or replace_stmt.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 15
- class-const InsertRule::LAYOUTS() line 85
- static-call ImplementationGap::production() line 85
- method-call Lowering::form() line 87
- method-call Form::node() line 87
- new WriteTarget line 91
- method-call InsertRule::priority() line 92
- method-call InsertRule::alias() line 94
- method-call InsertRule::updates() line 95
- method-call InsertSourceRule::source() line 97
- new InsertSourceRule line 97
- method-call InsertRule::build() line 99
- new InsertInto line 99
- new InsertSet line 102
- method-call ValueRule::assignments() line 102
- new ValueRule line 102
Lowers a node of insert or replace (5.6).
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 13
- static-call ImplementationGap::production() line 114
- method-call InsertRule::target() line 117
- method-call Form::node() line 117
- method-call InsertRule::priority() line 118
- method-call InsertRule::updates() line 120
- method-call Lowering::form() line 121
- new InsertSet line 123
- new InsertInto line 123
- method-call ValueRule::assignments() line 123
- new ValueRule line 123
- method-call InsertSourceRule::source() line 125
- new InsertSourceRule line 125
- method-call InsertRule::build() line 127
public function build(
InsertInto $into,
list<InsertedRow>|Query $body,
?RowAlias $alias,
list<Assignment> $updates,
): StatementBuilds the statement of rows or of a query.
Parameters
$into | InsertInto | |
$body | list<InsertedRow>|Query | |
$alias | ?RowAlias | |
$updates | list<Assignment> |
Returns
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:99
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::legacy() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:127
Calls 2
- new InsertQuery line 139
- new InsertRows line 142
public function target(Node $insert2): WriteTargetLowers the table of a node of insert2 (5.6).
Parameters
$insert2 | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 3
- method-call Lowering::form() line 152
- static-call ImplementationGap::production() line 156
- new WriteTarget line 166
public function priority(Node $option): ?InsertPriorityLowers a node of insert_lock_option or replace_lock_option.
Parameters
$option | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:92
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::legacy() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:118
Calls 4
- method-call Lowering::form() line 176
- function-call
array_key_existsline 180 - class-const InsertRule::PRIORITIES() line 180
- static-call ImplementationGap::production() line 181
Lowers a node of opt_values_reference; an absent alias is null.
Parameters
$reference | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 3
- method-call Lowering::form() line 194
- new RowAlias line 198
- static-call ImplementationGap::production() line 199
public function updates(Node $clause): list<Assignment>Lowers a node of opt_insert_update or opt_insert_update_list; an absent clause is empty.
Parameters
$clause | Node |
Returns
list<Assignment>Throws
ImplementationGap When a production has no ruleCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:95
- method-call SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::legacy() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:120
Calls 4
- method-call Lowering::form() line 211
- method-call ValueRule::assignments() line 216
- new ValueRule line 216
- static-call ImplementationGap::production() line 217
Private surface 3§
Implementation details, listed for orientation only.
private const LAYOUTS = ['insert_stmt: INSERT insert_lock_option opt_ignore opt_INTO table_ident opt_us…private const PRIORITIES = ['insert_lock_option:' => null, 'insert_lock_option: LOW_PRIORITY' => \SqlSeman…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
InsertRuleTestcalls