From b5995fd723708000f58791b6ac27931eafac3a3f Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Mon, 27 Dec 2010 15:41:11 +0000 Subject: [PATCH] Move setup_plpgsql() to PostgresInstaller and make it use status objects for when the rest of this is moved over too --- includes/db/DatabasePostgres.php | 30 ------------------------ includes/installer/Installer.i18n.php | 1 + includes/installer/PostgresInstaller.php | 22 +++++++++++++++++ 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index dff73e9d67..86492b0ddb 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -537,36 +537,6 @@ class DatabasePostgres extends DatabaseBase { } } - function setup_plpgsql() { - print '
  • Checking for PL/pgSQL ...'; - $SQL = "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'"; - $rows = $this->numRows( $this->doQuery( $SQL ) ); - if ( $rows < 1 ) { - // plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it - print 'not installed. Attempting to install PL/pgSQL ...'; - $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ". - "WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'"; - $rows = $this->numRows( $this->doQuery( $SQL ) ); - global $wgDBname; - if ( $rows >= 1 ) { - $olde = error_reporting( 0 ); - error_reporting( $olde - E_WARNING ); - $result = $this->doQuery( 'CREATE LANGUAGE plpgsql' ); - error_reporting( $olde ); - if ( !$result ) { - print 'FAILED. You need to install the language PL/pgSQL in the database ' . - htmlspecialchars( $wgDBname ) . '
  • '; - dieout( ); - } - } else { - print 'FAILED. You need to install the language PL/pgSQL in the database ' . - htmlspecialchars( $wgDBname ) . ''; - dieout( ); - } - } - print "OK\n"; - } - /** * Closes a database connection, if it is open * Returns success, true if already closed diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index 1cdfbf8002..6ab8d57f4b 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -449,6 +449,7 @@ Please proceed to the next page.", 'config-install-pg-schema-failed' => 'Tables creation failed. Make sure that the user "$1" can write to the schema "$2".', 'config-install-pg-commit' => 'Committing changes', + 'config-pg-no-plpgsql' => 'You need to install the language PL/pgSQL in the database $1', 'config-install-user' => 'Creating database user', 'config-install-user-failed' => 'Granting permission to user "$1" failed: $2', 'config-install-tables' => 'Creating tables', diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index aa9d68b95a..7f5612b795 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -166,4 +166,26 @@ class PostgresInstaller extends DatabaseInstaller { $wgDBuser = $this->getVar( '_InstallUser' ); $wgDBpassword = $this->getVar( '_InstallPassword' ); } + + private function setupPLpgSQL() { + $rows = $this->numRows( + $this->db->query( "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'" ) + ); + if ( $rows < 1 ) { + // plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it + $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ". + "WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'"; + $rows = $this->numRows( $this->db->query( $SQL ) ); + global $wgDBname; + if ( $rows >= 1 ) { + $result = $this->db->query( 'CREATE LANGUAGE plpgsql' ); + if ( !$result ) { + return Status::newFatal( 'pg-no-plpgsql', $wgDBname ); + } + } else { + return Status::newFatal( 'pg-no-plpgsql', $wgDBname ); + } + } + return Status::newGood(); + } } -- 2.20.1