From: Mark A. Hershberger Date: Tue, 17 Aug 2010 03:07:27 +0000 (+0000) Subject: OverloardQ or other PG person, please review X-Git-Tag: 1.31.0-rc.0~35464 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=79907b4b0845cd963a90a7a8f6340771a472ef70;p=lhc%2Fweb%2Fwiklou.git OverloardQ or other PG person, please review These patches were necessary to get new-installer working on PG for me. I'm not sure about the ‘create lang' bits — they should maybe be in another step? --- diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 7342fa2bae..67f2479b1e 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -302,11 +302,11 @@ abstract class DatabaseInstaller { if ( !$status->isOK() ) { return false; } - $conn = $status->value; - if ( !$conn->selectDB( $this->getVar( 'wgDBname' ) ) ) { + + if ( !$this->db->selectDB( $this->getVar( 'wgDBname' ) ) ) { return false; } - return $conn->tableExists( 'cur' ) || $conn->tableExists( 'revision' ); + return $this->db->tableExists( 'cur' ) || $this->db->tableExists( 'revision' ); } /** diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index bb812e84ba..8b3643c76b 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -18,15 +18,8 @@ class PostgresInstaller extends DatabaseInstaller { 'wgDBts2schema', ); - protected $internalDefaults = array( - '_InstallUser' => 'postgres', - '_InstallPassword' => '', - ); - var $minimumVersion = '8.1'; - var $conn; - function getName() { return 'postgres'; } @@ -80,40 +73,39 @@ class PostgresInstaller extends DatabaseInstaller { // Try to connect if ( $status->isOK() ) { - $status->merge( $this->attemptConnection() ); + $status->merge( $this->getConnection() ); } if ( !$status->isOK() ) { return $status; } // Check version - $version = $this->conn->getServerVersion(); + $version = $this->db->getServerVersion(); if ( version_compare( $version, $this->minimumVersion ) < 0 ) { return Status::newFatal( 'config-postgres-old', $this->minimumVersion, $version ); } + + $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) ); + $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) ); return $status; } - function attemptConnection() { + function getConnection() { $status = Status::newGood(); try { - $this->conn = new DatabasePostgres( + $this->db = new DatabasePostgres( $this->getVar( 'wgDBserver' ), $this->getVar( '_InstallUser' ), $this->getVar( '_InstallPassword' ), - 'postgres' ); - $status->value = $this->conn; + $this->getVar( 'wgDBname' ) ); + $status->value = $this->db; } catch ( DBConnectionError $e ) { $status->fatal( 'config-connection-error', $e->getMessage() ); } return $status; } - function getConnection() { - return $this->attemptConnection(); - } - function getSettingsForm() { return false; } @@ -126,6 +118,19 @@ class PostgresInstaller extends DatabaseInstaller { } function createTables() { + $status = $this->getConnection(); + if ( !$status->isOK() ) { + return $status; + } + $this->db->selectDB( $this->getVar( 'wgDBname' ) ); + + global $IP; + $err = $this->db->sourceFile( "$IP/maintenance/postgres/tables.sql" ); + if ( $err !== true ) { + //@todo or...? + $this->db->reportQueryError( $err, 0, $sql, __FUNCTION__ ); + } + return Status::newGood(); } function getLocalSettings() { diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index 60d0413f52..f45b5057d3 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -72,6 +72,7 @@ CREATE INDEX page_mediawiki_title ON page (page_title) WHERE page_namespace = CREATE INDEX page_random_idx ON page (page_random); CREATE INDEX page_len_idx ON page (page_len); +CREATE LANGUAGE 'plpgsql'; CREATE FUNCTION page_deleted() RETURNS TRIGGER LANGUAGE plpgsql AS $mw$ BEGIN