mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02:00
Merge remote-tracking branch 'origin/2'
This commit is contained in:
commit
577988715f
@ -36,6 +36,11 @@ class PostgreSQLDatabase extends Database
|
||||
*/
|
||||
protected $schema;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $transactionNesting = 0;
|
||||
|
||||
/**
|
||||
* Toggle if transactions are supported. Defaults to true.
|
||||
*
|
||||
@ -519,6 +524,9 @@ class PostgreSQLDatabase extends Database
|
||||
|
||||
public function transactionStart($transaction_mode = false, $session_characteristics = false)
|
||||
{
|
||||
if ($this->transactionNesting > 0) {
|
||||
$this->transactionSavepoint('NESTEDTRANSACTION' . $this->transactionNesting);
|
||||
} else {
|
||||
$this->query('BEGIN;');
|
||||
|
||||
if ($transaction_mode) {
|
||||
@ -529,6 +537,8 @@ class PostgreSQLDatabase extends Database
|
||||
$this->query("SET SESSION CHARACTERISTICS AS TRANSACTION {$session_characteristics};");
|
||||
}
|
||||
}
|
||||
++$this->transactionNesting;
|
||||
}
|
||||
|
||||
public function transactionSavepoint($savepoint)
|
||||
{
|
||||
@ -538,16 +548,25 @@ class PostgreSQLDatabase extends Database
|
||||
public function transactionRollback($savepoint = false)
|
||||
{
|
||||
if ($savepoint) {
|
||||
$this->query("ROLLBACK TO {$savepoint};");
|
||||
$this->query('ROLLBACK TO ' . $savepoint);
|
||||
} else {
|
||||
$this->query('ROLLBACK;');
|
||||
--$this->transactionNesting;
|
||||
if ($this->transactionNesting > 0) {
|
||||
$this->transactionRollback('NESTEDTRANSACTION' . $this->transactionNesting);
|
||||
} else {
|
||||
$this->query('ROLLBACK');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function transactionEnd($chain = false)
|
||||
{
|
||||
--$this->transactionNesting;
|
||||
if ($this->transactionNesting <= 0) {
|
||||
$this->transactionNesting = 0;
|
||||
$this->query('COMMIT;');
|
||||
}
|
||||
}
|
||||
|
||||
public function comparisonClause($field, $value, $exact = false, $negate = false, $caseSensitive = null, $parameterised = false)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user