From ae844e0325aaad1109d21d963f68c4920ec80bba Mon Sep 17 00:00:00 2001 From: River Tarnell Date: Thu, 8 Mar 2007 20:45:22 +0000 Subject: [PATCH] convert archive_insert rule fix to new form this makes the old update system obsolete; remove it --- .../archives/patch-archive_insert.sql | 6 ++ maintenance/updaters.inc | 82 +++++++------------ 2 files changed, 34 insertions(+), 54 deletions(-) create mode 100644 maintenance/postgres/archives/patch-archive_insert.sql diff --git a/maintenance/postgres/archives/patch-archive_insert.sql b/maintenance/postgres/archives/patch-archive_insert.sql new file mode 100644 index 0000000000..ca13d2a2cc --- /dev/null +++ b/maintenance/postgres/archives/patch-archive_insert.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE RULE archive_insert AS ON INSERT TO archive +DO INSTEAD INSERT INTO archive2 VALUES ( + NEW.ar_namespace, NEW.ar_title, NEW.ar_text, NEW.ar_comment, NEW.ar_user, NEW.ar_user_text, + TO_TIMESTAMP(NEW.ar_timestamp, 'YYYYMMDDHH24MISS'), + NEW.ar_minor_edit, NEW.ar_flags, NEW.ar_rev_id, NEW.ar_text_id +); diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index f129e2477a..902a38cf61 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -1243,6 +1243,28 @@ END; return $row[0]; } +function +pg_rule_def($table, $rule) +{ +global $wgDatabase, $wgDBmwschema; + $q = <<query(sprintf($q, + $wgDatabase->addQuotes($wgDBmwschema), + $wgDatabase->addQuotes($table), + $wgDatabase->addQuotes($rule))); + $row = $wgDatabase->fetchRow($r); + if (!$row) + return null; + $d = $row[0]; + $wgDatabase->freeResult($r); + return $d; +} + function do_postgres_updates() { global $wgDatabase, $wgVersion, $wgDBmwschema; @@ -1250,31 +1272,6 @@ function do_postgres_updates() { if ( !isset( $wgDBmwschema )) $wgDBmwschema = 'mediawiki'; - ## Default to the oldest supported version - $version = 1.7; - - $thisver = array(); - if ($wgDatabase->tableExists("mediawiki_version")) { - $version = "1.8"; - $sql = "SELECT mw_version FROM mediawiki_version ORDER BY cdate DESC LIMIT 1"; - $tempversion = pg_fetch_result($wgDatabase->doQuery($sql),0,0); - if (preg_match('/(\d+\.\d+)/', $tempversion, $thisver)) { - $version = $thisver[1]; - } - } - - print " Detected version: $version\n"; - - ## Transform to a standard format - if (! preg_match('/(\d+)\.(\d+)/', $version, $thisver)) { - die ("Sorry, could not figure out what version \"$version\" means"); - } - $oldversion = $version; - $version = sprintf("%d%03d",$thisver[1],$thisver[2]); - print " Standardized version: $version\n"; - - $upgrade = ''; - $typechanges = array( array("oldimage", "oi_size", "int4"), array("oldimage", "oi_width", "int4"), @@ -1406,35 +1403,12 @@ function do_postgres_updates() { dbsource(archive('patch-revision_rev_user_fkey.sql')); } - ## 1.10 updater - if ($version <= 1010) { - $upgrade = <<query("BEGIN;\n\n $upgrade\n\nCOMMIT;\n"); + $ai_def = pg_rule_def("archive", "archive_insert"); + if (strstr($ai_def, "to_date") !== false) { + echo "... fix archive_insert rule\n"; + dbsource(archive('patch-archive_insert.sql')); + } else + echo "... already have correct archive_insert rule\n"; return; } -- 2.20.1