Allow --record option if parserTests.php to work when using Postgres
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Tue, 18 Dec 2007 15:46:53 +0000 (15:46 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Tue, 18 Dec 2007 15:46:53 +0000 (15:46 +0000)
RELEASE-NOTES
maintenance/parserTests.inc
maintenance/testRunner.postgres.sql [new file with mode: 0644]

index f578a9e..dcbbb9f 100644 (file)
@@ -249,6 +249,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 12283) Special:Newpages forgets parameters
 * (bug 12031) All namespaces doesn't work in Special:Newpages
 * (bug 585) Only create searchindex replica table for parser tests if db is MySQL
+* Allow --record option if parserTests.php to work when using Postgres
 
 == Parser changes in 1.12 ==
 
index bfb226b..b789ebe 100644 (file)
@@ -942,13 +942,17 @@ class DbTestRecorder extends TestRecorder  {
         * and all that fun stuff
         */
        function start() {
+               global $wgDBtype;
                parent::start();
 
                $this->db->begin();
 
                if( ! $this->db->tableExists( 'testrun' ) or ! $this->db->tableExists( 'testitem') ) {
                        print "WARNING> `testrun` table not found in database. Trying to create table.\n";
-                       dbsource( dirname(__FILE__) . '/testRunner.sql',  $this->db );
+            if ($wgDBtype === 'postgres')
+                               dbsource( dirname(__FILE__) . '/testRunner.postgres.sql',  $this->db );
+                       else
+                               dbsource( dirname(__FILE__) . '/testRunner.sql',  $this->db );
                        echo "OK, resuming.\n";
                }
 
@@ -964,7 +968,10 @@ class DbTestRecorder extends TestRecorder  {
                                'tr_uname'       => php_uname()
                        ),
                        __METHOD__ );
-               $this->curRun = $this->db->insertId();
+                       if ($wgDBtype === 'postgres')
+                               $this->curRun = $this->db->currentSequenceValue('testrun_id_seq');
+                       else
+                               $this->curRun = $this->db->insertId();
        }
 
        /**
diff --git a/maintenance/testRunner.postgres.sql b/maintenance/testRunner.postgres.sql
new file mode 100644 (file)
index 0000000..c15300b
--- /dev/null
@@ -0,0 +1,30 @@
+--
+-- Optional tables for parserTests recording mode
+-- With --record option, success data will be saved to these tables,
+-- and comparisons of what's changed from the previous run will be
+-- displayed at the end of each run.
+--
+-- This file is for the Postgres version of the tables
+--
+
+-- Note: "if exists" will not work on older versions of Postgres
+DROP TABLE IF EXISTS testitem;
+DROP TABLE IF EXISTS testrun;
+DROP SEQUENCE IF EXISTS testrun_id_seq;
+
+CREATE SEQUENCE testrun_id_seq;
+CREATE TABLE testrun (
+  tr_id           INTEGER PRIMARY KEY NOT NULL DEFAULT nextval('testrun_id_seq'),
+  tr_date         TIMESTAMPTZ,
+  tr_mw_version   TEXT,
+  tr_php_version  TEXT,
+  tr_db_version   TEXT,
+  tr_uname        TEXT
+);
+
+CREATE TABLE testitem (
+  ti_run      INTEGER   NOT NULL REFERENCES testrun(tr_id) ON DELETE CASCADE,
+  ti_name     TEXT      NOT NULL,
+  ti_success  SMALLINT  NOT NULL
+);  
+CREATE UNIQUE INDEX testitem_uniq ON testitem(ti_run, ti_name);