final class SetTransaction
    implements Statement
    uses Snapshot
Public API: explicitly declared with @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.

Reading the characteristicsdoctest
$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> $characteristics
public VariableScope|null $scope = null

Methods§

public function __construct(
    array<array-key, object> $characteristics,
    public VariableScope|null $scope = null,
)

Parameters

$characteristicsarray<array-key, object>The characteristics in the order written, as a list of one or two IsolationLevel and AccessMode cases of different kinds
$scopeVariableScope|nullThe scope keyword, or null for the next transaction only

Throws

InvalidConstruction When a characteristic is not an isolation level or an access mode
Calls 4
public function deriveStatement(Derivation $derivation): void

Derives nothing: the statement returns no rows and holds no expression.

Parameters

$derivationDerivation
public function render(Output $out): void

Writes SET, the scope, TRANSACTION and the characteristics separated by commas.

Parameters

$outOutput
Calls 3

Test cases 2§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 2

Relations§

Instantiated in 2