Index: trunk/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -537,36 +537,6 @@ |
538 | 538 | } |
539 | 539 | } |
540 | 540 | |
541 | | - function setup_plpgsql() { |
542 | | - print '<li>Checking for PL/pgSQL ...'; |
543 | | - $SQL = "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'"; |
544 | | - $rows = $this->numRows( $this->doQuery( $SQL ) ); |
545 | | - if ( $rows < 1 ) { |
546 | | - // plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it |
547 | | - print 'not installed. Attempting to install PL/pgSQL ...'; |
548 | | - $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ". |
549 | | - "WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'"; |
550 | | - $rows = $this->numRows( $this->doQuery( $SQL ) ); |
551 | | - global $wgDBname; |
552 | | - if ( $rows >= 1 ) { |
553 | | - $olde = error_reporting( 0 ); |
554 | | - error_reporting( $olde - E_WARNING ); |
555 | | - $result = $this->doQuery( 'CREATE LANGUAGE plpgsql' ); |
556 | | - error_reporting( $olde ); |
557 | | - if ( !$result ) { |
558 | | - print '<b>FAILED</b>. You need to install the language PL/pgSQL in the database <tt>' . |
559 | | - htmlspecialchars( $wgDBname ) . '</tt></li>'; |
560 | | - dieout( ); |
561 | | - } |
562 | | - } else { |
563 | | - print '<b>FAILED</b>. You need to install the language PL/pgSQL in the database <tt>' . |
564 | | - htmlspecialchars( $wgDBname ) . '</tt></li>'; |
565 | | - dieout( ); |
566 | | - } |
567 | | - } |
568 | | - print "OK</li>\n"; |
569 | | - } |
570 | | - |
571 | 541 | /** |
572 | 542 | * Closes a database connection, if it is open |
573 | 543 | * Returns success, true if already closed |
Index: trunk/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -449,6 +449,7 @@ |
450 | 450 | 'config-install-pg-schema-failed' => 'Tables creation failed. |
451 | 451 | Make sure that the user "$1" can write to the schema "$2".', |
452 | 452 | 'config-install-pg-commit' => 'Committing changes', |
| 453 | + 'config-pg-no-plpgsql' => 'You need to install the language PL/pgSQL in the database $1', |
453 | 454 | 'config-install-user' => 'Creating database user', |
454 | 455 | 'config-install-user-failed' => 'Granting permission to user "$1" failed: $2', |
455 | 456 | 'config-install-tables' => 'Creating tables', |
Index: trunk/phase3/includes/installer/PostgresInstaller.php |
— | — | @@ -166,4 +166,26 @@ |
167 | 167 | $wgDBuser = $this->getVar( '_InstallUser' ); |
168 | 168 | $wgDBpassword = $this->getVar( '_InstallPassword' ); |
169 | 169 | } |
| 170 | + |
| 171 | + private function setupPLpgSQL() { |
| 172 | + $rows = $this->numRows( |
| 173 | + $this->db->query( "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'" ) |
| 174 | + ); |
| 175 | + if ( $rows < 1 ) { |
| 176 | + // plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it |
| 177 | + $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ". |
| 178 | + "WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'"; |
| 179 | + $rows = $this->numRows( $this->db->query( $SQL ) ); |
| 180 | + global $wgDBname; |
| 181 | + if ( $rows >= 1 ) { |
| 182 | + $result = $this->db->query( 'CREATE LANGUAGE plpgsql' ); |
| 183 | + if ( !$result ) { |
| 184 | + return Status::newFatal( 'pg-no-plpgsql', $wgDBname ); |
| 185 | + } |
| 186 | + } else { |
| 187 | + return Status::newFatal( 'pg-no-plpgsql', $wgDBname ); |
| 188 | + } |
| 189 | + } |
| 190 | + return Status::newGood(); |
| 191 | + } |
170 | 192 | } |