r58263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58262‎ | r58263 | r58264 >
Date:17:08, 28 October 2009
Author:overlordq
Status:ok (Comments)
Tags:
Comment:
Followup to r58262: PG half of sequence changes
Modified paths:
  • /trunk/phase3/maintenance/postgres/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -82,9 +82,9 @@
8383 CREATE TRIGGER page_deleted AFTER DELETE ON page
8484 FOR EACH ROW EXECUTE PROCEDURE page_deleted();
8585
86 -CREATE SEQUENCE rev_rev_id_val;
 86+CREATE SEQUENCE revision_rev_id_seq;
8787 CREATE TABLE revision (
88 - rev_id INTEGER NOT NULL UNIQUE DEFAULT nextval('rev_rev_id_val'),
 88+ rev_id INTEGER NOT NULL UNIQUE DEFAULT nextval('revision_rev_id_seq'),
8989 rev_page INTEGER NULL REFERENCES page (page_id) ON DELETE CASCADE,
9090 rev_text_id INTEGER NULL, -- FK
9191 rev_comment TEXT,
@@ -103,17 +103,17 @@
104104 CREATE INDEX rev_user_text_idx ON revision (rev_user_text);
105105
106106
107 -CREATE SEQUENCE text_old_id_val;
 107+CREATE SEQUENCE text_old_id_seq;
108108 CREATE TABLE pagecontent ( -- replaces reserved word 'text'
109 - old_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('text_old_id_val'),
 109+ old_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('text_old_id_seq'),
110110 old_text TEXT,
111111 old_flags TEXT
112112 );
113113
114114
115 -CREATE SEQUENCE pr_id_val;
 115+CREATE SEQUENCE page_restrictions_pr_id_seq;
116116 CREATE TABLE page_restrictions (
117 - pr_id INTEGER NOT NULL UNIQUE DEFAULT nextval('pr_id_val'),
 117+ pr_id INTEGER NOT NULL UNIQUE DEFAULT nextval('page_restrictions_pr_id_seq'),
118118 pr_page INTEGER NULL REFERENCES page (page_id) ON DELETE CASCADE,
119119 pr_type TEXT NOT NULL,
120120 pr_level TEXT NOT NULL,
@@ -233,9 +233,9 @@
234234 );
235235
236236
237 -CREATE SEQUENCE ipblocks_ipb_id_val;
 237+CREATE SEQUENCE ipblocks_ipb_id_seq;
238238 CREATE TABLE ipblocks (
239 - ipb_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('ipblocks_ipb_id_val'),
 239+ ipb_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('ipblocks_ipb_id_seq'),
240240 ipb_address TEXT NULL,
241241 ipb_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL,
242242 ipb_by INTEGER NOT NULL REFERENCES mwuser(user_id) ON DELETE CASCADE,
@@ -333,9 +333,9 @@
334334 CREATE INDEX fa_nouser ON filearchive (fa_deleted_user);
335335
336336
337 -CREATE SEQUENCE rc_rc_id_seq;
 337+CREATE SEQUENCE recentchanges_rc_id_seq;
338338 CREATE TABLE recentchanges (
339 - rc_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('rc_rc_id_seq'),
 339+ rc_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('recentchanges_rc_id_seq'),
340340 rc_timestamp TIMESTAMPTZ NOT NULL,
341341 rc_cur_time TIMESTAMPTZ NOT NULL,
342342 rc_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL,
@@ -435,9 +435,9 @@
436436 );
437437
438438
439 -CREATE SEQUENCE log_log_id_seq;
 439+CREATE SEQUENCE logging_log_id_seq;
440440 CREATE TABLE logging (
441 - log_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('log_log_id_seq'),
 441+ log_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq'),
442442 log_type TEXT NOT NULL,
443443 log_action TEXT NOT NULL,
444444 log_timestamp TIMESTAMPTZ NOT NULL,
@@ -563,9 +563,9 @@
564564 );
565565
566566
567 -CREATE SEQUENCE category_id_seq;
 567+CREATE SEQUENCE category_cat_id_seq;
568568 CREATE TABLE category (
569 - cat_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('category_id_seq'),
 569+ cat_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('category_cat_id_seq'),
570570 cat_title TEXT NOT NULL,
571571 cat_pages INTEGER NOT NULL DEFAULT 0,
572572 cat_subcats INTEGER NOT NULL DEFAULT 0,
Index: trunk/phase3/maintenance/updaters.inc
@@ -1402,6 +1402,15 @@
14031403 }
14041404
14051405 function
 1406+pg_sequence_exists($seq)
 1407+{
 1408+global $wgDatabase, $wgDBmwschema;
 1409+ $exists = $wgDatabase->selectField("pg_class","relname",
 1410+ array( "relname" => $seq ) );
 1411+ return $exists === $seq;
 1412+}
 1413+
 1414+function
14061415 pg_fkey_deltype($fkey)
14071416 {
14081417 global $wgDatabase, $wgDBmwschema;
@@ -1504,8 +1513,8 @@
15051514 }
15061515
15071516 $newsequences = array(
1508 - "log_log_id_seq",
1509 - "pr_id_val",
 1517+ "logging_log_id_seq",
 1518+ "page_restrictions_pr_id_seq",
15101519 );
15111520
15121521 $newtables = array(
@@ -1830,6 +1839,14 @@
18311840 $wgDatabase->sourceFile(archive('patch-revision_rev_user_fkey.sql'));
18321841 }
18331842
 1843+ #Update sequence names
 1844+ if (pg_sequence_exists('page_restrictions_pr_id_seq')) {
 1845+ wfOut( "... sequences already updated\n" );
 1846+ } else {
 1847+ wfOut( "Updating sequence names\n" );
 1848+ $wgDatabase->sourceFile(archive('patch-update_sequences.sql'));
 1849+ }
 1850+
18341851 # Fix ipb_address index
18351852 if (pg_index_exists('ipblocks', 'ipb_address' )) {
18361853 wfOut( "Removing deprecated index 'ipb_address'...\n" );

Follow-up revisions

RevisionCommit summaryAuthorDate
r58268Followup to r58263: forgot patch fileoverlordq18:18, 28 October 2009
r58349Followup to r58263, update newcolumns, fix newsequences check, minor formatti...overlordq00:14, 30 October 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r58262Changed sequence names to a standard <table>_<field>_seq form....freakolowsky16:17, 28 October 2009

Comments

#Comment by OverlordQ (talk | contribs)   23:56, 29 October 2009

Fixme: already a function for finding if sequenceExists, conflicts with $newsequences

Status & tagging log