classSetTransaction
final class SetTransaction
implements Statement
uses Snapshot
@visibility public.SET TRANSACTION: the isolation level and access mode of later transactions.
Rule: MYSQL-SET-TRANSACTION-001. Without a scope keyword the characteristics apply to the next transaction of the session only, and the statement is refused inside a transaction; with SESSION (or LOCAL) they apply to every later transaction of the session; with GLOBAL to later sessions; PERSIST and PERSIST_ONLY (8.0 and later) also persist the setting. One isolation level and one access mode can be written, in either order; the order is kept as written. The statement returns no rows and derives no facts. Terminates: a fixed list. Source: https://dev.mysql.com/doc/refman/8.4/en/set-transaction.html. Status: Implemented.
$set = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SET GLOBAL TRANSACTION READ ONLY, ISOLATION LEVEL SERIALIZABLE');
[$set->statement->scope, $set->statement->characteristics, $set->toString()] // => [\SqlSemantics\Platform\MySql\Statement\Variable\VariableScope::Global, [\SqlSemantics\Platform\MySql\Statement\Utility\Set\AccessMode::ReadOnly, \SqlSemantics\Platform\MySql\Statement\Utility\Set\IsolationLevel::Serializable], 'SET GLOBAL TRANSACTION READ ONLY, ISOLATION LEVEL SERIALIZABLE']Properties§
public non-empty-list<IsolationLevel|AccessMode> $characteristicspublic VariableScope|null $scope = nullMethods§
public function __construct(
array<array-key, object> $characteristics,
public VariableScope|null $scope = null,
)Parameters
$characteristics | array<array-key, object> | The characteristics in the order written, as a list of one or two IsolationLevel and AccessMode cases of different kinds |
$scope | VariableScope|null | The scope keyword, or null for the next transaction only |
Throws
InvalidConstruction When a characteristic is not an isolation level or an access modeCalls 4
- static-call Check::input() line 51
- function-call
array_is_listline 51 - function-call
countline 51 - new InvalidConstruction line 56
public function deriveStatement(Derivation $derivation): voidDerives nothing: the statement returns no rows and holds no expression.
Parameters
$derivation | Derivation |
public function render(Output $out): voidWrites SET, the scope, TRANSACTION and the characteristics separated by commas.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 77
- method-call Output::symbol() line 84
- function-call
explodeline 89
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.