Commit 561834cd authored by alexpott's avatar alexpott
Browse files

Issue #2465221 by amateescu: Raise the minimun version requirement for SQLite to 3.6.8

parent b75b691a
...@@ -9,9 +9,6 @@ ...@@ -9,9 +9,6 @@
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\Database\DatabaseNotFoundException; use Drupal\Core\Database\DatabaseNotFoundException;
use Drupal\Core\Database\TransactionNoActiveException;
use Drupal\Core\Database\TransactionNameNonUniqueException;
use Drupal\Core\Database\TransactionCommitFailedException;
use Drupal\Core\Database\Connection as DatabaseConnection; use Drupal\Core\Database\Connection as DatabaseConnection;
/** /**
...@@ -19,16 +16,6 @@ ...@@ -19,16 +16,6 @@
*/ */
class Connection extends DatabaseConnection { class Connection extends DatabaseConnection {
/**
* Whether this database connection supports savepoints.
*
* Version of sqlite lower then 3.6.8 can't use savepoints.
* See http://www.sqlite.org/releaselog/3_6_8.html
*
* @var bool
*/
protected $savepointSupport = FALSE;
/** /**
* Error code for "Unable to open database file" error. * Error code for "Unable to open database file" error.
*/ */
...@@ -90,10 +77,6 @@ public function __construct(\PDO $connection, array $connection_options) { ...@@ -90,10 +77,6 @@ public function __construct(\PDO $connection, array $connection_options) {
} }
// Regenerate the prefixes replacement table. // Regenerate the prefixes replacement table.
$this->setPrefix($prefixes); $this->setPrefix($prefixes);
// Detect support for SAVEPOINT.
$version = $this->query('SELECT sqlite_version()')->fetchField();
$this->savepointSupport = (version_compare($version, '3.6.8') >= 0);
} }
/** /**
...@@ -426,86 +409,4 @@ public function nextId($existing_id = 0) { ...@@ -426,86 +409,4 @@ public function nextId($existing_id = 0) {
return $this->query('SELECT value FROM {sequences}')->fetchField(); return $this->query('SELECT value FROM {sequences}')->fetchField();
} }
public function rollback($savepoint_name = 'drupal_transaction') {
if ($this->savepointSupport) {
return parent::rollBack($savepoint_name);
}
if (!$this->inTransaction()) {
throw new TransactionNoActiveException();
}
// A previous rollback to an earlier savepoint may mean that the savepoint
// in question has already been rolled back.
if (!isset($this->transactionLayers[$savepoint_name])) {
return;
}
// We need to find the point we're rolling back to, all other savepoints
// before are no longer needed.
while ($savepoint = array_pop($this->transactionLayers)) {
if ($savepoint == $savepoint_name) {
// Mark whole stack of transactions as needed roll back.
$this->willRollback = TRUE;
// If it is the last the transaction in the stack, then it is not a
// savepoint, it is the transaction itself so we will need to roll back
// the transaction rather than a savepoint.
if (empty($this->transactionLayers)) {
break;
}
return;
}
}
if ($this->supportsTransactions()) {
$this->connection->rollBack();
}
}
public function pushTransaction($name) {
if ($this->savepointSupport) {
return parent::pushTransaction($name);
}
if (!$this->supportsTransactions()) {
return;
}
if (isset($this->transactionLayers[$name])) {
throw new TransactionNameNonUniqueException($name . " is already in use.");
}
if (!$this->inTransaction()) {
$this->connection->beginTransaction();
}
$this->transactionLayers[$name] = $name;
}
public function popTransaction($name) {
if ($this->savepointSupport) {
return parent::popTransaction($name);
}
if (!$this->supportsTransactions()) {
return;
}
if (!$this->inTransaction()) {
throw new TransactionNoActiveException();
}
// Commit everything since SAVEPOINT $name.
while($savepoint = array_pop($this->transactionLayers)) {
if ($savepoint != $name) continue;
// If there are no more layers left then we should commit or rollback.
if (empty($this->transactionLayers)) {
// If there was any rollback() we should roll back whole transaction.
if ($this->willRollback) {
$this->willRollback = FALSE;
$this->connection->rollBack();
}
elseif (!$this->connection->commit()) {
throw new TransactionCommitFailedException();
}
}
else {
break;
}
}
}
} }
...@@ -10,24 +10,6 @@ ...@@ -10,24 +10,6 @@
use Drupal\Core\Database\Query\Delete as QueryDelete; use Drupal\Core\Database\Query\Delete as QueryDelete;
/** /**
* SQLite specific implementation of DeleteQuery. * SQLite specific implementation of \Drupal\Core\Database\Query\Delete.
*
* When the WHERE is omitted from a DELETE statement and the table being deleted
* has no triggers, SQLite uses an optimization to erase the entire table content
* without having to visit each row of the table individually.
*
* Prior to SQLite 3.6.5, SQLite does not return the actual number of rows deleted
* by that optimized "truncate" optimization.
*/ */
class Delete extends QueryDelete { class Delete extends QueryDelete { }
public function execute() {
if (!count($this->condition)) {
$total_rows = $this->connection->query('SELECT COUNT(*) FROM {' . $this->connection->escapeTable($this->table) . '}')->fetchField();
parent::execute();
return $total_rows;
}
else {
return parent::execute();
}
}
}
...@@ -33,8 +33,7 @@ public function name() { ...@@ -33,8 +33,7 @@ public function name() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function minimumVersion() { public function minimumVersion() {
// @todo Consider upping to 3.6.8 in Drupal 8 to get SAVEPOINT support. return '3.6.8';
return '3.3.7';
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment