Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function DatabaseTasks_pgsql::initializeDatabase

Make PostgreSQL Drupal friendly.

File

includes/database/pgsql/install.inc, line 139

Class

DatabaseTasks_pgsql
@file Install functions for PostgreSQL embedded database engine.

Code

function initializeDatabase() {
 // We create some functions using global names instead of prefixing them
 // like we do with table names. This is so that we don't double up if more
 // than one instance of Drupal is running on a single database. We therefore
 // avoid trying to create them again in that case.
 try {
 // Create functions.
 db_query ('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS
 \'SELECT CASE WHEN ((1ドル > 2ドル) OR (2ドル IS NULL)) THEN 1ドル ELSE 2ドル END;\'
 LANGUAGE \'sql\'');
 db_query ('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS
 \'SELECT greatest(1,ドル greatest(2,ドル 3ドル));\'
 LANGUAGE \'sql\'');
 // Don't use {} around pg_proc table.
 if (!db_query ("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'")->fetchField ()) {
 db_query ('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS
 \'SELECT random();\'
 LANGUAGE \'sql\'');
 }
 db_query ('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
 \'SELECT array_to_string((string_to_array(1,ドル 2ドル)) [1:3ドル], 2ドル);\'
 LANGUAGE \'sql\'');
 // Using || to concatenate in Drupal is not recommended 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 for each
 // 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) {
 $this->fail (st ('Drupal could not be correctly setup with the existing database. Revise any errors.'));
 }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.