diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index b1aa8f7..171bd48 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -139,6 +139,20 @@ public function queryTableInformation($table) {
   }
 
   /**
+   * Resets information about table blobs, sequences and serial fields.
+   *
+   * @param $table
+   *   The non-prefixed name of the table.
+   */
+  protected function resetTableInformation($table) {
+    $key = $this->connection->prefixTables('{' . $table . '}');
+    if (!strpos($key, '.')) {
+      $key = 'public.' . $key;
+    }
+    unset($this->tableInformation[$key]);
+  }
+
+  /**
    * Fetch the list of CHECK constraints used on a field.
    *
    * We introspect the database to collect the information required by field
@@ -421,16 +435,30 @@ function renameTable($table, $new_name) {
     // rename them when renaming the table.
     $indexes = $this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table', array(':schema' => $old_schema, ':table' => $old_table_name));
     foreach ($indexes as $index) {
-      if (preg_match('/^' . preg_quote($old_full_name) . '_(.*)$/', $index->indexname, $matches)) {
+      // Make sure to remove the '__idx' suffix from index name, because
+      // $this->ensureIdentifiersLength() will add the '__idx' suffix again and
+      // thus would result in a wrong index name.
+      if (preg_match('/^' . preg_quote($old_full_name) . '__(.*)__idx/', $index->indexname, $matches)) {
         $index_name = $matches[1];
         $this->connection->query('ALTER INDEX ' . $index->indexname . ' RENAME TO ' . $this->ensureIdentifiersLength($new_name, $index_name, 'idx'));
       }
     }
 
-    // Now rename the table.
     // Ensure the new table name does not include schema syntax.
     $prefixInfo = $this->getPrefixInfo($new_name);
+
+    // Rename sequences if there's a serial fields.
+    $info = $this->queryTableInformation($table);
+    if (!empty($info->serial_fields)) {
+      foreach ($info->serial_fields as $field) {
+        $old_sequence = $this->prefixNonTable($table, $field, 'seq');
+        $new_sequence = $this->prefixNonTable($new_name, $field, 'seq');
+        $this->connection->query('ALTER SEQUENCE ' . $old_sequence . ' RENAME TO ' . $new_sequence);
+      }
+    }
+    // Now rename the table.
     $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO ' . $prefixInfo['table']);
+    $this->resetTableInformation($table);
   }
 
   public function dropTable($table) {
@@ -439,6 +467,7 @@ public function dropTable($table) {
     }
 
     $this->connection->query('DROP TABLE {' . $table . '}');
+    $this->resetTableInformation($table);
     return TRUE;
   }
 
@@ -473,6 +502,7 @@ public function addField($table, $field, $spec, $new_keys = array()) {
     if (!empty($spec['description'])) {
       $this->connection->query('COMMENT ON COLUMN {' . $table . '}.' . $field . ' IS ' . $this->prepareComment($spec['description']));
     }
+    $this->resetTableInformation($table);
   }
 
   public function dropField($table, $field) {
@@ -481,6 +511,7 @@ public function dropField($table, $field) {
     }
 
     $this->connection->query('ALTER TABLE {' . $table . '} DROP COLUMN "' . $field . '"');
+    $this->resetTableInformation($table);
     return TRUE;
   }
 
@@ -530,6 +561,7 @@ public function addPrimaryKey($table, $fields) {
     }
 
     $this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createPrimaryKeySql($fields) . ')');
+    $this->resetTableInformation($table);
   }
 
   public function dropPrimaryKey($table) {
@@ -538,6 +570,7 @@ public function dropPrimaryKey($table) {
     }
 
     $this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT ' . $this->ensureIdentifiersLength($table, 'pkey'));
+    $this->resetTableInformation($table);
     return TRUE;
   }
 
@@ -550,6 +583,7 @@ function addUniqueKey($table, $name, $fields) {
     }
 
     $this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT "' . $this->ensureIdentifiersLength($table, $name, 'key') . '" UNIQUE (' . implode(',', $fields) . ')');
+    $this->resetTableInformation($table);
   }
 
   public function dropUniqueKey($table, $name) {
@@ -558,6 +592,7 @@ public function dropUniqueKey($table, $name) {
     }
 
     $this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT "' . $this->ensureIdentifiersLength($table, $name, 'key') . '"');
+    $this->resetTableInformation($table);
     return TRUE;
   }
 
@@ -570,6 +605,7 @@ public function addIndex($table, $name, $fields) {
     }
 
     $this->connection->query($this->_createIndexSql($table, $name, $fields));
+    $this->resetTableInformation($table);
   }
 
   public function dropIndex($table, $name) {
@@ -578,6 +614,7 @@ public function dropIndex($table, $name) {
     }
 
     $this->connection->query('DROP INDEX ' . $this->ensureIdentifiersLength($table, $name, 'idx'));
+    $this->resetTableInformation($table);
     return TRUE;
   }
 
@@ -681,6 +718,7 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = array
     if (isset($new_keys)) {
       $this->_createKeys($table, $new_keys);
     }
+    $this->resetTableInformation($table);
   }
 
   protected function _createIndexSql($table, $name, $fields) {
diff --git a/core/modules/system/src/Tests/Database/SchemaTest.php b/core/modules/system/src/Tests/Database/SchemaTest.php
index da8623d..0bde1ca 100644
--- a/core/modules/system/src/Tests/Database/SchemaTest.php
+++ b/core/modules/system/src/Tests/Database/SchemaTest.php
@@ -127,6 +127,78 @@ function testSchema() {
     $count = db_query('SELECT COUNT(*) FROM {test_table}')->fetchField();
     $this->assertEqual($count, 2, 'There were two rows.');
 
+    // Test renaming of keys and constraints.
+    db_drop_table('test_table');
+    $table_specification = array(
+      'fields' => array(
+        'id'  => array(
+          'type' => 'serial',
+          'not null' => TRUE,
+        ),
+        'test_field'  => array(
+          'type' => 'int',
+          'default' => 0,
+        ),
+      ),
+      'primary key' => array('id'),
+      'unique keys' => array(
+        'test_field' => array('test_field'),
+      ),
+    );
+    db_create_table('test_table', $table_specification);
+
+    // Check primary key.
+    try {
+      // Can't use indexExists() because Postgresql uses constraints.
+      db_add_primary_key('test_table', array('id'));
+      $constraint_exists = FALSE;
+    }
+    catch (Exception $e) {
+      $constraint_exists = TRUE;
+    }
+    $this->assertIdentical($constraint_exists, TRUE, 'Primary key created.');
+
+    // Check unique key.
+    try {
+      // Can't use indexExists() because Postgresql uses constraints.
+      db_add_unique_key('test_table', 'test_field', array('test_field'));
+      $constraint_exists = FALSE;
+    }
+    catch (Exception $e) {
+      $constraint_exists = TRUE;
+    }
+    $this->assertIdentical($constraint_exists, TRUE, 'Unique key created.');
+    // Rename the table.
+    db_rename_table('test_table', 'test_table2');
+
+    // Primary key should be renamed.
+    try {
+      db_add_primary_key('test_table2', array('id'));
+      $constraint_exists = FALSE;
+    }
+    catch (Exception $e) {
+      $constraint_exists = TRUE;
+    }
+    $this->assertIdentical($constraint_exists, TRUE, 'Primary key was renamed.');
+
+    // Unique key should be renamed.
+    try {
+      db_add_unique_key('test_table2', 'test_field', array('test_field'));
+      $constraint_exists = FALSE;
+    }
+    catch (Exception $e) {
+      $constraint_exists = TRUE;
+    }
+    $this->assertIdentical($constraint_exists, TRUE, 'Unique key was renamed.');
+
+    // For postgresql check that sequence was renamed.
+    if (Database::getConnection()->databaseType() == 'pgsql') {
+      // Get information about new table.
+      $info = Database::getConnection()->schema()->queryTableInformation('test_table2');
+      $sequence_name = Database::getConnection()->schema()->prefixNonTable('test_table2', 'id', 'seq');
+      $this->assertEqual($sequence_name, current($info->sequences), 'Sequence was renamed.');
+    }
+
     // Use database specific data type and ensure that table is created.
     $table_specification = array(
       'description' => 'Schema table description.',
