diff --git a/core/INSTALL.txt b/core/INSTALL.txt
index 6379cfa1fcd..eef7efb09bb 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 65577d2cc8f..056105e25df 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 @@ use Drupal\Core\Database\DatabaseNotFoundException;
*/
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 @@ class Tasks extends InstallTasks {
* {@inheritdoc}
*/
public function minimumVersion() {
- return '9.1.2';
+ return static::PGSQL_MINIMUM_VERSION;
}
/**
@@ -133,42 +142,38 @@ class Tasks extends InstallTasks {
* 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.
+ }
+
+ // 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()) {
- // 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();
-
- // 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: @query
", $replacements));
- }
+ $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: @query
", $replacements));
}
}
}
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index 9eb681bc53a..fd4579b62fa 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 @@ EOD;
}
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 @@ EOD;
* {@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.