Index: trunk/phase3/maintenance/tests/parser/parserTest.inc |
— | — | @@ -339,16 +339,20 @@ |
340 | 340 | public function runTestsFromFiles( $filenames ) { |
341 | 341 | $GLOBALS['wgContLang'] = Language::factory( 'en' ); |
342 | 342 | $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 | + } |
345 | 351 | |
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(); |
349 | 356 | } |
350 | | - |
351 | | - $this->teardownDatabase(); |
352 | | - $this->recorder->report(); |
353 | 357 | $this->recorder->end(); |
354 | 358 | |
355 | 359 | return $ok; |
— | — | @@ -703,7 +707,7 @@ |
704 | 708 | 'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links' |
705 | 709 | ); |
706 | 710 | |
707 | | - if ( in_array( $wgDBtype, array( 'mysql', 'sqlite' ) ) ) |
| 711 | + if ( in_array( $wgDBtype, array( 'mysql', 'sqlite', 'oracle' ) ) ) |
708 | 712 | array_push( $tables, 'searchindex' ); |
709 | 713 | |
710 | 714 | // Allow extensions to add to the list of tables to duplicate; |
— | — | @@ -776,6 +780,15 @@ |
777 | 781 | |
778 | 782 | $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' ); |
779 | 783 | |
| 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 | + |
780 | 793 | # Hack: insert a few Wikipedia in-project interwiki prefixes, |
781 | 794 | # for testing inter-language links |
782 | 795 | $db->insert( 'interwiki', array( |
— | — | @@ -812,15 +825,6 @@ |
813 | 826 | ) ); |
814 | 827 | |
815 | 828 | |
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 | | - |
825 | 829 | # Update certain things in site_stats |
826 | 830 | $db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) ); |
827 | 831 | |
— | — | @@ -842,7 +846,7 @@ |
843 | 847 | 'media_type' => MEDIATYPE_BITMAP, |
844 | 848 | 'mime' => 'image/jpeg', |
845 | 849 | 'metadata' => serialize( array() ), |
846 | | - 'sha1' => sha1( '' ), |
| 850 | + 'sha1' => wfBaseConvert( '', 16, 36, 31 ), |
847 | 851 | 'fileExists' => true |
848 | 852 | ), $db->timestamp( '20010115123500' ), $user ); |
849 | 853 | |
— | — | @@ -856,7 +860,7 @@ |
857 | 861 | 'media_type' => MEDIATYPE_BITMAP, |
858 | 862 | 'mime' => 'image/jpeg', |
859 | 863 | 'metadata' => serialize( array() ), |
860 | | - 'sha1' => sha1( '' ), |
| 864 | + 'sha1' => wfBaseConvert( '', 16, 36, 31 ), |
861 | 865 | 'fileExists' => true |
862 | 866 | ), $db->timestamp( '20010115123500' ), $user ); |
863 | 867 | } |
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 |
1 | 127 | + 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 |
1 | 99 | + 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 |
1 | 43 | + native |
Index: trunk/phase3/maintenance/oracle/tables.sql |
— | — | @@ -29,17 +29,19 @@ |
30 | 30 | VALUES (user_user_id_seq.nextval,'Anonymous','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, '', current_timestamp, current_timestamp, 0); |
31 | 31 | |
32 | 32 | 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, |
34 | 34 | ug_group VARCHAR2(16) NOT NULL |
35 | 35 | ); |
| 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; |
36 | 37 | CREATE UNIQUE INDEX &mw_prefix.user_groups_u01 ON &mw_prefix.user_groups (ug_user,ug_group); |
37 | 38 | CREATE INDEX &mw_prefix.user_groups_i01 ON &mw_prefix.user_groups (ug_group); |
38 | 39 | |
39 | 40 | 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, |
41 | 42 | user_ip VARCHAR2(40) NULL, |
42 | 43 | user_last_timestamp TIMESTAMP(6) WITH TIME ZONE |
43 | 44 | ); |
| 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; |
44 | 46 | CREATE INDEX &mw_prefix.user_newtalk_i01 ON &mw_prefix.user_newtalk (user_id); |
45 | 47 | CREATE INDEX &mw_prefix.user_newtalk_i02 ON &mw_prefix.user_newtalk (user_ip); |
46 | 48 | |
— | — | @@ -81,10 +83,10 @@ |
82 | 84 | CREATE SEQUENCE revision_rev_id_seq; |
83 | 85 | CREATE TABLE &mw_prefix.revision ( |
84 | 86 | 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, |
86 | 88 | rev_text_id NUMBER NULL, |
87 | 89 | 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, |
89 | 91 | rev_user_text VARCHAR2(255) NOT NULL, |
90 | 92 | rev_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL, |
91 | 93 | rev_minor_edit CHAR(1) DEFAULT '0' NOT NULL, |
— | — | @@ -93,6 +95,8 @@ |
94 | 96 | rev_parent_id NUMBER DEFAULT NULL |
95 | 97 | ); |
96 | 98 | 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; |
97 | 101 | CREATE UNIQUE INDEX &mw_prefix.revision_u01 ON &mw_prefix.revision (rev_page, rev_id); |
98 | 102 | CREATE INDEX &mw_prefix.revision_i01 ON &mw_prefix.revision (rev_timestamp); |
99 | 103 | CREATE INDEX &mw_prefix.revision_i02 ON &mw_prefix.revision (rev_page,rev_timestamp); |
— | — | @@ -112,7 +116,7 @@ |
113 | 117 | ar_title VARCHAR2(255) NOT NULL, |
114 | 118 | ar_text CLOB, |
115 | 119 | 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, |
117 | 121 | ar_user_text VARCHAR2(255) NOT NULL, |
118 | 122 | ar_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL, |
119 | 123 | ar_minor_edit CHAR(1) DEFAULT '0' NOT NULL, |
— | — | @@ -124,36 +128,40 @@ |
125 | 129 | ar_page_id NUMBER, |
126 | 130 | ar_parent_id NUMBER |
127 | 131 | ); |
| 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; |
128 | 133 | CREATE INDEX &mw_prefix.archive_i01 ON &mw_prefix.archive (ar_namespace,ar_title,ar_timestamp); |
129 | 134 | CREATE INDEX &mw_prefix.archive_i02 ON &mw_prefix.archive (ar_user_text,ar_timestamp); |
130 | 135 | CREATE INDEX &mw_prefix.archive_i03 ON &mw_prefix.archive (ar_namespace, ar_title, ar_rev_id); |
131 | 136 | |
132 | 137 | 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, |
134 | 139 | pl_namespace NUMBER DEFAULT 0 NOT NULL, |
135 | 140 | pl_title VARCHAR2(255) NOT NULL |
136 | 141 | ); |
| 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; |
137 | 143 | CREATE UNIQUE INDEX &mw_prefix.pagelinks_u01 ON &mw_prefix.pagelinks (pl_from,pl_namespace,pl_title); |
138 | 144 | CREATE UNIQUE INDEX &mw_prefix.pagelinks_u02 ON &mw_prefix.pagelinks (pl_namespace,pl_title,pl_from); |
139 | 145 | |
140 | 146 | 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, |
142 | 148 | tl_namespace NUMBER DEFAULT 0 NOT NULL, |
143 | 149 | tl_title VARCHAR2(255) NOT NULL |
144 | 150 | ); |
| 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; |
145 | 152 | CREATE UNIQUE INDEX &mw_prefix.templatelinks_u01 ON &mw_prefix.templatelinks (tl_from,tl_namespace,tl_title); |
146 | 153 | CREATE UNIQUE INDEX &mw_prefix.templatelinks_u02 ON &mw_prefix.templatelinks (tl_namespace,tl_title,tl_from); |
147 | 154 | |
148 | 155 | 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, |
150 | 157 | il_to VARCHAR2(255) NOT NULL |
151 | 158 | ); |
| 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; |
152 | 160 | CREATE UNIQUE INDEX &mw_prefix.imagelinks_u01 ON &mw_prefix.imagelinks (il_from,il_to); |
153 | 161 | CREATE UNIQUE INDEX &mw_prefix.imagelinks_u02 ON &mw_prefix.imagelinks (il_to,il_from); |
154 | 162 | |
155 | 163 | |
156 | 164 | 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, |
158 | 166 | cl_to VARCHAR2(255) NOT NULL, |
159 | 167 | cl_sortkey VARCHAR2(230), |
160 | 168 | cl_sortkey_prefix VARCHAR2(255) DEFAULT '' NOT NULL, |
— | — | @@ -161,6 +169,7 @@ |
162 | 170 | cl_collation VARCHAR2(32) DEFAULT '' NOT NULL, |
163 | 171 | cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL |
164 | 172 | ); |
| 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; |
165 | 174 | CREATE UNIQUE INDEX &mw_prefix.categorylinks_u01 ON &mw_prefix.categorylinks (cl_from,cl_to); |
166 | 175 | CREATE INDEX &mw_prefix.categorylinks_i01 ON &mw_prefix.categorylinks (cl_to,cl_type,cl_sortkey,cl_from); |
167 | 176 | CREATE INDEX &mw_prefix.categorylinks_i02 ON &mw_prefix.categorylinks (cl_to,cl_timestamp); |
— | — | @@ -180,10 +189,11 @@ |
181 | 190 | CREATE INDEX &mw_prefix.category_i01 ON &mw_prefix.category (cat_pages); |
182 | 191 | |
183 | 192 | 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, |
185 | 194 | el_to VARCHAR2(2048) NOT NULL, |
186 | 195 | el_index VARCHAR2(2048) NOT NULL |
187 | 196 | ); |
| 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; |
188 | 198 | CREATE INDEX &mw_prefix.externallinks_i01 ON &mw_prefix.externallinks (el_from, el_to); |
189 | 199 | CREATE INDEX &mw_prefix.externallinks_i02 ON &mw_prefix.externallinks (el_to, el_from); |
190 | 200 | CREATE INDEX &mw_prefix.externallinks_i03 ON &mw_prefix.externallinks (el_index); |
— | — | @@ -196,10 +206,11 @@ |
197 | 207 | CREATE UNIQUE INDEX &mw_prefix.external_user_u01 ON &mw_prefix.external_user (eu_external_id); |
198 | 208 | |
199 | 209 | 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, |
201 | 211 | ll_lang VARCHAR2(20), |
202 | 212 | ll_title VARCHAR2(255) |
203 | 213 | ); |
| 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; |
204 | 215 | CREATE UNIQUE INDEX &mw_prefix.langlinks_u01 ON &mw_prefix.langlinks (ll_from, ll_lang); |
205 | 216 | CREATE INDEX &mw_prefix.langlinks_i01 ON &mw_prefix.langlinks (ll_lang, ll_title); |
206 | 217 | |
— | — | @@ -232,8 +243,8 @@ |
233 | 244 | CREATE TABLE &mw_prefix.ipblocks ( |
234 | 245 | ipb_id NUMBER NOT NULL, |
235 | 246 | 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, |
238 | 249 | ipb_by_text VARCHAR2(255) NOT NULL, |
239 | 250 | ipb_reason VARCHAR2(255) NOT NULL, |
240 | 251 | ipb_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL, |
— | — | @@ -249,6 +260,8 @@ |
250 | 261 | ipb_allow_usertalk CHAR(1) DEFAULT '0' NOT NULL |
251 | 262 | ); |
252 | 263 | 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; |
253 | 266 | CREATE UNIQUE INDEX &mw_prefix.ipblocks_u01 ON &mw_prefix.ipblocks (ipb_address, ipb_user, ipb_auto, ipb_anon_only); |
254 | 267 | CREATE INDEX &mw_prefix.ipblocks_i01 ON &mw_prefix.ipblocks (ipb_user); |
255 | 268 | CREATE INDEX &mw_prefix.ipblocks_i02 ON &mw_prefix.ipblocks (ipb_range_start, ipb_range_end); |
— | — | @@ -266,12 +279,13 @@ |
267 | 280 | img_major_mime VARCHAR2(32) DEFAULT 'unknown', |
268 | 281 | img_minor_mime VARCHAR2(100) DEFAULT 'unknown', |
269 | 282 | 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, |
271 | 284 | img_user_text VARCHAR2(255) NOT NULL, |
272 | 285 | img_timestamp TIMESTAMP(6) WITH TIME ZONE, |
273 | 286 | img_sha1 VARCHAR2(32) |
274 | 287 | ); |
275 | 288 | 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; |
276 | 290 | CREATE INDEX &mw_prefix.image_i01 ON &mw_prefix.image (img_user_text,img_timestamp); |
277 | 291 | CREATE INDEX &mw_prefix.image_i02 ON &mw_prefix.image (img_size); |
278 | 292 | CREATE INDEX &mw_prefix.image_i03 ON &mw_prefix.image (img_timestamp); |
— | — | @@ -279,14 +293,14 @@ |
280 | 294 | |
281 | 295 | |
282 | 296 | 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, |
284 | 298 | oi_archive_name VARCHAR2(255), |
285 | 299 | oi_size NUMBER DEFAULT 0 NOT NULL, |
286 | 300 | oi_width NUMBER DEFAULT 0 NOT NULL, |
287 | 301 | oi_height NUMBER DEFAULT 0 NOT NULL, |
288 | 302 | oi_bits NUMBER DEFAULT 0 NOT NULL, |
289 | 303 | 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, |
291 | 305 | oi_user_text VARCHAR2(255) NOT NULL, |
292 | 306 | oi_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL, |
293 | 307 | oi_metadata CLOB, |
— | — | @@ -296,6 +310,8 @@ |
297 | 311 | oi_deleted NUMBER DEFAULT 0 NOT NULL, |
298 | 312 | oi_sha1 VARCHAR2(32) |
299 | 313 | ); |
| 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; |
300 | 316 | CREATE INDEX &mw_prefix.oldimage_i01 ON &mw_prefix.oldimage (oi_user_text,oi_timestamp); |
301 | 317 | CREATE INDEX &mw_prefix.oldimage_i02 ON &mw_prefix.oldimage (oi_name,oi_timestamp); |
302 | 318 | CREATE INDEX &mw_prefix.oldimage_i03 ON &mw_prefix.oldimage (oi_name,oi_archive_name); |
— | — | @@ -309,7 +325,7 @@ |
310 | 326 | fa_archive_name VARCHAR2(255), |
311 | 327 | fa_storage_group VARCHAR2(16), |
312 | 328 | 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, |
314 | 330 | fa_deleted_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL, |
315 | 331 | fa_deleted_reason CLOB, |
316 | 332 | fa_size NUMBER DEFAULT 0 NOT NULL, |
— | — | @@ -321,12 +337,14 @@ |
322 | 338 | fa_major_mime VARCHAR2(32) DEFAULT 'unknown', |
323 | 339 | fa_minor_mime VARCHAR2(100) DEFAULT 'unknown', |
324 | 340 | 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, |
326 | 342 | fa_user_text VARCHAR2(255) NOT NULL, |
327 | 343 | fa_timestamp TIMESTAMP(6) WITH TIME ZONE, |
328 | 344 | fa_deleted NUMBER DEFAULT 0 NOT NULL |
329 | 345 | ); |
330 | 346 | 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; |
331 | 349 | CREATE INDEX &mw_prefix.filearchive_i01 ON &mw_prefix.filearchive (fa_name, fa_timestamp); |
332 | 350 | CREATE INDEX &mw_prefix.filearchive_i02 ON &mw_prefix.filearchive (fa_storage_group, fa_storage_key); |
333 | 351 | CREATE INDEX &mw_prefix.filearchive_i03 ON &mw_prefix.filearchive (fa_deleted_timestamp); |
— | — | @@ -337,7 +355,7 @@ |
338 | 356 | rc_id NUMBER NOT NULL, |
339 | 357 | rc_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL, |
340 | 358 | 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, |
342 | 360 | rc_user_text VARCHAR2(255) NOT NULL, |
343 | 361 | rc_namespace NUMBER DEFAULT 0 NOT NULL, |
344 | 362 | rc_title VARCHAR2(255) NOT NULL, |
— | — | @@ -362,6 +380,8 @@ |
363 | 381 | rc_params CLOB |
364 | 382 | ); |
365 | 383 | 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; |
366 | 386 | CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp); |
367 | 387 | CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title); |
368 | 388 | CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id); |
— | — | @@ -371,11 +391,12 @@ |
372 | 392 | CREATE INDEX &mw_prefix.recentchanges_i07 ON &mw_prefix.recentchanges (rc_user_text, rc_timestamp); |
373 | 393 | |
374 | 394 | 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, |
376 | 396 | wl_namespace NUMBER DEFAULT 0 NOT NULL, |
377 | 397 | wl_title VARCHAR2(255) NOT NULL, |
378 | 398 | wl_notificationtimestamp TIMESTAMP(6) WITH TIME ZONE |
379 | 399 | ); |
| 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; |
380 | 401 | CREATE UNIQUE INDEX &mw_prefix.watchlist_u01 ON &mw_prefix.watchlist (wl_user, wl_namespace, wl_title); |
381 | 402 | CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title); |
382 | 403 | |
— | — | @@ -435,16 +456,17 @@ |
436 | 457 | log_type VARCHAR2(10) NOT NULL, |
437 | 458 | log_action VARCHAR2(10) NOT NULL, |
438 | 459 | 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, |
440 | 461 | log_user_text VARCHAR2(255), |
441 | 462 | log_namespace NUMBER DEFAULT 0 NOT NULL, |
442 | 463 | log_title VARCHAR2(255) NOT NULL, |
443 | | - log_page NUMBER, |
| 464 | + log_page NUMBER, |
444 | 465 | log_comment VARCHAR2(255), |
445 | 466 | log_params CLOB, |
446 | 467 | log_deleted CHAR(1) DEFAULT '0' NOT NULL |
447 | 468 | ); |
448 | 469 | 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; |
449 | 471 | CREATE INDEX &mw_prefix.logging_i01 ON &mw_prefix.logging (log_type, log_timestamp); |
450 | 472 | CREATE INDEX &mw_prefix.logging_i02 ON &mw_prefix.logging (log_user, log_timestamp); |
451 | 473 | CREATE INDEX &mw_prefix.logging_i03 ON &mw_prefix.logging (log_namespace, log_title, log_timestamp); |
— | — | @@ -461,13 +483,14 @@ |
462 | 484 | CREATE SEQUENCE trackbacks_tb_id_seq; |
463 | 485 | CREATE TABLE &mw_prefix.trackbacks ( |
464 | 486 | 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, |
466 | 488 | tb_title VARCHAR2(255) NOT NULL, |
467 | 489 | tb_url VARCHAR2(255) NOT NULL, |
468 | 490 | tb_ex CLOB, |
469 | 491 | tb_name VARCHAR2(255) |
470 | 492 | ); |
471 | 493 | 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; |
472 | 495 | CREATE INDEX &mw_prefix.trackbacks_i01 ON &mw_prefix.trackbacks (tb_page); |
473 | 496 | |
474 | 497 | CREATE SEQUENCE job_job_id_seq; |
— | — | @@ -488,12 +511,13 @@ |
489 | 512 | CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01 ON &mw_prefix.querycache_info (qci_type); |
490 | 513 | |
491 | 514 | 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, |
493 | 516 | rd_namespace NUMBER DEFAULT 0 NOT NULL, |
494 | 517 | rd_title VARCHAR2(255) NOT NULL, |
495 | 518 | rd_interwiki VARCHAR2(32), |
496 | 519 | rd_fragment VARCHAR2(255) |
497 | 520 | ); |
| 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; |
498 | 522 | CREATE INDEX &mw_prefix.redirect_i01 ON &mw_prefix.redirect (rd_namespace,rd_title,rd_from); |
499 | 523 | |
500 | 524 | CREATE TABLE &mw_prefix.querycachetwo ( |
— | — | @@ -511,7 +535,7 @@ |
512 | 536 | CREATE SEQUENCE page_restrictions_pr_id_seq; |
513 | 537 | CREATE TABLE &mw_prefix.page_restrictions ( |
514 | 538 | 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, |
516 | 540 | pr_type VARCHAR2(255) NOT NULL, |
517 | 541 | pr_level VARCHAR2(255) NOT NULL, |
518 | 542 | pr_cascade NUMBER NOT NULL, |
— | — | @@ -519,6 +543,7 @@ |
520 | 544 | pr_expiry TIMESTAMP(6) WITH TIME ZONE NULL |
521 | 545 | ); |
522 | 546 | 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; |
523 | 548 | CREATE INDEX &mw_prefix.page_restrictions_i01 ON &mw_prefix.page_restrictions (pr_type,pr_level); |
524 | 549 | CREATE INDEX &mw_prefix.page_restrictions_i02 ON &mw_prefix.page_restrictions (pr_level); |
525 | 550 | CREATE INDEX &mw_prefix.page_restrictions_i03 ON &mw_prefix.page_restrictions (pr_cascade); |
— | — | @@ -798,9 +823,7 @@ |
799 | 824 | END; |
800 | 825 | /*$mw$*/ |
801 | 826 | |
802 | | -/*$mw$*/ |
803 | 827 | CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255); |
804 | | -/*$mw$*/ |
805 | 828 | |
806 | 829 | /*$mw$*/ |
807 | 830 | CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS |
Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -996,6 +996,7 @@ |
997 | 997 | if ( substr( $line, 0, 8 ) == '/*$mw$*/' ) { |
998 | 998 | if ( $dollarquote ) { |
999 | 999 | $dollarquote = false; |
| 1000 | + $line = str_replace( '/*$mw$*/', '', $line ); // remove dollarquotes |
1000 | 1001 | $done = true; |
1001 | 1002 | } else { |
1002 | 1003 | $dollarquote = true; |
Index: trunk/phase3/includes/installer/OracleUpdater.php |
— | — | @@ -13,10 +13,19 @@ |
14 | 14 | * @since 1.17 |
15 | 15 | */ |
16 | 16 | class OracleUpdater extends DatabaseUpdater { |
| 17 | + |
| 18 | + protected function __construct( DatabaseBase &$db, $shared ) { |
| 19 | + define( 'MEDIAWIKI_INSTALL', true ); |
| 20 | + parent::__construct( $db, $shared ); |
| 21 | + } |
| 22 | + |
17 | 23 | protected function getCoreUpdateList() { |
18 | 24 | return array( |
19 | 25 | // 1.16 |
20 | 26 | array( 'doNamespaceDefaults' ), |
| 27 | + array( 'doFKRenameDeferr' ), |
| 28 | + array( 'doFunctions17' ), |
| 29 | + array( 'doSchemaUpgrade17' ), |
21 | 30 | ); |
22 | 31 | } |
23 | 32 | |
— | — | @@ -27,18 +36,58 @@ |
28 | 37 | * Oracle inserts NULL, so namespace fields should have a default value |
29 | 38 | */ |
30 | 39 | protected function doNamespaceDefaults() { |
| 40 | + $this->output( "Altering namespace fields with default value ... " ); |
31 | 41 | $meta = $this->db->fieldInfo( 'page', 'page_namespace' ); |
32 | 42 | 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" ); |
34 | 44 | return; |
35 | 45 | } |
36 | 46 | |
37 | | - $this->output( "Altering namespace fields with default value ..." ); |
38 | 47 | $this->applyPatch( 'patch_namespace_defaults.sql', false ); |
39 | 48 | $this->output( "ok\n" ); |
40 | 49 | } |
41 | 50 | |
42 | 51 | /** |
| 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 | + /** |
43 | 92 | * Overload: after this action field info table has to be rebuilt |
44 | 93 | */ |
45 | 94 | public function doUpdates( $purge = true ) { |
Index: trunk/phase3/includes/installer/OracleInstaller.php |
— | — | @@ -176,15 +176,17 @@ |
177 | 177 | if ( !$status->isOK() ) { |
178 | 178 | return $status; |
179 | 179 | } |
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 | + } |
187 | 189 | } |
188 | | - |
| 190 | + |
189 | 191 | return $status; |
190 | 192 | } |
191 | 193 | |