r75545 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75544‎ | r75545 | r75546 >
Date:14:52, 27 October 2010
Author:freakolowsky
Status:resolved (Comments)
Tags:
Comment:
* installers skips recreation of existing user
* updater for 16->17 schema changes
* i dedicate this revision to my greatest supporter ... Reedy :)
Modified paths:
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/installer/OracleInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/OracleUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/oracle/archives/patch_16_17_schema_changes.sql (added) (history)
  • /trunk/phase3/maintenance/oracle/archives/patch_create_17_functions.sql (added) (history)
  • /trunk/phase3/maintenance/oracle/archives/patch_fk_rename_deferred.sql (added) (history)
  • /trunk/phase3/maintenance/oracle/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/tests/parser/parserTest.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/parser/parserTest.inc
@@ -339,16 +339,20 @@
340340 public function runTestsFromFiles( $filenames ) {
341341 $GLOBALS['wgContLang'] = Language::factory( 'en' );
342342 $this->recorder->start();
343 - $this->setupDatabase();
344 - $ok = true;
 343+ try {
 344+ $this->setupDatabase();
 345+ $ok = true;
 346+
 347+ foreach ( $filenames as $filename ) {
 348+ $tests = new TestFileIterator( $filename, $this );
 349+ $ok = $this->runTests( $tests ) && $ok;
 350+ }
345351
346 - foreach ( $filenames as $filename ) {
347 - $tests = new TestFileIterator( $filename, $this );
348 - $ok = $this->runTests( $tests ) && $ok;
 352+ $this->teardownDatabase();
 353+ $this->recorder->report();
 354+ } catch (DBError $e) {
 355+ echo $e->getMessage();
349356 }
350 -
351 - $this->teardownDatabase();
352 - $this->recorder->report();
353357 $this->recorder->end();
354358
355359 return $ok;
@@ -703,7 +707,7 @@
704708 'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links'
705709 );
706710
707 - if ( in_array( $wgDBtype, array( 'mysql', 'sqlite' ) ) )
 711+ if ( in_array( $wgDBtype, array( 'mysql', 'sqlite', 'oracle' ) ) )
708712 array_push( $tables, 'searchindex' );
709713
710714 // Allow extensions to add to the list of tables to duplicate;
@@ -776,6 +780,15 @@
777781
778782 $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' );
779783
 784+ if ( $wgDBtype == 'oracle' ) {
 785+ # Insert 0 user to prevent FK violations
 786+
 787+ # Anonymous user
 788+ $db->insert( 'user', array(
 789+ 'user_id' => 0,
 790+ 'user_name' => 'Anonymous' ) );
 791+ }
 792+
780793 # Hack: insert a few Wikipedia in-project interwiki prefixes,
781794 # for testing inter-language links
782795 $db->insert( 'interwiki', array(
@@ -812,15 +825,6 @@
813826 ) );
814827
815828
816 - if ( $wgDBtype == 'oracle' ) {
817 - # Insert 0 user to prevent FK violations
818 -
819 - # Anonymous user
820 - $db->insert( 'user', array(
821 - 'user_id' => 0,
822 - 'user_name' => 'Anonymous' ) );
823 - }
824 -
825829 # Update certain things in site_stats
826830 $db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) );
827831
@@ -842,7 +846,7 @@
843847 'media_type' => MEDIATYPE_BITMAP,
844848 'mime' => 'image/jpeg',
845849 'metadata' => serialize( array() ),
846 - 'sha1' => sha1( '' ),
 850+ 'sha1' => wfBaseConvert( '', 16, 36, 31 ),
847851 'fileExists' => true
848852 ), $db->timestamp( '20010115123500' ), $user );
849853
@@ -856,7 +860,7 @@
857861 'media_type' => MEDIATYPE_BITMAP,
858862 'mime' => 'image/jpeg',
859863 'metadata' => serialize( array() ),
860 - 'sha1' => sha1( '' ),
 864+ 'sha1' => wfBaseConvert( '', 16, 36, 31 ),
