diff -u b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php --- b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php @@ -252,7 +252,7 @@ * Act on an exception when the table might not have been created. * * If the table does not yet exist, that's fine, but if the table exists and - * something else cause the exception, then propagate it. + * something else caused the exception, then propagate it. * * @param \Exception $e * The exception. diff -u b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php --- b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php @@ -72,7 +72,7 @@ * Act on an exception when the table might not have been created. * * If the table does not yet exist, that's fine, but if the table exists and - * something else cause the exception, then propagate it. + * something else caused the exception, then propagate it. * * @param \Exception $e * The exception. only in patch2: unchanged: --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php @@ -190,7 +190,17 @@ public function query($query, array $args = array(), $options = array()) { return $return; } + /** + * {@inheritdoc} + */ public function prepareQuery($query) { + // The statement class is not gauranteed to be set. This works around the + // issue that may be caused by a race condition in closing and opening + // the connection. + $statementClass = $this->connection->getAttribute(\PDO::ATTR_STATEMENT_CLASS); + if ($statementClass[0] !== $this->statementClass) { + $this->connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); + } // mapConditionOperator converts LIKE operations to ILIKE for consistency // with MySQL. However, Postgres does not support ILIKE on bytea (blobs) // fields.