From: Greg Sabino Mullane Date: Tue, 18 Dec 2007 15:46:53 +0000 (+0000) Subject: Allow --record option if parserTests.php to work when using Postgres X-Git-Tag: 1.31.0-rc.0~50362 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=271659d01bff842d0856462ebe42ecf8ae47901d;p=lhc%2Fweb%2Fwiklou.git Allow --record option if parserTests.php to work when using Postgres --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f578a9eddd..dcbbb9f199 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index bfb226bca8..b789ebe7c1 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -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 index 0000000000..c15300b5c5 --- /dev/null +++ b/maintenance/testRunner.postgres.sql @@ -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);