aboutsummaryrefslogtreecommitdiffstats
path: root/includes/DatabasePostgres.php
diff options
context:
space:
mode:
authorGreg Sabino Mullane <greg@users.mediawiki.org>2008-02-04 16:40:35 +0000
committerGreg Sabino Mullane <greg@users.mediawiki.org>2008-02-04 16:40:35 +0000
commitec4c20458ec11cf99ab29793d79e93f23162b073 (patch)
tree4e3995ca4349c9613633918fa8c9c927eff2aa53 /includes/DatabasePostgres.php
parent4a1eb5d79782e595e126dbe9e11d22c76bb68bf5 (diff)
downloadmediawikicore-ec4c20458ec11cf99ab29793d79e93f23162b073.tar.gz
mediawikicore-ec4c20458ec11cf99ab29793d79e93f23162b073.zip
Refactor Pl/Pgsql check so we can also attempt installing when connecting as superuser.
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/30531
Diffstat (limited to 'includes/DatabasePostgres.php')
-rw-r--r--includes/DatabasePostgres.php60
1 files changed, 34 insertions, 26 deletions
diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php
index 48c99dbd8cd2..47d10ae189dd 100644
--- a/includes/DatabasePostgres.php
+++ b/includes/DatabasePostgres.php
@@ -335,6 +335,9 @@ class DatabasePostgres extends Database {
print "OK</li>";
}
+ ## Install plpgsql if needed
+ $this->setup_plpgsql();
+
$wgDBsuperuser = '';
return true; // Reconnect as regular user
@@ -415,32 +418,8 @@ class DatabasePostgres extends Database {
}
print "OK</li>";
- ## Do we have plpgsql installed?
- print "<li>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));
- if ($rows >= 1) {
- $olde = error_reporting(0);
- error_reporting($olde - E_WARNING);
- $result = $this->doQuery("CREATE LANGUAGE plpgsql");
- error_reporting($olde);
- if (!$result) {
- print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
- dieout("</ul>");
- }
- }
- else {
- print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
- dieout("</ul>");
- }
- }
- print "OK</li>\n";
+ ## Install plpgsql if needed
+ $this->setup_plpgsql();
## Does the schema already exist? Who owns it?
$result = $this->schemaExists($wgDBmwschema);
@@ -524,6 +503,35 @@ class DatabasePostgres extends Database {
}
+ function setup_plpgsql() {
+ print "<li>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));
+ if ($rows >= 1) {
+ $olde = error_reporting(0);
+ error_reporting($olde - E_WARNING);
+ $result = $this->doQuery("CREATE LANGUAGE plpgsql");
+ error_reporting($olde);
+ if (!$result) {
+ print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
+ dieout("</ul>");
+ }
+ }
+ else {
+ print "<b>FAILED</b>. You need to install the language plpgsql in the database <tt>$wgDBname</tt></li>";
+ dieout("</ul>");
+ }
+ }
+ print "OK</li>\n";
+ }
+
+
/**
* Closes a database connection, if it is open
* Returns success, true if already closed