From 1e79c1f35c1f1fbafb62d2010e695570601de0a5 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Sat, 19 Aug 2006 12:43:13 +0000 Subject: [PATCH] By Robert Treat: try to create plpgsql if it does not exists. Bug #7065 --- includes/DatabasePostgres.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index 2ff33a3ba6..50097b89bc 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -246,8 +246,22 @@ class DatabasePostgres extends Database { $SQL = "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'"; $rows = $this->numRows($this->doQuery($SQL)); if ($rows < 1) { - print "FAILED. Make sure the language plpgsql is installed for the database $wgDBname"; - dieout(""); + // 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)); + if ($rows >= 1) { + $result = $this->doQuery("CREATE LANGUAGE plpgsql"); + if (!$result) { + print "FAILED. You need to install the language plpgsql in the database $wgDBname"; + dieout(""); + } + } + else { + print "FAILED. You need to install the language plpgsql in the database $wgDBname"; + dieout(""); + } } print "OK\n"; -- 2.20.1