Account for pre-existing test table, commit only if setup completes.
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Mon, 26 Mar 2007 00:12:26 +0000 (00:12 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Mon, 26 Mar 2007 00:12:26 +0000 (00:12 +0000)
includes/DatabasePostgres.php
maintenance/postgres/tables.sql

index 3fe8144..bed25d8 100644 (file)
@@ -908,7 +908,11 @@ END;
 
                ## Make sure that we can write to the correct schema
                ## If not, Postgres will happily and silently go to the next search_path item
-               $SQL = "CREATE TABLE $wgDBmwschema.mw_test_table(a int)";
+               $ctest = "mw_test_table";
+               if ($this->tableExists($ctest, $wgDBmwschema)) {
+                       $this->doQuery("DROP TABLE $wgDBmwschema.$ctest");
+               }
+               $SQL = "CREATE TABLE $wgDBmwschema.$ctest(a int)";
                error_reporting( 0 );
                $res = $this->doQuery($SQL);
                error_reporting( E_ALL );
@@ -916,6 +920,7 @@ END;
                        print "<b>FAILED</b>. Make sure that the user \"$wgDBuser\" can write to the schema \"$wgDBmwschema\"</li>\n";
                        dieout("</ul>");
                }
+               $this->doQuery("DROP TABLE $wgDBmwschema.mw_test_table");
 
                dbsource( "../maintenance/postgres/tables.sql", $this);
 
@@ -961,6 +966,8 @@ END;
                        $this->query("$SQL $matches[1],$matches[2])");
                }
                print " (table interwiki successfully populated)...\n";
+
+               $this->doQuery("COMMIT");
        }
 
        function encodeBlob($b) {
index 5eba2cf..1c7c42d 100644 (file)
@@ -514,4 +514,3 @@ INSERT INTO mediawiki_version (type,mw_version,sql_version,sql_date)
   VALUES ('Creation','??','$LastChangedRevision$','$LastChangedDate$');
 
 
-COMMIT;