Index: trunk/phase3/maintenance/postgres/tables.sql |
— | — | @@ -72,6 +72,7 @@ |
73 | 73 | CREATE INDEX page_random_idx ON page (page_random); |
74 | 74 | CREATE INDEX page_len_idx ON page (page_len); |
75 | 75 | |
| 76 | +CREATE LANGUAGE 'plpgsql'; |
76 | 77 | CREATE FUNCTION page_deleted() RETURNS TRIGGER LANGUAGE plpgsql AS |
77 | 78 | $mw$ |
78 | 79 | BEGIN |
Index: trunk/phase3/includes/installer/DatabaseInstaller.php |
— | — | @@ -302,11 +302,11 @@ |
303 | 303 | if ( !$status->isOK() ) { |
304 | 304 | return false; |
305 | 305 | } |
306 | | - $conn = $status->value; |
307 | | - if ( !$conn->selectDB( $this->getVar( 'wgDBname' ) ) ) { |
| 306 | + |
| 307 | + if ( !$this->db->selectDB( $this->getVar( 'wgDBname' ) ) ) { |
308 | 308 | return false; |
309 | 309 | } |
310 | | - return $conn->tableExists( 'cur' ) || $conn->tableExists( 'revision' ); |
| 310 | + return $this->db->tableExists( 'cur' ) || $this->db->tableExists( 'revision' ); |
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
Index: trunk/phase3/includes/installer/PostgresInstaller.php |
— | — | @@ -18,15 +18,8 @@ |
19 | 19 | 'wgDBts2schema', |
20 | 20 | ); |
21 | 21 | |
22 | | - protected $internalDefaults = array( |
23 | | - '_InstallUser' => 'postgres', |
24 | | - '_InstallPassword' => '', |
25 | | - ); |
26 | | - |
27 | 22 | var $minimumVersion = '8.1'; |
28 | 23 | |
29 | | - var $conn; |
30 | | - |
31 | 24 | function getName() { |
32 | 25 | return 'postgres'; |
33 | 26 | } |
— | — | @@ -80,40 +73,39 @@ |
81 | 74 | |
82 | 75 | // Try to connect |
83 | 76 | if ( $status->isOK() ) { |
84 | | - $status->merge( $this->attemptConnection() ); |
| 77 | + $status->merge( $this->getConnection() ); |
85 | 78 | } |
86 | 79 | if ( !$status->isOK() ) { |
87 | 80 | return $status; |
88 | 81 | } |
89 | 82 | |
90 | 83 | // Check version |
91 | | - $version = $this->conn->getServerVersion(); |
| 84 | + $version = $this->db->getServerVersion(); |
92 | 85 | if ( version_compare( $version, $this->minimumVersion ) < 0 ) { |
93 | 86 | return Status::newFatal( 'config-postgres-old', $this->minimumVersion, $version ); |
94 | 87 | } |
| 88 | + |
| 89 | + $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) ); |
| 90 | + $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) ); |
95 | 91 | return $status; |
96 | 92 | } |
97 | 93 | |
98 | | - function attemptConnection() { |
| 94 | + function getConnection() { |
99 | 95 | $status = Status::newGood(); |
100 | 96 | |
101 | 97 | try { |
102 | | - $this->conn = new DatabasePostgres( |
| 98 | + $this->db = new DatabasePostgres( |
103 | 99 | $this->getVar( 'wgDBserver' ), |
104 | 100 | $this->getVar( '_InstallUser' ), |
105 | 101 | $this->getVar( '_InstallPassword' ), |
106 | | - 'postgres' ); |
107 | | - $status->value = $this->conn; |
| 102 | + $this->getVar( 'wgDBname' ) ); |
| 103 | + $status->value = $this->db; |
108 | 104 | } catch ( DBConnectionError $e ) { |
109 | 105 | $status->fatal( 'config-connection-error', $e->getMessage() ); |
110 | 106 | } |
111 | 107 | return $status; |
112 | 108 | } |
113 | 109 | |
114 | | - function getConnection() { |
115 | | - return $this->attemptConnection(); |
116 | | - } |
117 | | - |
118 | 110 | function getSettingsForm() { |
119 | 111 | return false; |
120 | 112 | } |
— | — | @@ -126,8 +118,21 @@ |
127 | 119 | } |
128 | 120 | |
129 | 121 | function createTables() { |
| 122 | + $status = $this->getConnection(); |
| 123 | + if ( !$status->isOK() ) { |
| 124 | + return $status; |
130 | 125 | } |
| 126 | + $this->db->selectDB( $this->getVar( 'wgDBname' ) ); |
131 | 127 | |
| 128 | + global $IP; |
| 129 | + $err = $this->db->sourceFile( "$IP/maintenance/postgres/tables.sql" ); |
| 130 | + if ( $err !== true ) { |
| 131 | + //@todo or...? |
| 132 | + $this->db->reportQueryError( $err, 0, $sql, __FUNCTION__ ); |
| 133 | + } |
| 134 | + return Status::newGood(); |
| 135 | + } |
| 136 | + |
132 | 137 | function getLocalSettings() { |
133 | 138 | $port = $this->getVar( 'wgDBport' ); |
134 | 139 | $schema = $this->getVar( 'wgDBmwschema' ); |