Skip to content

Commit 73b02f7

Browse files
committed
feat(IDBConnection): Add getTransactionIsolation and setTransactionIsolation
Signed-off-by: provokateurin <[email protected]>
1 parent 65d008b commit 73b02f7

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

lib/private/DB/ConnectionAdapter.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ class ConnectionAdapter implements IDBConnection {
2626
/** @var Connection */
2727
private $inner;
2828

29+
/**
30+
* The currently active transaction isolation level or NULL before it has been determined.
31+
*
32+
* @var \Doctrine\DBAL\TransactionIsolationLevel::*|null
33+
*/
34+
private ?int $transactionIsolationLevel = null;
35+
2936
public function __construct(Connection $inner) {
3037
$this->inner = $inner;
3138
}
@@ -262,4 +269,14 @@ public function getShardDefinition(string $name): ?ShardDefinition {
262269
public function getCrossShardMoveHelper(): CrossShardMoveHelper {
263270
return $this->inner->getCrossShardMoveHelper();
264271
}
272+
273+
public function setTransactionIsolation(int $level): int {
274+
$this->transactionIsolationLevel = $level;
275+
276+
return $this->executeStatement($this->getDatabasePlatform()->getSetTransactionIsolationSQL($level));
277+
}
278+
279+
public function getTransactionIsolation(): int {
280+
return $this->transactionIsolationLevel ??= $this->getDatabasePlatform()->getDefaultTransactionIsolationLevel();
281+
}
265282
}

lib/public/IDBConnection.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,4 +388,26 @@ public function getShardDefinition(string $name): ?ShardDefinition;
388388
* @since 30.0.0
389389
*/
390390
public function getCrossShardMoveHelper(): CrossShardMoveHelper;
391+
392+
/**
393+
* Sets the transaction isolation level.
394+
*
395+
* @param \Doctrine\DBAL\TransactionIsolationLevel::* $level The level to set.
396+
*
397+
* @throws \Doctrine\DBAL\Exception
398+
*
399+
* @since 33.0.0
400+
*/
401+
public function setTransactionIsolation(int $level): int;
402+
403+
/**
404+
* Gets the currently active transaction isolation level.
405+
*
406+
* @return \Doctrine\DBAL\TransactionIsolationLevel::* The current transaction isolation level.
407+
*
408+
* @throws \Doctrine\DBAL\Exception
409+
*
410+
* @since 33.0.0
411+
*/
412+
public function getTransactionIsolation(): int;
391413
}

0 commit comments

Comments
 (0)