Issue #2846994 by Gábor Hojtsy, jungle, andypost, daffie, swatichouhan012, xjm, catch, effulgentsia, bzrudi71, mradcliffe, TravisCarden, Mixologic: Increase minimum version requirement for Postgres to 10 and require the pg_trgm extension

merge-requests/2419/head
catch 2020-03-10 10:36:34 +00:00
parent c88513f91e
commit 5b446846f8
3 changed files with 43 additions and 38 deletions

View File

@ -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

View File

@ -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,10 +142,7 @@ 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.
@ -145,7 +151,7 @@ class Tasks extends InstallTasks {
// 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';";
$query = "ALTER DATABASE \"{$connection_options['database']}\" SET bytea_output = 'escape';";
try {
$database_connection->query($query);
}
@ -171,7 +177,6 @@ class Tasks extends InstallTasks {
}
}
}
}
/**
* Verify that a binary data roundtrip returns the original string.

View File

@ -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.