r20314 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20313‎ | r20314 | r20315 >
Date:19:06, 10 March 2007
Author:river
Status:old
Tags:
Comment:
drop obsolete archive2 table; it doesn't work and Special:Delete/Undelete work fine without it
Modified paths:
  • /trunk/phase3/maintenance/postgres/archives/patch-archive-ar_deleted.sql (added) (history)
  • /trunk/phase3/maintenance/postgres/archives/patch-archive-ar_deleted.sql (added) (history)
  • /trunk/phase3/maintenance/postgres/archives/patch-archive2-ar_deleted.sql (deleted) (history)
  • /trunk/phase3/maintenance/postgres/archives/patch-remove-archive2.sql (added) (history)
  • /trunk/phase3/maintenance/postgres/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updaters.inc
@@ -1332,7 +1332,7 @@
13331333 array("page_restrictions", "patch-page_restrictions.sql"),
13341334 array("profiling", "patch-profiling.sql"),
13351335 array("mediawiki_version", "patch-mediawiki_version.sql"),
1336 - array("archive2", "patch-archive2.sql")
 1336+ // array("archive2", "patch-archive2.sql")
13371337 );
13381338
13391339 $newsequences = array(
@@ -1344,7 +1344,8 @@
13451345 );
13461346
13471347 $newrules = array(
1348 - array("archive", "archive_delete", "patch-archive_delete.sql")
 1348+ //array("archive", "archive_delete",
 1349+ //"patch-archive_delete.sql")
13491350 );
13501351
13511352 foreach ($newsequences as $ns) {
@@ -1449,18 +1450,26 @@
14501451 dbsource(archive('patch-revision_rev_user_fkey.sql'));
14511452 }
14521453
1453 - $ai_def = pg_rule_def("archive", "archive_insert");
1454 - if (strstr($ai_def, "to_date") !== false) {
1455 - echo "... fix archive_insert rule\n";
1456 - dbsource(archive('patch-archive_insert.sql'));
 1454+ if (pg_table_exists("archive2")) {
 1455+ echo "... convert archive2 back to normal archive table\n";
 1456+ if (pg_rule_exists("archive", "archive_insert")) {
 1457+ echo "... drop rule archive_insert\n";
 1458+ $wgDatabase->query("DROP RULE archive_insert ON archive");
 1459+ }
 1460+ if (pg_rule_exists("archive", "archive_delete")) {
 1461+ echo "... drop rule archive_delete\n";
 1462+ $wgDatabase->query("DROP RULE archive_delete ON archive");
 1463+ }
 1464+
 1465+ dbsource(archive("patch-remove-archive2.sql"));
14571466 } else
1458 - echo "... already have correct archive_insert rule\n";
 1467+ echo "... obsolete archive2 not present\n";
14591468
1460 - if (!pg_column_exists("archive2", "ar_deleted")) {
1461 - echo "... add archive2.ar_deleted and recreate archive view\n";
1462 - dbsource(archive("patch-archive2-ar_deleted.sql"));
 1469+ if (!pg_column_exists("archive", "ar_deleted")) {
 1470+ echo "... add archive.ar_deleted\n";
 1471+ dbsource(archive("patch-archive-ar_deleted.sql"));
14631472 } else
1464 - echo "... already have archive2.ar_deleted\n";
 1473+ echo "... archive.ar_deleted already exists\n";
14651474
14661475 return;
14671476 }
Index: trunk/phase3/maintenance/postgres/archives/patch-archive2-ar_deleted.sql
@@ -1,17 +0,0 @@
2 -ALTER TABLE archive2 ADD ar_deleted INTEGER NOT NULL DEFAULT '0';
3 -DROP VIEW archive;
4 -
5 -CREATE VIEW archive AS
6 -SELECT
7 - ar_namespace, ar_title, ar_text, ar_comment, ar_user, ar_user_text,
8 - ar_minor_edit, ar_flags, ar_rev_id, ar_text_id, ar_deleted,
9 - TO_CHAR(ar_timestamp, 'YYYYMMDDHH24MISS') AS ar_timestamp
10 -FROM archive2;
11 -
12 -CREATE RULE archive_insert AS ON INSERT TO archive
13 -DO INSTEAD INSERT INTO archive2 VALUES (
14 - NEW.ar_namespace, NEW.ar_title, NEW.ar_text, NEW.ar_comment, NEW.ar_user, NEW.ar_user_text,
15 - TO_TIMESTAMP(NEW.ar_timestamp, 'YYYYMMDDHH24MISS'),
16 - NEW.ar_minor_edit, NEW.ar_flags, NEW.ar_rev_id, NEW.ar_text_id,
17 - COALESCE(NEW.ar_deleted, 0) -- ar_deleted is not always specified
18 -);
Index: trunk/phase3/maintenance/postgres/archives/patch-remove-archive2.sql
@@ -0,0 +1,2 @@
 2+DROP VIEW archive;
 3+ALTER TABLE archive2 RENAME TO archive;
Index: trunk/phase3/maintenance/postgres/archives/patch-archive-ar_deleted.sql
@@ -0,0 +1 @@
 2+ALTER TABLE archive ADD ar_deleted INTEGER NOT NULL DEFAULT '0';
Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -123,8 +123,7 @@
124124 );
125125 ALTER TABLE page_restrictions ADD CONSTRAINT page_restrictions_pk PRIMARY KEY (pr_page,pr_type);
126126
127 -
128 -CREATE TABLE archive2 (
 127+CREATE TABLE archive (
129128 ar_namespace SMALLINT NOT NULL,
130129 ar_title TEXT NOT NULL,
131130 ar_text TEXT,
@@ -140,29 +139,6 @@
141140 );
142141 CREATE INDEX archive_name_title_timestamp ON archive2 (ar_namespace,ar_title,ar_timestamp);
143142
144 -CREATE VIEW archive AS
145 -SELECT
146 - ar_namespace, ar_title, ar_text, ar_comment, ar_user, ar_user_text,
147 - ar_minor_edit, ar_flags, ar_rev_id, ar_text_id, ar_deleted,
148 - TO_CHAR(ar_timestamp, 'YYYYMMDDHH24MISS') AS ar_timestamp
149 -FROM archive2;
150 -
151 -CREATE RULE archive_insert AS ON INSERT TO archive
152 -DO INSTEAD INSERT INTO archive2 VALUES (
153 - NEW.ar_namespace, NEW.ar_title, NEW.ar_text, NEW.ar_comment, NEW.ar_user, NEW.ar_user_text,
154 - TO_TIMESTAMP(NEW.ar_timestamp, 'YYYYMMDDHH24MISS'),
155 - NEW.ar_minor_edit, NEW.ar_flags, NEW.ar_rev_id, NEW.ar_text_id,
156 - COALESCE(NEW.ar_deleted, 0) -- NEW.ar_deleted might be unspecified (NULL)
157 -);
158 -
159 -CREATE RULE archive_delete AS ON DELETE TO archive
160 -DO INSTEAD DELETE FROM archive2 WHERE
161 - archive2.ar_title = OLD.ar_title AND
162 - archive2.ar_namespace = OLD.ar_namespace AND
163 - archive2.ar_rev_id = OLD.ar_rev_id;
164 -
165 -
166143 CREATE TABLE redirect (
167144 rd_from INTEGER NOT NULL REFERENCES page(page_id) ON DELETE CASCADE,
168145 rd_namespace SMALLINT NOT NULL,