diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index 8fe1c45..3e73b49 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -161,7 +161,7 @@
       $target = 'default';
     }
 
-    if (!isset(self::$connections[$key][$target])) {
+    if (!isset(self::$connections[$key][$target]) || self::$connections[$key][$target] === NULL) {
       // If necessary, a new connection is opened.
       self::$connections[$key][$target] = self::openConnection($key, $target);
     }
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
index f081eff..c1cb885 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
@@ -49,6 +49,20 @@ class Connection extends DatabaseConnection {
   ];
 
   /**
+   * The actual PDO object.
+   *
+   * @var \PDO
+   */
+  private $actualConnection;
+
+  /**
+   * A reference to the actual PDO object.
+   *
+   * @var \PDO
+   */
+  protected $connection;
+
+  /**
    * The list of PostgreSQL reserved key words.
    *
    * @see http://www.postgresql.org/docs/9.4/static/sql-keywords-appendix.html
@@ -75,6 +89,9 @@ class Connection extends DatabaseConnection {
   public function __construct(\PDO $connection, array $connection_options) {
     parent::__construct($connection, $connection_options);
 
+    $this->actualConnection = $connection;
+    $this->connection = &$this->actualConnection;
+
     // This driver defaults to transaction support, except if explicitly passed FALSE.
     $this->transactionSupport = !isset($connection_options['transactions']) || ($connection_options['transactions'] !== FALSE);
 
@@ -157,6 +174,21 @@ public static function open(array &$connection_options = array()) {
   /**
    * {@inheritdoc}
    */
+  public function destroy() {
+    // Destroy the reference to this connection.
+    unset($this->connection);
+
+    // The Statement class attribute only accepts a new value that presents a
+    // proper callable, so we reset it to PDOStatement.
+    if (!empty($this->statementClass)) {
+      $this->actualConnection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array()));
+    }
+    $this->schema = NULL;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public function query($query, array $args = array(), $options = array()) {
     $options += $this->defaultOptions();
 