861865 'fileExists' => true
862866 ), $db->timestamp( '20010115123500' ), $user );
863867 }
Index: trunk/phase3/maintenance/oracle/archives/patch_create_17_functions.sql
@@ -0,0 +1,125 @@
 2+define mw_prefix='{$wgDBprefix}';
 3+
 4+/*$mw$*/
 5+CREATE OR REPLACE PROCEDURE duplicate_table(p_tabname IN VARCHAR2,
 6+ p_oldprefix IN VARCHAR2,
 7+ p_newprefix IN VARCHAR2,
 8+ p_temporary IN BOOLEAN) IS
 9+ e_table_not_exist EXCEPTION;
 10+ PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
 11+ l_temp_ei_sql VARCHAR2(2000);
 12+BEGIN
 13+ BEGIN
 14+ EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
 15+ ' CASCADE CONSTRAINTS';
 16+ EXCEPTION
 17+ WHEN e_table_not_exist THEN
 18+ NULL;
 19+ END;
 20+ IF (p_temporary) THEN
 21+ EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
 22+ p_tabname || ' AS SELECT * FROM ' || p_oldprefix ||
 23+ p_tabname || ' WHERE ROWNUM = 0';
 24+ ELSE
 25+ EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname ||
 26+ ' AS SELECT * FROM ' || p_oldprefix || p_tabname ||
 27+ ' WHERE ROWNUM = 0';
 28+ END IF;
 29+ FOR rc IN (SELECT column_name, data_default
 30+ FROM user_tab_columns
 31+ WHERE table_name = p_oldprefix || p_tabname
 32+ AND data_default IS NOT NULL) LOOP
 33+ EXECUTE IMMEDIATE 'ALTER TABLE ' || p_newprefix || p_tabname ||
 34+ ' MODIFY ' || rc.column_name || ' DEFAULT ' ||
 35+ SUBSTR(rc.data_default, 1, 2000);
 36+ END LOOP;
 37+ FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('CONSTRAINT',
 38+ constraint_name),
 39+ 32767,
 40+ 1),
 41+ USER || '"."' || p_oldprefix,
 42+ USER || '"."' || p_newprefix),
 43+ '"' || constraint_name || '"',
 44+ '"' || p_newprefix || constraint_name || '"') DDLVC2,
 45+ constraint_name
 46+ FROM user_constraints uc
 47+ WHERE table_name = p_oldprefix || p_tabname
 48+ AND constraint_type = 'P') LOOP
 49+ l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
 50+ l_temp_ei_sql := SUBSTR(l_temp_ei_sql, 1, INSTR(l_temp_ei_sql, ')', INSTR(l_temp_ei_sql, 'PRIMARY KEY')+1)+1);
 51+ EXECUTE IMMEDIATE l_temp_ei_sql;
 52+ END LOOP;
 53+ IF (NOT p_temporary) THEN
 54+ FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
 55+ constraint_name),
 56+ 32767,
 57+ 1),
 58+ USER || '"."' || p_oldprefix,
 59+ USER || '"."' || p_newprefix) DDLVC2,
 60+ constraint_name
 61+ FROM user_constraints uc
 62+ WHERE table_name = p_oldprefix || p_tabname
 63+ AND constraint_type = 'R') LOOP
 64+ EXECUTE IMMEDIATE rc.ddlvc2;
 65+ END LOOP;
 66+ END IF;
 67+ FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
 68+ index_name),
 69+ 32767,
 70+ 1),
 71+ USER || '"."' || p_oldprefix,
 72+ USER || '"."' || p_newprefix),
 73+ '"' || index_name || '"',
 74+ '"' || p_newprefix || index_name || '"') DDLVC2,
 75+ index_name,
 76+ index_type
 77+ FROM user_indexes ui
 78+ WHERE table_name = p_oldprefix || p_tabname
 79+ AND index_type NOT IN ('LOB', 'DOMAIN')
 80+ AND NOT EXISTS
 81+ (SELECT NULL
 82+ FROM user_constraints
 83+ WHERE table_name = ui.table_name
 84+ AND constraint_name = ui.index_name)) LOOP
 85+ l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
 86+ l_temp_ei_sql := SUBSTR(l_temp_ei_sql, 1, INSTR(l_temp_ei_sql, ')', INSTR(l_temp_ei_sql, '"' || USER || '"."' || p_newprefix || '"')+1)+1);
 87+ EXECUTE IMMEDIATE l_temp_ei_sql;
 88+ END LOOP;
 89+ FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
 90+ trigger_name),
 91+ 32767,
 92+ 1)),
 93+ USER || '"."' || p_oldprefix,
 94+ USER || '"."' || p_newprefix),
 95+ ' ON ' || p_oldprefix || p_tabname,
 96+ ' ON ' || p_newprefix || p_tabname) DDLVC2,
 97+ trigger_name
 98+ FROM user_triggers
 99+ WHERE table_name = p_oldprefix || p_tabname) LOOP
 100+ l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'ALTER ') - 1);
 101+ dbms_output.put_line(l_temp_ei_sql);
 102+ EXECUTE IMMEDIATE l_temp_ei_sql;
 103+ END LOOP;
 104+END;
 105+/*$mw$*/
 106+
 107+CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
 108+
 109+/*$mw$*/
 110+CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS
 111+ v_line VARCHAR2(255);
 112+ v_status INTEGER := 0;
 113+BEGIN
 114+
 115+ LOOP
 116+ DBMS_OUTPUT.GET_LINE(v_line, v_status);
 117+ IF (v_status = 0) THEN RETURN; END IF;
 118+ PIPE ROW (v_line);
 119+ END LOOP;
 120+ RETURN;
 121+EXCEPTION
 122+ WHEN OTHERS THEN
 123+ RETURN;
 124+END;
 125+/*$mw$*/
 126+
