From: Greg Sabino Mullane Date: Sat, 19 Aug 2006 12:43:13 +0000 (+0000) Subject: By Robert Treat: try to create plpgsql if it does not exists. X-Git-Tag: 1.31.0-rc.0~55949 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=1e79c1f35c1f1fbafb62d2010e695570601de0a5;p=lhc%2Fweb%2Fwiklou.git By Robert Treat: try to create plpgsql if it does not exists. Bug #7065 --- 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";