diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index 4a5f404..0894d9c 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -468,7 +468,20 @@ protected function createPrimaryKeySql($fields) {
   public function tableExists($table) {
     $prefixInfo = $this->getPrefixInfo($table, TRUE);

-    return (bool) $this->connection->query("SELECT 1 FROM pg_tables WHERE schemaname = :schema AND tablename = :table", array(':schema' => $prefixInfo['schema'], ':table' => $prefixInfo['table']))->fetchField();
+    $this->connection->addSavepoint();
+
+    try {
+      // The existence of a table can be found in pg_catalog, which is
+      // significantly faster than querying the information_schema.
+      $result = (bool) $this->connection->query("SELECT 1 FROM pg_catalog.pg_class c INNER JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) WHERE n.nspname = :schema AND c.relkind = 'r' AND relname = :table", array(':schema' => $prefixInfo['schema'], ':table' => $prefixInfo['table']))->fetchField();
+    }
+    catch (\Exception $e) {
+      $this->connection->rollbackSavepoint();
+      return FALSE;
+    }
+
+    $this->connection->releaseSavepoint();
+    return $result;
   }

   function renameTable($table, $new_name) {
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
index 4b954ed..b433909 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
@@ -25,8 +25,19 @@ class Schema extends DatabaseSchema {
   public function tableExists($table) {
     $info = $this->getPrefixInfo($table);

-    // Don't use {} around sqlite_master table.
-    return (bool) $this->connection->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', array(':type' => 'table', ':name' => $info['table']))->fetchField();
+    $this->connection->addSavepoint();
+
+    try {
+      // Don't use {} around sqlite_master table.
+      $result = (bool) $this->connection->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', array(':type' => 'table', ':name' => $info['table']))->fetchField();
+    }
+    catch (\Exception $e) {
+      $this->connection->rollbackSavepoint();
+      return FALSE;
+    }
+
+    $this->connection->releaseSavepoint();
+    return $result;
   }

   public function fieldExists($table, $column) {
diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php
index 8b9eb7e..e9d7f53 100644
--- a/core/lib/Drupal/Core/Database/Schema.php
+++ b/core/lib/Drupal/Core/Database/Schema.php
@@ -163,12 +163,19 @@ protected function buildTableNameCondition($table_name, $operator = '=', $add_pr
   public function tableExists($table) {
     $condition = $this->buildTableNameCondition($table);
     $condition->compile($this->connection, $this);
-    // Normally, we would heartily discourage the use of string
-    // concatenation for conditionals like this however, we
-    // couldn't use db_select() here because it would prefix
-    // information_schema.tables and the query would fail.
-    // Don't use {} around information_schema.tables table.
-    return (bool) $this->connection->query("SELECT 1 FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchField();
+
+    $this->connection->addSavepoint();
+
+    try {
+      $result = (bool) $this->connection->query("SELECT 1 FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchField();
+    }
+    catch (\Exception $e) {
+      $this->connection->rollbackSavepoint();
+      return FALSE;
+    }
+
+    $this->connection->releaseSavepoint();
+    return $result;
   }

   /**
