diff --git includes/database/pgsql/install.inc includes/database/pgsql/install.inc index 7f63f6c..60630de 100644 --- includes/database/pgsql/install.inc +++ includes/database/pgsql/install.inc @@ -89,6 +89,29 @@ class DatabaseTasks_pgsql extends DatabaseTasks { \'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\' LANGUAGE \'sql\'' ); + + // Using || to concatenate in Drupal is not recommeneded because there are + // database drivers for Drupal that do not support the syntax, however + // they do support CONCAT(item1, item2) which we can replicate in + // PostgreSQL. PostgreSQL requires the function to be defined foreach + // different argument variation the function can handle. + db_query('CREATE OR REPLACE FUNCTION "concat"(anynonarray, anynonarray) RETURNS text AS + \'SELECT CAST($1 AS text) || CAST($2 AS text);\' + LANGUAGE \'sql\' + '); + db_query('CREATE OR REPLACE FUNCTION "concat"(text, anynonarray) RETURNS text AS + \'SELECT $1 || CAST($2 AS text);\' + LANGUAGE \'sql\' + '); + db_query('CREATE OR REPLACE FUNCTION "concat"(anynonarray, text) RETURNS text AS + \'SELECT CAST($1 AS text) || $2;\' + LANGUAGE \'sql\' + '); + db_query('CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS + \'SELECT $1 || $2;\' + LANGUAGE \'sql\' + '); + $this->pass(st('PostgreSQL has initialized itself.')); } catch (Exception $e) {