API Support better transaction nesting

This commit is contained in:
Damian Mooyman 2018-06-19 16:17:43 +12:00
parent 01cc78ec94
commit e0d5536715
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A

View File

@ -547,16 +547,31 @@ class PostgreSQLDatabase extends Database
public function transactionRollback($savepoint = false)
{
// Named savepoint
if ($savepoint) {
$this->query('ROLLBACK TO ' . $savepoint);
} else {
return true;
}
// Abort if unable to unnest, otherwise jump up a level
if (!$this->transactionNesting) {
return false;
}
--$this->transactionNesting;
// Rollback nested
if ($this->transactionNesting > 0) {
$this->transactionRollback('NESTEDTRANSACTION' . $this->transactionNesting);
} else {
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)