FIX Add nested transaction support

This commit is contained in:
Daniel Hensby 2018-02-09 11:24:35 +00:00
parent e8f4e55b8a
commit f176bb0a39
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E

View File

@ -50,6 +50,11 @@ class SQLite3Database extends Database
*/
protected $livesInMemory = false;
/**
* @var bool
*/
protected $transactionNesting = 0;
/**
* List of default pragma values
*
@ -448,7 +453,12 @@ class SQLite3Database extends Database
public function transactionStart($transaction_mode = false, $session_characteristics = false)
{
$this->query('BEGIN');
if ($this->transactionNesting > 0) {
$this->transactionSavepoint('NESTEDTRANSACTION' . $this->transactionNesting);
} else {
$this->query('BEGIN');
}
++$this->transactionNesting;
}
public function transactionSavepoint($savepoint)
@ -461,13 +471,22 @@ class SQLite3Database extends Database
if ($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->query('COMMIT;');
--$this->transactionNesting;
if ($this->transactionNesting <= 0) {
$this->transactionNesting = 0;
$this->query('COMMIT;');
}
}
public function clearTable($table)