From 561834cd9f9b7609ce45e4cc6a6b1bd4a1dad6ab Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Sun, 12 Apr 2015 09:31:49 +0100 Subject: [PATCH] Issue #2465221 by amateescu: Raise the minimun version requirement for SQLite to 3.6.8 --- .../Database/Driver/sqlite/Connection.php | 99 ------------------- .../Core/Database/Driver/sqlite/Delete.php | 22 +---- .../Database/Driver/sqlite/Install/Tasks.php | 3 +- 3 files changed, 3 insertions(+), 121 deletions(-) diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php index a29c382bb313..8c1c8b8b50f0 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -9,9 +9,6 @@ use Drupal\Core\Database\Database; 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; /** @@ -19,16 +16,6 @@ */ 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. */ @@ -90,10 +77,6 @@ public function __construct(\PDO $connection, array $connection_options) { } // Regenerate the prefixes replacement table. $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) { 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; - } - } - } - } diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Delete.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Delete.php index c0056cbe3816..e75090e98210 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Delete.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Delete.php @@ -10,24 +10,6 @@ use Drupal\Core\Database\Query\Delete as QueryDelete; /** - * SQLite specific implementation of DeleteQuery. - * - * 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. + * SQLite specific implementation of \Drupal\Core\Database\Query\Delete. */ -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(); - } - } -} +class Delete extends QueryDelete { } diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php index 97eab5441ac8..89d4069548bb 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php @@ -33,8 +33,7 @@ public function name() { * {@inheritdoc} */ public function minimumVersion() { - // @todo Consider upping to 3.6.8 in Drupal 8 to get SAVEPOINT support. - return '3.3.7'; + return '3.6.8'; } /** -- GitLab