classTransactionRule
final class TransactionRule
Lowers the transaction statements: BEGIN, START TRANSACTION, COMMIT, ROLLBACK and the savepoint statements.
Rule: MYSQL-TRANSACTION-001. Scope: begin (5.6, 5.7), begin_stmt (8.0 and later), start, opt_start_transaction_option_list, start_transaction_option_list, start_transaction_option, commit, rollback, savepoint, release, opt_work, opt_chain, opt_release, opt_savepoint. WORK and the SAVEPOINT of ROLLBACK TO are optional words (ServerNoise). READ ONLY with READ WRITE in START TRANSACTION, and AND CHAIN with RELEASE in COMMIT or ROLLBACK, are syntax errors the server raises in the grammar actions (sql_yacc.yy start, commit, rollback) and are rejected as such. Constructs: Begin, StartTransaction, Commit, Rollback, RollbackToSavepoint, Savepoint, ReleaseSavepoint. Terminates: the option list is flattened iteratively. Source: https://dev.mysql.com/doc/refman/8.4/en/commit.html, https://dev.mysql.com/doc/refman/8.4/en/savepoint.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers a transaction statement.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleAnalysisException When the statement requests choices that exclude each otherCalled from 1
Calls 8
- method-call TransactionRule::begin() line 85
- method-call Form::node() line 85
- method-call TransactionRule::start() line 86
- method-call TransactionRule::completion() line 87
- method-call TransactionRule::rollbackTo() line 89
- new Savepoint line 90
- new ReleaseSavepoint line 91
- static-call ImplementationGap::production() line 92
Lowers BEGIN [WORK].
Parameters
$work | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 2
- method-call TransactionRule::word() line 103
- new Begin line 105
public function start(Node $options): StartTransactionLowers START TRANSACTION from its option list: a node of opt_start_transaction_option_list.
Parameters
$options | Node |
Returns
Throws
ImplementationGap When a production has no ruleAnalysisException When READ ONLY and READ WRITE are both writtenCalled from 1
Calls 10
- method-call Lowering::form() line 116
- method-call Lists::items() line 123
- new Lists line 123
- class-const TransactionRule::CHARACTERISTICS() line 125
- static-call ImplementationGap::production() line 125
- function-call
in_arrayline 130 - class-const TransactionCharacteristic::ReadOnly() line 130
- class-const TransactionCharacteristic::ReadWrite() line 130
- new AnalysisException line 131
- new StartTransaction line 134
Lowers COMMIT or ROLLBACK with their completion choices.
Parameters
$form | Form | |
$commit | bool |
Throws
ImplementationGap When a production has no ruleAnalysisException When AND CHAIN and RELEASE are both writtenCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Server\Transaction\TransactionRule::statement() packages/sql-semantics-mysql/src/Lowering/Server/Transaction/TransactionRule.php:87
- method-call SqlSemantics\Platform\MySql\Lowering\Server\Transaction\TransactionRule::statement() packages/sql-semantics-mysql/src/Lowering/Server/Transaction/TransactionRule.php:88
Calls 6
- method-call TransactionRule::word() line 145
- method-call Form::node() line 145
- method-call TransactionRule::choice() line 146
- new AnalysisException line 149
- new Commit line 152
- new Rollback line 152
public function rollbackTo(Form $form): RollbackToSavepointLowers ROLLBACK TO SAVEPOINT.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 3
- method-call TransactionRule::word() line 162
- method-call Form::node() line 162
- new RollbackToSavepoint line 165
public function choice(Node $choice): ?boolLowers a completion choice: a node of opt_chain or opt_release.
Parameters
$choice | Node |
Returns
?boolThrows
ImplementationGap When a production has no ruleCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Server\Transaction\TransactionRule::completion() packages/sql-semantics-mysql/src/Lowering/Server/Transaction/TransactionRule.php:146
- method-call SqlSemantics\Platform\MySql\Lowering\Server\Transaction\TransactionRule::completion() packages/sql-semantics-mysql/src/Lowering/Server/Transaction/TransactionRule.php:147
Calls 4
- method-call Lowering::form() line 175
- function-call
array_key_existsline 176 - class-const TransactionRule::COMPLETIONS() line 176
- static-call ImplementationGap::production() line 177
public function word(Node $word): voidConfirms an optional word that holds no operand: a node of opt_work or opt_savepoint.
Parameters
$word | Node |
Throws
ImplementationGap When a production has no ruleCalled from 4
- method-call SqlSemantics\Platform\MySql\Lowering\Server\Transaction\TransactionRule::begin() packages/sql-semantics-mysql/src/Lowering/Server/Transaction/TransactionRule.php:103
- method-call SqlSemantics\Platform\MySql\Lowering\Server\Transaction\TransactionRule::completion() packages/sql-semantics-mysql/src/Lowering/Server/Transaction/TransactionRule.php:145
- method-call SqlSemantics\Platform\MySql\Lowering\Server\Transaction\TransactionRule::rollbackTo() packages/sql-semantics-mysql/src/Lowering/Server/Transaction/TransactionRule.php:162
- method-call SqlSemantics\Platform\MySql\Lowering\Server\Transaction\TransactionRule::rollbackTo() packages/sql-semantics-mysql/src/Lowering/Server/Transaction/TransactionRule.php:163
Calls 3
- method-call Lowering::form() line 190
- class-const TransactionRule::WORDS() line 191
- static-call ImplementationGap::production() line 192
Private surface 4§
Implementation details, listed for orientation only.
private const CHARACTERISTICS = ['start_transaction_option: WITH CONSISTENT_SYM SNAPSHOT_SYM' => \SqlSemantics\…private const COMPLETIONS = ['opt_chain:' => null, 'opt_chain: AND_SYM NO_SYM CHAIN_SYM' => false, 'opt_cha…private const WORDS = ['opt_work:' => true, 'opt_work: WORK_SYM' => true, 'opt_savepoint:' => true, '…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
TransactionRuleTestcalls