diff --git a/core/INSTALL.txt b/core/INSTALL.txt index 6379cfa1fcdbb0b76c174cd6815ac12e1e206890..eef7efb09bbf805089c0123bb1f10663aaaaeadf 100644 --- a/core/INSTALL.txt +++ b/core/INSTALL.txt @@ -56,7 +56,7 @@ Drupal requires: compatible drop-in replacement for MySQL. - Percona Server 5.7.8 (or greater) (http://www.percona.com/). Percona Server is a backwards-compatible replacement for MySQL. - - PostgreSQL 9.1.2 (or greater) (http://www.postgresql.org/). + - PostgreSQL 10 (or greater) (http://www.postgresql.org/). - SQLite 3.26 (or greater) (http://www.sqlite.org/). For more detailed information about Drupal requirements, including a list of diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php index 65577d2cc8fb4765362a360a4de202d2422c9a2c..056105e25df593a8fff448beb37aa20687baf54f 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php @@ -11,6 +11,15 @@ */ class Tasks extends InstallTasks { + /** + * Minimum required PostgreSQL version. + * + * The contrib extension pg_trgm is supposed to be installed. + * + * @see https://www.postgresql.org/docs/10/pgtrgm.html + */ + const PGSQL_MINIMUM_VERSION = '10'; + /** * {@inheritdoc} */ @@ -49,7 +58,7 @@ public function name() { * {@inheritdoc} */ public function minimumVersion() { - return '9.1.2'; + return static::PGSQL_MINIMUM_VERSION; } /** @@ -133,42 +142,38 @@ protected function checkEncoding() { * Unserializing does not work on Postgresql 9 when bytea_output is 'hex'. */ public function checkBinaryOutput() { - // PostgreSQL < 9 doesn't support bytea_output, so verify we are running - // at least PostgreSQL 9. $database_connection = Database::getConnection(); - if (version_compare($database_connection->version(), '9') >= 0) { - if (!$this->checkBinaryOutputSuccess()) { - // First try to alter the database. If it fails, raise an error telling - // the user to do it themselves. - $connection_options = $database_connection->getConnectionOptions(); - // It is safe to include the database name directly here, because this - // code is only called when a connection to the database is already - // established, thus the database name is guaranteed to be a correct - // value. - $query = "ALTER DATABASE \"" . $connection_options['database'] . "\" SET bytea_output = 'escape';"; - try { - $database_connection->query($query); - } - catch (\Exception $e) { - // Ignore possible errors when the user doesn't have the necessary - // privileges to ALTER the database. - } + if (!$this->checkBinaryOutputSuccess()) { + // First try to alter the database. If it fails, raise an error telling + // the user to do it themselves. + $connection_options = $database_connection->getConnectionOptions(); + // It is safe to include the database name directly here, because this + // code is only called when a connection to the database is already + // established, thus the database name is guaranteed to be a correct + // value. + $query = "ALTER DATABASE \"{$connection_options['database']}\" SET bytea_output = 'escape';"; + try { + $database_connection->query($query); + } + catch (\Exception $e) { + // Ignore possible errors when the user doesn't have the necessary + // privileges to ALTER the database. + } - // Close the database connection so that the configuration parameter - // is applied to the current connection. - Database::closeConnection(); + // Close the database connection so that the configuration parameter + // is applied to the current connection. + Database::closeConnection(); - // Recheck, if it fails, finally just rely on the end user to do the - // right thing. - if (!$this->checkBinaryOutputSuccess()) { - $replacements = [ - '%setting' => 'bytea_output', - '%current_value' => 'hex', - '%needed_value' => 'escape', - '@query' => $query, - ]; - $this->fail(t("The %setting setting is currently set to '%current_value', but needs to be '%needed_value'. Change this by running the following query: <code>@query</code>", $replacements)); - } + // Recheck, if it fails, finally just rely on the end user to do the + // right thing. + if (!$this->checkBinaryOutputSuccess()) { + $replacements = [ + '%setting' => 'bytea_output', + '%current_value' => 'hex', + '%needed_value' => 'escape', + '@query' => $query, + ]; + $this->fail(t("The %setting setting is currently set to '%current_value', but needs to be '%needed_value'. Change this by running the following query: <code>@query</code>", $replacements)); } } } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index 9eb681bc53a292f1a7d3b8d3490152acce6cebab..fd4579b62fafb9d01d3d68ec768b92d65cdf92ac 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -380,7 +380,7 @@ protected function processField($field) { } if (!empty($field['unsigned'])) { - // Unsigned data types are not supported in PostgreSQL 9.1. In MySQL, + // Unsigned data types are not supported in PostgreSQL 10. In MySQL, // they are used to ensure a positive number is inserted and it also // doubles the maximum integer size that can be stored in a field. // The PostgreSQL schema in Drupal creates a check constraint @@ -706,7 +706,7 @@ public function fieldExists($table, $column) { * {@inheritdoc} */ public function indexExists($table, $name) { - // Details http://www.postgresql.org/docs/9.1/interactive/view-pg-indexes.html + // Details https://www.postgresql.org/docs/10/view-pg-indexes.html $index_name = $this->ensureIdentifiersLength($table, $name, 'idx'); // Remove leading and trailing quotes because the index name is in a WHERE // clause and not used as an identifier.