mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02:00
Merge pull request #86 from open-sausages/pulls/2/report-transaction-nesting
API Support better transaction nesting
This commit is contained in:
commit
6cfc30952c
@ -547,16 +547,31 @@ class PostgreSQLDatabase extends Database
|
|||||||
|
|
||||||
public function transactionRollback($savepoint = false)
|
public function transactionRollback($savepoint = false)
|
||||||
{
|
{
|
||||||
|
// Named savepoint
|
||||||
if ($savepoint) {
|
if ($savepoint) {
|
||||||
$this->query('ROLLBACK TO ' . $savepoint);
|
$this->query('ROLLBACK TO ' . $savepoint);
|
||||||
} else {
|
return true;
|
||||||
--$this->transactionNesting;
|
|
||||||
if ($this->transactionNesting > 0) {
|
|
||||||
$this->transactionRollback('NESTEDTRANSACTION' . $this->transactionNesting);
|
|
||||||
} else {
|
|
||||||
$this->query('ROLLBACK');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Abort if unable to unnest, otherwise jump up a level
|
||||||
|
if (!$this->transactionNesting) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
--$this->transactionNesting;
|
||||||
|
|
||||||
|
// Rollback nested
|
||||||
|
if ($this->transactionNesting > 0) {
|
||||||
|
return $this->transactionRollback('NESTEDTRANSACTION' . $this->transactionNesting);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rollback top level
|
||||||
|
$this->query('ROLLBACK');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transactionDepth()
|
||||||
|
{
|
||||||
|
return $this->transactionNesting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transactionEnd($chain = false)
|
public function transactionEnd($chain = false)
|
||||||
|
Loading…
Reference in New Issue
Block a user