Property changes on: trunk/phase3/maintenance/oracle/archives/patch_create_17_functions.sql
___________________________________________________________________
Added: svn:eol-style
1127 + native
Index: trunk/phase3/maintenance/oracle/archives/patch_16_17_schema_changes.sql
@@ -0,0 +1,97 @@
 2+define mw_prefix='{$wgDBprefix}';
 3+
 4+ALTER TABLE &mw_prefix.archive MODIFY ar_user DEFAULT 0 NOT NULL;
 5+ALTER TABLE &mw_prefix.archive MODIFY ar_deleted CHAR(1);
 6+CREATE INDEX &mw_prefix.archive_i03 ON &mw_prefix.archive (ar_namespace, ar_title, ar_rev_id);
 7+
 8+ALTER TABLE &mw_prefix.page MODIFY page_is_redirect default '0';
 9+ALTER TABLE &mw_prefix.page MODIFY page_is_new default '0';
 10+ALTER TABLE &mw_prefix.page MODIFY page_latest default 0;
 11+ALTER TABLE &mw_prefix.page MODIFY page_len default 0;
 12+
 13+ALTER TABLE &mw_prefix.categorylinks MODIFY cl_sortkey VARCHAR2(230);
 14+ALTER TABLE &mw_prefix.categorylinks ADD cl_sortkey_prefix VARCHAR2(255) DEFAULT '' NOT NULL;
 15+ALTER TABLE &mw_prefix.categorylinks ADD cl_collation VARCHAR2(32) DEFAULT '' NOT NULL;
 16+ALTER TABLE &mw_prefix.categorylinks ADD cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL;
 17+DROP INDEX &mw_prefix.categorylinks_i01;
 18+CREATE INDEX &mw_prefix.categorylinks_i01 ON &mw_prefix.categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
 19+CREATE INDEX &mw_prefix.categorylinks_i03 ON &mw_prefix.categorylinks (cl_collation);
 20+
 21+ALTER TABLE &mw_prefix.filearchive MODIFY fa_deleted_user DEFAULT 0 NOT NULL;
 22+ALTER TABLE &mw_prefix.filearchive MODIFY fa_size DEFAULT 0;
 23+ALTER TABLE &mw_prefix.filearchive MODIFY fa_width DEFAULT 0;
 24+ALTER TABLE &mw_prefix.filearchive MODIFY fa_height DEFAULT 0;
 25+ALTER TABLE &mw_prefix.filearchive MODIFY fa_bits DEFAULT 0 NOT NULL;
 26+ALTER TABLE &mw_prefix.filearchive MODIFY fa_user DEFAULT 0 NOT NULL;
 27+ALTER TABLE &mw_prefix.filearchive MODIFY fa_deleted DEFAULT 0;
 28+
 29+ALTER TABLE &mw_prefix.image MODIFY img_size DEFAULT 0;
 30+ALTER TABLE &mw_prefix.image MODIFY img_width DEFAULT 0;
 31+ALTER TABLE &mw_prefix.image MODIFY img_height DEFAULT 0;
 32+ALTER TABLE &mw_prefix.image MODIFY img_bits DEFAULT 0 NOT NULL;
 33+ALTER TABLE &mw_prefix.image MODIFY img_user DEFAULT 0 NOT NULL;
 34+
 35+ALTER TABLE &mw_prefix.interwiki ADD iw_api BLOB NOT NULL;
 36+ALTER TABLE &mw_prefix.interwiki ADD iw_wikiid VARCHAR2(64);
 37+
 38+ALTER TABLE &mw_prefix.ipblocks MODIFY ipb_user DEFAULT 0 NOT NULL;
 39+ALTER TABLE &mw_prefix.ipblocks MODIFY ipb_by DEFAULT 0;
 40+
 41+CREATE TABLE &mw_prefix.iwlinks (
 42+ iwl_from NUMBER DEFAULT 0 NOT NULL,
 43+ iwl_prefix VARCHAR2(20) DEFAULT '' NOT NULL,
 44+ iwl_title VARCHAR2(255) DEFAULT '' NOT NULL
 45+);
 46+CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01 ON &mw_prefix.iwlinks (iwl_from, iwl_prefix, iwl_title);
 47+CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02 ON &mw_prefix.iwlinks (iwl_prefix, iwl_title, iwl_from);
 48+
 49+ALTER TABLE &mw_prefix.logging MODIFY log_user DEFAULT 0 NOT NULL;
 50+ALTER TABLE &mw_prefix.logging MODIFY log_deleted CHAR(1);
 51+
 52+CREATE TABLE &mw_prefix.module_deps (
 53+ md_module VARCHAR2(255) NOT NULL,
 54+ md_skin VARCHAR2(32) NOT NULL,
 55+ md_deps BLOB NOT NULL
 56+);
 57+CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
 58+
 59+CREATE TABLE &mw_prefix.msg_resource_links (
 60+ mrl_resource VARCHAR2(255) NOT NULL,
 61+ mrl_message VARCHAR2(255) NOT NULL
 62+);
 63+CREATE UNIQUE INDEX &mw_prefix.msg_resource_links_u01 ON &mw_prefix.msg_resource_links (mrl_message, mrl_resource);
 64+
 65+CREATE TABLE &mw_prefix.msg_resource (
 66+ mr_resource VARCHAR2(255) NOT NULL,
 67+ mr_lang varchar2(32) NOT NULL,
 68+ mr_blob BLOB NOT NULL,
 69+ mr_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL
 70+) ;
 71+CREATE UNIQUE INDEX &mw_prefix.msg_resource_u01 ON &mw_prefix.msg_resource (mr_resource, mr_lang);
 72+
 73+ALTER TABLE &mw_prefix.oldimage MODIFY oi_name DEFAULT 0;
 74+ALTER TABLE &mw_prefix.oldimage MODIFY oi_size DEFAULT 0;
 75+ALTER TABLE &mw_prefix.oldimage MODIFY oi_width DEFAULT 0;
 76+ALTER TABLE &mw_prefix.oldimage MODIFY oi_height DEFAULT 0;
 77+ALTER TABLE &mw_prefix.oldimage MODIFY oi_bits DEFAULT 0;
 78+ALTER TABLE &mw_prefix.oldimage MODIFY oi_user DEFAULT 0 NOT NULL;
 79+
 80+ALTER TABLE &mw_prefix.querycache MODIFY qc_value DEFAULT 0;
 81+
 82+ALTER TABLE &mw_prefix.recentchanges MODIFY rc_user DEFAULT 0 NOT NULL;
 83+ALTER TABLE &mw_prefix.recentchanges MODIFY rc_cur_id DEFAULT 0 NOT NULL;
 84+ALTER TABLE &mw_prefix.recentchanges MODIFY rc_this_oldid DEFAULT 0;
 85+ALTER TABLE &mw_prefix.recentchanges MODIFY rc_last_oldid DEFAULT 0;
 86+ALTER TABLE &mw_prefix.recentchanges MODIFY rc_moved_to_ns DEFAULT 0 NOT NULL;
 87+ALTER TABLE &mw_prefix.recentchanges MODIFY rc_deleted CHAR(1);
 88+ALTER TABLE &mw_prefix.recentchanges MODIFY rc_logid DEFAULT 0;
 89+
 90+ALTER TABLE &mw_prefix.revision MODIFY rev_page NOT NULL;
 91+ALTER TABLE &mw_prefix.revision MODIFY rev_user DEFAULT 0;
 92+
 93+ALTER TABLE &mw_prefix.updatelog ADD ul_value BLOB;
 94+
 95+ALTER TABLE &mw_prefix.user_groups MODIFY ug_user DEFAULT 0 NOT NULL;
 96+
 97+ALTER TABLE &mw_prefix.user_newtalk MODIFY user_id DEFAULT 0;
 98+
