commit 699c486c9c6dcd8f3afcd4c9f528b2711030b17b
Author: Damien Tournoud <damien@commerceguys.com>
Date:   Sun Jun 2 22:48:39 2013 +0200

    Unbreak SQLite.

diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
index 5aaf7da..768b8ca 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
@@ -229,7 +229,7 @@ public static function sqlFunctionSubstringIndex($string, $delimiter, $count) {
   /**
    * SQLite compatibility implementation for the RAND() SQL function.
    */
-  public function sqlFunctionRand($seed = NULL) {
+  public static function sqlFunctionRand($seed = NULL) {
     if (isset($seed)) {
       mt_srand($seed);
     }
@@ -243,24 +243,8 @@ public function sqlFunctionRand($seed = NULL) {
    * a Statement object, that will create a PDOStatement
    * using the semi-private PDOPrepare() method below.
    */
-  public function prepare($query, $options = array()) {
-    return new Statement($this, $query, $options);
-  }
-
-  /**
-   * NEVER CALL THIS FUNCTION: YOU MIGHT DEADLOCK YOUR PHP PROCESS.
-   *
-   * This is a wrapper around the parent PDO::prepare method. However, as
-   * the PDO SQLite driver only closes SELECT statements when the PDOStatement
-   * destructor is called and SQLite does not allow data change (INSERT,
-   * UPDATE etc) on a table which has open SELECT statements, you should never
-   * call this function and keep a PDOStatement object alive as that can lead
-   * to a deadlock. This really, really should be private, but as Statement
-   * needs to call it, we have no other choice but to expose this function to
-   * the world.
-   */
-  public function PDOPrepare($query, array $options = array()) {
-    return $this->connection->prepare($query, $options);
+  public function prepare($statement, array $driver_options = array()) {
+    return new Statement($this->connection, $this, $statement, $driver_options);
   }
 
   public function queryRange($query, $from, $count, array $args = array(), array $options = array()) {
@@ -312,10 +296,6 @@ public function mapConditionOperator($operator) {
     return isset($specials[$operator]) ? $specials[$operator] : NULL;
   }
 
-  public function prepareQuery($query) {
-    return $this->prepare($this->prefixTables($query));
-  }
-
   public function nextId($existing_id = 0) {
     $transaction = $this->startTransaction();
     // We can safely use literal queries here instead of the slower query
@@ -382,7 +362,7 @@ public function pushTransaction($name) {
       throw new TransactionNameNonUniqueException($name . " is already in use.");
     }
     if (!$this->inTransaction()) {
-      PDO::beginTransaction();
+      $this->connection->beginTransaction();
     }
     $this->transactionLayers[$name] = $name;
   }
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
index 531b6d0..b21d448 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php
@@ -16,10 +16,11 @@
 /**
  * Specific SQLite implementation of DatabaseConnection.
  *
- * See DatabaseConnection_sqlite::PDOPrepare() for reasons why we must prefetch
- * the data instead of using PDOStatement.
- *
- * @see DatabaseConnection_sqlite::PDOPrepare()
+ * The PDO SQLite driver only closes SELECT statements when the PDOStatement
+ * destructor is called and SQLite does not allow data change (INSERT,
+ * UPDATE etc) on a table which has open SELECT statements. This is a
+ * user-space mock of PDOStatement that buffers all the data and doesn't
+ * have those limitations.
  */
 class Statement extends StatementPrefetch implements Iterator, StatementInterface {
 
@@ -86,7 +87,7 @@ protected function getStatement($query, &$args = array()) {
       }
     }
 
-    return $this->dbh->PDOPrepare($query);
+    return $this->dbh->prepare($query);
   }
 
   public function execute($args = array(), $options = array()) {
diff --git a/core/lib/Drupal/Core/Database/StatementPrefetch.php b/core/lib/Drupal/Core/Database/StatementPrefetch.php
index e01f03a..ef1593c 100644
--- a/core/lib/Drupal/Core/Database/StatementPrefetch.php
+++ b/core/lib/Drupal/Core/Database/StatementPrefetch.php
@@ -124,8 +124,9 @@ class StatementPrefetch implements Iterator, StatementInterface {
     'column' => 0,
   );
 
-  public function __construct(Connection $connection, $query, array $driver_options = array()) {
-    $this->dbh = $connection;
+  public function __construct(PDO $dbh, Connection $connection, $query, array $driver_options = array()) {
+    $this->dbh = $dbh;
+    $this->connection = $connection;
     $this->queryString = $query;
     $this->driverOptions = $driver_options;
   }
@@ -153,7 +154,7 @@ public function execute($args = array(), $options = array()) {
       }
     }
 
-    $logger = $this->dbh->getLogger();
+    $logger = $this->connection->getLogger();
     if (!empty($logger)) {
       $query_start = microtime(TRUE);
     }