Property changes on: trunk/phase3/maintenance/oracle/archives/patch_16_17_schema_changes.sql
___________________________________________________________________
Added: svn:eol-style
199 + native
Index: trunk/phase3/maintenance/oracle/archives/patch_fk_rename_deferred.sql
@@ -0,0 +1,41 @@
 2+define mw_prefix='{$wgDBprefix}';
 3+
 4+/*$mw$*/
 5+BEGIN
 6+-- drop all, recreate manual in case anyone was missing
 7+ FOR cc1 IN (SELECT uc.table_name,
 8+ uc.constraint_name
 9+ FROM user_constraints uc
 10+ WHERE uc.constraint_type = 'R') LOOP
 11+ EXECUTE IMMEDIATE 'ALTER TABLE &mw_prefix.' || cc1.table_name ||
 12+ ' DROP CONSTRAINT ' || cc1.constraint_name;
 13+ END LOOP;
 14+END;
 15+/*$mw$*/
 16+
 17+ALTER TABLE &mw_prefix.user_groups ADD CONSTRAINT &mw_prefix.user_groups_fk1 FOREIGN KEY (ug_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 18+ALTER TABLE &mw_prefix.user_newtalk ADD CONSTRAINT &mw_prefix.user_newtalk_fk1 FOREIGN KEY (user_id) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 19+ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk1 FOREIGN KEY (rev_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 20+ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk2 FOREIGN KEY (rev_user) REFERENCES &mw_prefix.mwuser(user_id) DEFERRABLE INITIALLY DEFERRED;
 21+ALTER TABLE &mw_prefix.archive ADD CONSTRAINT &mw_prefix.archive_fk1 FOREIGN KEY (ar_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 22+ALTER TABLE &mw_prefix.pagelinks ADD CONSTRAINT &mw_prefix.pagelinks_fk1 FOREIGN KEY (pl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 23+ALTER TABLE &mw_prefix.templatelinks ADD CONSTRAINT &mw_prefix.templatelinks_fk1 FOREIGN KEY (tl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 24+ALTER TABLE &mw_prefix.imagelinks ADD CONSTRAINT &mw_prefix.imagelinks_fk1 FOREIGN KEY (il_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 25+ALTER TABLE &mw_prefix.categorylinks ADD CONSTRAINT &mw_prefix.categorylinks_fk1 FOREIGN KEY (cl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 26+ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_fk1 FOREIGN KEY (el_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 27+ALTER TABLE &mw_prefix.langlinks ADD CONSTRAINT &mw_prefix.langlinks_fk1 FOREIGN KEY (ll_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 28+ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_fk1 FOREIGN KEY (ipb_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 29+ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_fk2 FOREIGN KEY (ipb_by) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 30+ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_fk1 FOREIGN KEY (img_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 31+ALTER TABLE &mw_prefix.oldimage ADD CONSTRAINT &mw_prefix.oldimage_fk1 FOREIGN KEY (oi_name) REFERENCES &mw_prefix.image(img_name) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 32+ALTER TABLE &mw_prefix.oldimage ADD CONSTRAINT &mw_prefix.oldimage_fk2 FOREIGN KEY (oi_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 33+ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_fk1 FOREIGN KEY (fa_deleted_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 34+ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_fk2 FOREIGN KEY (fa_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 35+ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk1 FOREIGN KEY (rc_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 36+ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 37+ALTER TABLE &mw_prefix.watchlist ADD CONSTRAINT &mw_prefix.watchlist_fk1 FOREIGN KEY (wl_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 38+ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_fk1 FOREIGN KEY (log_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 39+ALTER TABLE &mw_prefix.trackbacks ADD CONSTRAINT &mw_prefix.trackbacks_fk1 FOREIGN KEY (tb_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 40+ALTER TABLE &mw_prefix.redirect ADD CONSTRAINT &mw_prefix.redirect_fk1 FOREIGN KEY (rd_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 41+ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_fk1 FOREIGN KEY (pr_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 42+
Property changes on: trunk/phase3/maintenance/oracle/archives/patch_fk_rename_deferred.sql
___________________________________________________________________
Added: svn:eol-style
143 + native
Index: trunk/phase3/maintenance/oracle/tables.sql
@@ -29,17 +29,19 @@
3030 VALUES (user_user_id_seq.nextval,'Anonymous','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, '', current_timestamp, current_timestamp, 0);
3131
3232 CREATE TABLE &mw_prefix.user_groups (
33 - ug_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 33+ ug_user NUMBER DEFAULT 0 NOT NULL,
3434 ug_group VARCHAR2(16) NOT NULL
3535 );
 36+ALTER TABLE &mw_prefix.user_groups ADD CONSTRAINT &mw_prefix.user_groups_fk1 FOREIGN KEY (ug_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
3637 CREATE UNIQUE INDEX &mw_prefix.user_groups_u01 ON &mw_prefix.user_groups (ug_user,ug_group);
3738 CREATE INDEX &mw_prefix.user_groups_i01 ON &mw_prefix.user_groups (ug_group);
3839
3940 CREATE TABLE &mw_prefix.user_newtalk (
40 - user_id NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 41+ user_id NUMBER DEFAULT 0 NOT NULL,
4142 user_ip VARCHAR2(40) NULL,
4243 user_last_timestamp TIMESTAMP(6) WITH TIME ZONE
4344 );
 45+ALTER TABLE &mw_prefix.user_newtalk ADD CONSTRAINT &mw_prefix.user_newtalk_fk1 FOREIGN KEY (user_id) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
4446 CREATE INDEX &mw_prefix.user_newtalk_i01 ON &mw_prefix.user_newtalk (user_id);
4547 CREATE INDEX &mw_prefix.user_newtalk_i02 ON &mw_prefix.user_newtalk (user_ip);
4648
@@ -81,10 +83,10 @@
8284 CREATE SEQUENCE revision_rev_id_seq;
8385 CREATE TABLE &mw_prefix.revision (
8486 rev_id NUMBER NOT NULL,
85 - rev_page NUMBER NOT NULL REFERENCES &mw_prefix.page (page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 87+ rev_page NUMBER NOT NULL,
8688 rev_text_id NUMBER NULL,
8789 rev_comment VARCHAR2(255),
88 - rev_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) DEFERRABLE INITIALLY DEFERRED,
 90+ rev_user NUMBER DEFAULT 0 NOT NULL,
8991 rev_user_text VARCHAR2(255) NOT NULL,
9092 rev_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
9193 rev_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
@@ -93,6 +95,8 @@
9496 rev_parent_id NUMBER DEFAULT NULL
9597 );
9698 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_pk PRIMARY KEY (rev_id);
 99+ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk1 FOREIGN KEY (rev_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 100+ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk2 FOREIGN KEY (rev_user) REFERENCES &mw_prefix.mwuser(user_id) DEFERRABLE INITIALLY DEFERRED;
97101 CREATE UNIQUE INDEX &mw_prefix.revision_u01 ON &mw_prefix.revision (rev_page, rev_id);
98102 CREATE INDEX &mw_prefix.revision_i01 ON &mw_prefix.revision (rev_timestamp);
99103 CREATE INDEX &mw_prefix.revision_i02 ON &mw_prefix.revision (rev_page,rev_timestamp);
@@ -112,7 +116,7 @@
113117 ar_title VARCHAR2(255) NOT NULL,
114118 ar_text CLOB,
115119 ar_comment VARCHAR2(255),
116 - ar_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
 120+ ar_user NUMBER DEFAULT 0 NOT NULL,
117121 ar_user_text VARCHAR2(255) NOT NULL,
118122 ar_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
119123 ar_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
@@ -124,36 +128,40 @@
125129 ar_page_id NUMBER,
126130 ar_parent_id NUMBER
127131 );
 132+ALTER TABLE &mw_prefix.archive ADD CONSTRAINT &mw_prefix.archive_fk1 FOREIGN KEY (ar_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
128133 CREATE INDEX &mw_prefix.archive_i01 ON &mw_prefix.archive (ar_namespace,ar_title,ar_timestamp);
129134 CREATE INDEX &mw_prefix.archive_i02 ON &mw_prefix.archive (ar_user_text,ar_timestamp);
130135 CREATE INDEX &mw_prefix.archive_i03 ON &mw_prefix.archive (ar_namespace, ar_title, ar_rev_id);
131136
132137 CREATE TABLE &mw_prefix.pagelinks (
133 - pl_from NUMBER NOT NULL REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 138+ pl_from NUMBER NOT NULL,
134139 pl_namespace NUMBER DEFAULT 0 NOT NULL,
135140 pl_title VARCHAR2(255) NOT NULL
136141 );
 142+ALTER TABLE &mw_prefix.pagelinks ADD CONSTRAINT &mw_prefix.pagelinks_fk1 FOREIGN KEY (pl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
137143 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u01 ON &mw_prefix.pagelinks (pl_from,pl_namespace,pl_title);
138144 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u02 ON &mw_prefix.pagelinks (pl_namespace,pl_title,pl_from);
139145
140146 CREATE TABLE &mw_prefix.templatelinks (
141 - tl_from NUMBER NOT NULL REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 147+ tl_from NUMBER NOT NULL,
142148 tl_namespace NUMBER DEFAULT 0 NOT NULL,
143149 tl_title VARCHAR2(255) NOT NULL
144150 );
 151+ALTER TABLE &mw_prefix.templatelinks ADD CONSTRAINT &mw_prefix.templatelinks_fk1 FOREIGN KEY (tl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
145152 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u01 ON &mw_prefix.templatelinks (tl_from,tl_namespace,tl_title);
146153 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u02 ON &mw_prefix.templatelinks (tl_namespace,tl_title,tl_from);
147154
148155 CREATE TABLE &mw_prefix.imagelinks (
149 - il_from NUMBER NOT NULL REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 156+ il_from NUMBER NOT NULL,
150157 il_to VARCHAR2(255) NOT NULL
151158 );
 159+ALTER TABLE &mw_prefix.imagelinks ADD CONSTRAINT &mw_prefix.imagelinks_fk1 FOREIGN KEY (il_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
152160 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u01 ON &mw_prefix.imagelinks (il_from,il_to);
153161 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u02 ON &mw_prefix.imagelinks (il_to,il_from);
154162
155163
156164 CREATE TABLE &mw_prefix.categorylinks (
157 - cl_from NUMBER NOT NULL REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 165+ cl_from NUMBER NOT NULL,
158166 cl_to VARCHAR2(255) NOT NULL,
159167 cl_sortkey VARCHAR2(230),
160168 cl_sortkey_prefix VARCHAR2(255) DEFAULT '' NOT NULL,
@@ -161,6 +169,7 @@
162170 cl_collation VARCHAR2(32) DEFAULT '' NOT NULL,
163171 cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL
164172 );
 173+ALTER TABLE &mw_prefix.categorylinks ADD CONSTRAINT &mw_prefix.categorylinks_fk1 FOREIGN KEY (cl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
165174 CREATE UNIQUE INDEX &mw_prefix.categorylinks_u01 ON &mw_prefix.categorylinks (cl_from,cl_to);
166175 CREATE INDEX &mw_prefix.categorylinks_i01 ON &mw_prefix.categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
167176 CREATE INDEX &mw_prefix.categorylinks_i02 ON &mw_prefix.categorylinks (cl_to,cl_timestamp);
@@ -180,10 +189,11 @@
181190 CREATE INDEX &mw_prefix.category_i01 ON &mw_prefix.category (cat_pages);
182191
183192 CREATE TABLE &mw_prefix.externallinks (
184 - el_from NUMBER NOT NULL REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 193+ el_from NUMBER NOT NULL,
185194 el_to VARCHAR2(2048) NOT NULL,
186195 el_index VARCHAR2(2048) NOT NULL
187196 );
 197+ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_fk1 FOREIGN KEY (el_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
188198 CREATE INDEX &mw_prefix.externallinks_i01 ON &mw_prefix.externallinks (el_from, el_to);
189199 CREATE INDEX &mw_prefix.externallinks_i02 ON &mw_prefix.externallinks (el_to, el_from);
190200 CREATE INDEX &mw_prefix.externallinks_i03 ON &mw_prefix.externallinks (el_index);
@@ -196,10 +206,11 @@
197207 CREATE UNIQUE INDEX &mw_prefix.external_user_u01 ON &mw_prefix.external_user (eu_external_id);
198208
199209 CREATE TABLE &mw_prefix.langlinks (
200 - ll_from NUMBER NOT NULL REFERENCES &mw_prefix.page (page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 210+ ll_from NUMBER NOT NULL,
201211 ll_lang VARCHAR2(20),
202212 ll_title VARCHAR2(255)
203213 );
 214+ALTER TABLE &mw_prefix.langlinks ADD CONSTRAINT &mw_prefix.langlinks_fk1 FOREIGN KEY (ll_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
204215 CREATE UNIQUE INDEX &mw_prefix.langlinks_u01 ON &mw_prefix.langlinks (ll_from, ll_lang);
205216 CREATE INDEX &mw_prefix.langlinks_i01 ON &mw_prefix.langlinks (ll_lang, ll_title);
206217
@@ -232,8 +243,8 @@
233244 CREATE TABLE &mw_prefix.ipblocks (
234245 ipb_id NUMBER NOT NULL,
235246 ipb_address VARCHAR2(255) NULL,
236 - ipb_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
237 - ipb_by NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 247+ ipb_user NUMBER DEFAULT 0 NOT NULL,
 248+ ipb_by NUMBER DEFAULT 0 NOT NULL,
238249 ipb_by_text VARCHAR2(255) NOT NULL,
239250 ipb_reason VARCHAR2(255) NOT NULL,
240251 ipb_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
@@ -249,6 +260,8 @@
250261 ipb_allow_usertalk CHAR(1) DEFAULT '0' NOT NULL
251262 );
252263 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_pk PRIMARY KEY (ipb_id);
 264+ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_fk1 FOREIGN KEY (ipb_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 265+ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_fk2 FOREIGN KEY (ipb_by) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
253266 CREATE UNIQUE INDEX &mw_prefix.ipblocks_u01 ON &mw_prefix.ipblocks (ipb_address, ipb_user, ipb_auto, ipb_anon_only);
254267 CREATE INDEX &mw_prefix.ipblocks_i01 ON &mw_prefix.ipblocks (ipb_user);
255268 CREATE INDEX &mw_prefix.ipblocks_i02 ON &mw_prefix.ipblocks (ipb_range_start, ipb_range_end);
@@ -266,12 +279,13 @@
267280 img_major_mime VARCHAR2(32) DEFAULT 'unknown',
268281 img_minor_mime VARCHAR2(100) DEFAULT 'unknown',
269282 img_description VARCHAR2(255),
270 - img_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
 283+ img_user NUMBER DEFAULT 0 NOT NULL,
271284 img_user_text VARCHAR2(255) NOT NULL,
272285 img_timestamp TIMESTAMP(6) WITH TIME ZONE,
273286 img_sha1 VARCHAR2(32)
274287 );
275288 ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_pk PRIMARY KEY (img_name);
 289+ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_fk1 FOREIGN KEY (img_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
276290 CREATE INDEX &mw_prefix.image_i01 ON &mw_prefix.image (img_user_text,img_timestamp);
277291 CREATE INDEX &mw_prefix.image_i02 ON &mw_prefix.image (img_size);
278292 CREATE INDEX &mw_prefix.image_i03 ON &mw_prefix.image (img_timestamp);
@@ -279,14 +293,14 @@
280294
281295
282296 CREATE TABLE &mw_prefix.oldimage (
283 - oi_name VARCHAR2(255) DEFAULT 0 NOT NULL REFERENCES &mw_prefix.image(img_name) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
 297+ oi_name VARCHAR2(255) DEFAULT 0 NOT NULL,
284298 oi_archive_name VARCHAR2(255),
285299 oi_size NUMBER DEFAULT 0 NOT NULL,
286300 oi_width NUMBER DEFAULT 0 NOT NULL,
287301 oi_height NUMBER DEFAULT 0 NOT NULL,
288302 oi_bits NUMBER DEFAULT 0 NOT NULL,
289303 oi_description VARCHAR2(255),
290 - oi_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
 304+ oi_user NUMBER DEFAULT 0 NOT NULL,
291305 oi_user_text VARCHAR2(255) NOT NULL,
292306 oi_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
293307 oi_metadata CLOB,
@@ -296,6 +310,8 @@
297311 oi_deleted NUMBER DEFAULT 0 NOT NULL,
298312 oi_sha1 VARCHAR2(32)
299313 );
 314+ALTER TABLE &mw_prefix.oldimage ADD CONSTRAINT &mw_prefix.oldimage_fk1 FOREIGN KEY (oi_name) REFERENCES &mw_prefix.image(img_name) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 315+ALTER TABLE &mw_prefix.oldimage ADD CONSTRAINT &mw_prefix.oldimage_fk2 FOREIGN KEY (oi_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
300316 CREATE INDEX &mw_prefix.oldimage_i01 ON &mw_prefix.oldimage (oi_user_text,oi_timestamp);
301317 CREATE INDEX &mw_prefix.oldimage_i02 ON &mw_prefix.oldimage (oi_name,oi_timestamp);
302318 CREATE INDEX &mw_prefix.oldimage_i03 ON &mw_prefix.oldimage (oi_name,oi_archive_name);
@@ -309,7 +325,7 @@
310326 fa_archive_name VARCHAR2(255),
311327 fa_storage_group VARCHAR2(16),
312328 fa_storage_key VARCHAR2(64),
313 - fa_deleted_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
 329+ fa_deleted_user NUMBER DEFAULT 0 NOT NULL,
314330 fa_deleted_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
315331 fa_deleted_reason CLOB,
316332 fa_size NUMBER DEFAULT 0 NOT NULL,
@@ -321,12 +337,14 @@
322338 fa_major_mime VARCHAR2(32) DEFAULT 'unknown',
323339 fa_minor_mime VARCHAR2(100) DEFAULT 'unknown',
324340 fa_description VARCHAR2(255),
325 - fa_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
 341+ fa_user NUMBER DEFAULT 0 NOT NULL,
326342 fa_user_text VARCHAR2(255) NOT NULL,
327343 fa_timestamp TIMESTAMP(6) WITH TIME ZONE,
328344 fa_deleted NUMBER DEFAULT 0 NOT NULL
329345 );
330346 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_pk PRIMARY KEY (fa_id);
 347+ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_fk1 FOREIGN KEY (fa_deleted_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 348+ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_fk2 FOREIGN KEY (fa_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
331349 CREATE INDEX &mw_prefix.filearchive_i01 ON &mw_prefix.filearchive (fa_name, fa_timestamp);
332350 CREATE INDEX &mw_prefix.filearchive_i02 ON &mw_prefix.filearchive (fa_storage_group, fa_storage_key);
333351 CREATE INDEX &mw_prefix.filearchive_i03 ON &mw_prefix.filearchive (fa_deleted_timestamp);
@@ -337,7 +355,7 @@
338356 rc_id NUMBER NOT NULL,
339357 rc_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
340358 rc_cur_time TIMESTAMP(6) WITH TIME ZONE NOT NULL,
341 - rc_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
 359+ rc_user NUMBER DEFAULT 0 NOT NULL,
342360 rc_user_text VARCHAR2(255) NOT NULL,
343361 rc_namespace NUMBER DEFAULT 0 NOT NULL,
344362 rc_title VARCHAR2(255) NOT NULL,
@@ -362,6 +380,8 @@
363381 rc_params CLOB
364382 );
365383 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id);
 384+ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk1 FOREIGN KEY (rc_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
 385+ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
366386 CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
367387 CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
368388 CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
@@ -371,11 +391,12 @@
372392 CREATE INDEX &mw_prefix.recentchanges_i07 ON &mw_prefix.recentchanges (rc_user_text, rc_timestamp);
373393
374394 CREATE TABLE &mw_prefix.watchlist (
375 - wl_user NUMBER NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 395+ wl_user NUMBER NOT NULL,
376396 wl_namespace NUMBER DEFAULT 0 NOT NULL,
377397 wl_title VARCHAR2(255) NOT NULL,
378398 wl_notificationtimestamp TIMESTAMP(6) WITH TIME ZONE
379399 );
 400+ALTER TABLE &mw_prefix.watchlist ADD CONSTRAINT &mw_prefix.watchlist_fk1 FOREIGN KEY (wl_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
380401 CREATE UNIQUE INDEX &mw_prefix.watchlist_u01 ON &mw_prefix.watchlist (wl_user, wl_namespace, wl_title);
381402 CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title);
382403
@@ -435,16 +456,17 @@
436457 log_type VARCHAR2(10) NOT NULL,
437458 log_action VARCHAR2(10) NOT NULL,
438459 log_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
439 - log_user NUMBER DEFAULT 0 NOT NULL REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
 460+ log_user NUMBER DEFAULT 0 NOT NULL,
440461 log_user_text VARCHAR2(255),
441462 log_namespace NUMBER DEFAULT 0 NOT NULL,
442463 log_title VARCHAR2(255) NOT NULL,
443 - log_page NUMBER,
 464+ log_page NUMBER,
444465 log_comment VARCHAR2(255),
445466 log_params CLOB,
446467 log_deleted CHAR(1) DEFAULT '0' NOT NULL
447468 );
448469 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_pk PRIMARY KEY (log_id);
 470+ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_fk1 FOREIGN KEY (log_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
449471 CREATE INDEX &mw_prefix.logging_i01 ON &mw_prefix.logging (log_type, log_timestamp);
450472 CREATE INDEX &mw_prefix.logging_i02 ON &mw_prefix.logging (log_user, log_timestamp);
451473 CREATE INDEX &mw_prefix.logging_i03 ON &mw_prefix.logging (log_namespace, log_title, log_timestamp);
@@ -461,13 +483,14 @@
462484 CREATE SEQUENCE trackbacks_tb_id_seq;
463485 CREATE TABLE &mw_prefix.trackbacks (
464486 tb_id NUMBER NOT NULL,
465 - tb_page NUMBER REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 487+ tb_page NUMBER,
466488 tb_title VARCHAR2(255) NOT NULL,
467489 tb_url VARCHAR2(255) NOT NULL,
468490 tb_ex CLOB,
469491 tb_name VARCHAR2(255)
470492 );
471493 ALTER TABLE &mw_prefix.trackbacks ADD CONSTRAINT &mw_prefix.trackbacks_pk PRIMARY KEY (tb_id);
 494+ALTER TABLE &mw_prefix.trackbacks ADD CONSTRAINT &mw_prefix.trackbacks_fk1 FOREIGN KEY (tb_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
472495 CREATE INDEX &mw_prefix.trackbacks_i01 ON &mw_prefix.trackbacks (tb_page);
473496
474497 CREATE SEQUENCE job_job_id_seq;
@@ -488,12 +511,13 @@
489512 CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01 ON &mw_prefix.querycache_info (qci_type);
490513
491514 CREATE TABLE &mw_prefix.redirect (
492 - rd_from NUMBER NOT NULL REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 515+ rd_from NUMBER NOT NULL,
493516 rd_namespace NUMBER DEFAULT 0 NOT NULL,
494517 rd_title VARCHAR2(255) NOT NULL,
495518 rd_interwiki VARCHAR2(32),
496519 rd_fragment VARCHAR2(255)
497520 );
 521+ALTER TABLE &mw_prefix.redirect ADD CONSTRAINT &mw_prefix.redirect_fk1 FOREIGN KEY (rd_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
498522 CREATE INDEX &mw_prefix.redirect_i01 ON &mw_prefix.redirect (rd_namespace,rd_title,rd_from);
499523
500524 CREATE TABLE &mw_prefix.querycachetwo (
@@ -511,7 +535,7 @@
512536 CREATE SEQUENCE page_restrictions_pr_id_seq;
513537 CREATE TABLE &mw_prefix.page_restrictions (
514538 pr_id NUMBER NOT NULL,
515 - pr_page NUMBER NOT NULL REFERENCES &mw_prefix.page (page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
 539+ pr_page NUMBER NOT NULL,
516540 pr_type VARCHAR2(255) NOT NULL,
517541 pr_level VARCHAR2(255) NOT NULL,
518542 pr_cascade NUMBER NOT NULL,
@@ -519,6 +543,7 @@
520544 pr_expiry TIMESTAMP(6) WITH TIME ZONE NULL
521545 );
522546 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_pk PRIMARY KEY (pr_page,pr_type);
 547+ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_fk1 FOREIGN KEY (pr_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
523548 CREATE INDEX &mw_prefix.page_restrictions_i01 ON &mw_prefix.page_restrictions (pr_type,pr_level);
524549 CREATE INDEX &mw_prefix.page_restrictions_i02 ON &mw_prefix.page_restrictions (pr_level);
525550 CREATE INDEX &mw_prefix.page_restrictions_i03 ON &mw_prefix.page_restrictions (pr_cascade);
@@ -798,9 +823,7 @@
799824 END;
800825 /*$mw$*/
801826
802 -/*$mw$*/
803827 CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
804 -/*$mw$*/
805828
806829 /*$mw$*/
807830 CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -996,6 +996,7 @@
997997 if ( substr( $line, 0, 8 ) == '/*$mw$*/' ) {
998998 if ( $dollarquote ) {
999999 $dollarquote = false;
 1000+ $line = str_replace( '/*$mw$*/', '', $line ); // remove dollarquotes
10001001 $done = true;
10011002 } else {
10021003 $dollarquote = true;
Index: trunk/phase3/includes/installer/OracleUpdater.php
@@ -13,10 +13,19 @@
1414 * @since 1.17
1515 */
1616 class OracleUpdater extends DatabaseUpdater {
 17+
 18+ protected function __construct( DatabaseBase &$db, $shared ) {
 19+ define( 'MEDIAWIKI_INSTALL', true );
 20+ parent::__construct( $db, $shared );
 21+ }
 22+
1723 protected function getCoreUpdateList() {
1824 return array(
1925 // 1.16
2026 array( 'doNamespaceDefaults' ),
 27+ array( 'doFKRenameDeferr' ),
 28+ array( 'doFunctions17' ),
 29+ array( 'doSchemaUpgrade17' ),
2130 );
2231 }
2332
@@ -27,18 +36,58 @@
2837 * Oracle inserts NULL, so namespace fields should have a default value
2938 */
3039 protected function doNamespaceDefaults() {
 40+ $this->output( "Altering namespace fields with default value ... " );
3141 $meta = $this->db->fieldInfo( 'page', 'page_namespace' );
3242 if ( $meta->defaultValue() != null ) {
33 - $this->output( "... defaults seem to present on namespace fields\n" );
 43+ $this->output( "defaults seem to present on namespace fields\n" );
3444 return;
3545 }
3646
37 - $this->output( "Altering namespace fields with default value ..." );
3847 $this->applyPatch( 'patch_namespace_defaults.sql', false );
3948 $this->output( "ok\n" );
4049 }
4150
4251 /**
 52+ * Uniform FK names + deferrable state
 53+ */
 54+ protected function doFKRenameDeferr() {
 55+ $this->output( "Altering foreign keys ... " );
 56+ $meta = $this->db->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' );
 57+ $row = $meta->fetchRow();
 58+ if ( $row && $row['cnt'] > 0 ) {
 59+ $this->output( "at least one FK is deferrable, considering up to date\n" );
 60+ return;
 61+ }
 62+
 63+ $this->applyPatch( 'patch_fk_rename_deferred.sql', false );
 64+ $this->output( "ok\n" );
 65+ }
 66+
 67+ /**
 68+ * Recreate functions to 17 schema layout
 69+ */
 70+ protected function doFunctions17() {
 71+ $this->output( "Recreating functions ... " );
 72+ $this->applyPatch( 'patch_create_17_functions.sql', false );
 73+ $this->output( "ok\n" );
 74+ }
 75+
 76+ /**
 77+ * Schema upgrade 16->17
 78+ * there are no incremental patches prior to this
 79+ */
 80+ protected function doSchemaUpgrade17() {
 81+ $this->output( "Updating schema to 17 ... " );
 82+ // check if iwlinks table exists which was added in 1.17
 83+ if ( $this->db->tableExists( trim( $this->db->tableName( 'iwlinks' ) ) ) ) {
 84+ $this->output( "schema seem to be up to date.\n" );
 85+ return;
 86+ }
 87+ $this->applyPatch( 'patch_16_17_schema_changes.sql', false );
 88+ $this->output( "ok\n" );
 89+ }
 90+
 91+ /**
4392 * Overload: after this action field info table has to be rebuilt
4493 */
4594 public function doUpdates( $purge = true ) {
Index: trunk/phase3/includes/installer/OracleInstaller.php
@@ -176,15 +176,17 @@
177177 if ( !$status->isOK() ) {
178178 return $status;
179179 }
180 -
181 - global $_OracleDefTS, $_OracleTempTS;
182 - $_OracleDefTS = $this->getVar( '_OracleDefTS' );
183 - $_OracleTempTS = $this->getVar( '_OracleTempTS' );
184 - $error = $this->db->sourceFile( "$IP/maintenance/oracle/user.sql" );
185 - if ( $error !== true || !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
186 - $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error );
 180+
 181+ if ( !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
 182+ global $_OracleDefTS, $_OracleTempTS;
 183+ $_OracleDefTS = $this->getVar( '_OracleDefTS' );
 184+ $_OracleTempTS = $this->getVar( '_OracleTempTS' );
 185+ $error = $this->db->sourceFile( "$IP/maintenance/oracle/user.sql" );
 186+ if ( $error !== true || !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
 187+ $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error );
 188+ }
187189 }
188 -
 190+
189191 return $status;
190192 }
191193

Follow-up revisions

RevisionCommit summaryAuthorDate
r79745Fixes for r75545: don't use MEDIAWIKI_INSTALL in the updaters classes, it's n...demon19:25, 6 January 2011

Comments

#Comment by Freakolowsky (talk | contribs)   15:17, 27 October 2010

forgot to mention ... on parserTests

  • added DB error handling in runTestsFromFiles
  • changed sequence of db setup and included oracle in searchindex creation condition
  • replaced sha1 (returned 40 chars which broke insert into DB) with wfBaseConvert call
#Comment by MarkAHershberger (talk | contribs)   16:48, 8 December 2010

+			$ok = true;
+			
+			foreach ( $filenames as $filename ) {

You're leaving whitespace at the end of the empty line here.

#Comment by 😂 (talk | contribs)   13:05, 16 December 2010

+ define( 'MEDIAWIKI_INSTALL', true );

^ Is there a reason you're defining this here? Entry points to the installer should define this, it shouldn't be up to DB-specific code to set this define. Also, I'm wondering what the exact use-case is in DatabaseOracle, I'm not quite sure why you're skipping that code during installation.

Also, I'm curious if we can get rid of the define entirely. It's mainly used to keep MediaWiki from throwing exceptions it can't handle while in the old installer. I'm pretty sure this isn't really necessary in the new installer.

#Comment by Freakolowsky (talk | contribs)   14:04, 16 December 2010

The reason for this define is on line 314 of DatabaseOracle.php ... some code uses "AS alias" notation in statements which in some cases caused problems for oracle and as "AS" is not required in this context i simply stripped the "AS" keywords from the statements. But in some DDL cases you have to use this keywoard. And as DDL is processed only in install/upgrade processes i used this define to determine if i should strip those "AS" keywords or not. As far as i can remember that's the only time i use that define.

If you wish to remove that define and you have an alternative on how i could detect that i'm in upgrade/install (DDL) mode, please let me know and i'll change it. But keep in mind that this is done on every executed statement, so it should be a simple process.

#Comment by 😂 (talk | contribs)   19:21, 6 January 2011

Can we reuse DBO_SYSDBA here, or should I add a DBO_DDLMODE or something?

#Comment by 😂 (talk | contribs)   19:21, 6 January 2011

Answered my own question, I'm adding DBO_DDLMODE.

Status & tagging log