Index: trunk/phase3/maintenance/oracle/archives/patch_rebuild_dupfunc.sql |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | BEGIN |
12 | 12 | BEGIN |
13 | 13 | EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname || |
14 | | - ' CASCADE CONSTRAINTS'; |
| 14 | + ' CASCADE CONSTRAINTS PURGE'; |
15 | 15 | EXCEPTION |
16 | 16 | WHEN e_table_not_exist THEN |
17 | 17 | NULL; |
— | — | @@ -20,8 +20,9 @@ |
21 | 21 | END IF; |
22 | 22 | IF (l_temporary) THEN |
23 | 23 | EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix || |
24 | | - p_tabname || ' AS SELECT * FROM ' || p_oldprefix || |
25 | | - p_tabname || ' WHERE ROWNUM = 0'; |
| 24 | + p_tabname || |
| 25 | + ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' || |
| 26 | + p_oldprefix || p_tabname || ' WHERE ROWNUM = 0'; |
26 | 27 | ELSE |
27 | 28 | EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname || |
28 | 29 | ' AS SELECT * FROM ' || p_oldprefix || p_tabname || |
— | — | @@ -68,7 +69,8 @@ |
69 | 70 | FROM user_constraints uc |
70 | 71 | WHERE table_name = p_oldprefix || p_tabname |
71 | 72 | AND constraint_type = 'R') LOOP |
72 | | - IF nvl(length(l_temp_ei_sql), 0) > 0 THEN |
| 73 | + IF nvl(length(l_temp_ei_sql), 0) > 0 AND |
| 74 | + INSTR(l_temp_ei_sql, 'PRIMARY KEY') = 0 THEN |
73 | 75 | EXECUTE IMMEDIATE l_temp_ei_sql; |
74 | 76 | END IF; |
75 | 77 | END LOOP; |
— | — | @@ -142,5 +144,6 @@ |
143 | 145 | END IF; |
144 | 146 | END LOOP; |
145 | 147 | END; |
| 148 | + |
146 | 149 | /*$mw$*/ |
147 | 150 | |
Index: trunk/phase3/maintenance/oracle/tables.sql |
— | — | @@ -781,7 +781,7 @@ |
782 | 782 | BEGIN |
783 | 783 | BEGIN |
784 | 784 | EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname || |
785 | | - ' CASCADE CONSTRAINTS'; |
| 785 | + ' CASCADE CONSTRAINTS PURGE'; |
786 | 786 | EXCEPTION |
787 | 787 | WHEN e_table_not_exist THEN |
788 | 788 | NULL; |
— | — | @@ -791,8 +791,9 @@ |
792 | 792 | END IF; |
793 | 793 | IF (l_temporary) THEN |
794 | 794 | EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix || |
795 | | - p_tabname || ' AS SELECT * FROM ' || p_oldprefix || |
796 | | - p_tabname || ' WHERE ROWNUM = 0'; |
| 795 | + p_tabname || |
| 796 | + ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' || |
| 797 | + p_oldprefix || p_tabname || ' WHERE ROWNUM = 0'; |
797 | 798 | ELSE |
798 | 799 | EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname || |
799 | 800 | ' AS SELECT * FROM ' || p_oldprefix || p_tabname || |
— | — | @@ -839,7 +840,8 @@ |
840 | 841 | FROM user_constraints uc |
841 | 842 | WHERE table_name = p_oldprefix || p_tabname |
842 | 843 | AND constraint_type = 'R') LOOP |
843 | | - IF nvl(length(l_temp_ei_sql), 0) > 0 THEN |
| 844 | + IF nvl(length(l_temp_ei_sql), 0) > 0 AND |
| 845 | + INSTR(l_temp_ei_sql, 'PRIMARY KEY') = 0 THEN |
844 | 846 | EXECUTE IMMEDIATE l_temp_ei_sql; |
845 | 847 | END IF; |
846 | 848 | END LOOP; |
Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php |
— | — | @@ -125,6 +125,22 @@ |
126 | 126 | $this->db->insert( 'user', array( |
127 | 127 | 'user_id' => 0, |
128 | 128 | 'user_name' => 'Anonymous' ) ); |
| 129 | + |
| 130 | + # Insert 0 page to prevent FK violations |
| 131 | + # Blank page |
| 132 | + $this->db->insert( 'page', array( |
| 133 | + 'page_id' => 0, |
| 134 | + 'page_namespace' => 0, |
| 135 | + 'page_title' => ' ', |
| 136 | + 'page_restrictions' => NULL, |
| 137 | + 'page_counter' => 0, |
| 138 | + 'page_is_redirect' => 0, |
| 139 | + 'page_is_new' => 0, |
| 140 | + 'page_random' => 0, |
| 141 | + 'page_touched' => $this->db->timestamp(), |
| 142 | + 'page_latest' => 0, |
| 143 | + 'page_len' => 0 ) ); |
| 144 | + |
129 | 145 | } |
130 | 146 | } |
131 | 147 | |
— | — | @@ -134,9 +150,29 @@ |
135 | 151 | private function resetDB() { |
136 | 152 | if( $this->db ) { |
137 | 153 | foreach( $this->listTables() as $tbl ) { |
138 | | - if( $tbl == 'interwiki' || $tbl == 'user' ) continue; |
139 | | - $this->db->delete( $tbl, '*', __METHOD__ ); |
| 154 | + if( $tbl == 'interwiki' || $tbl == 'user' || $tbl == 'MWUSER' ) continue; |
| 155 | + if ( $this->db->getType() == 'oracle' ) |
| 156 | + $this->db->query( 'TRUNCATE TABLE '.$this->db->tableName($tbl), __METHOD__ ); |
| 157 | + else |
| 158 | + $this->db->delete( $tbl, '*', __METHOD__ ); |
140 | 159 | } |
| 160 | + |
| 161 | + if ( $this->db->getType() == 'oracle' ) { |
| 162 | + # Insert 0 page to prevent FK violations |
| 163 | + # Blank page |
| 164 | + $this->db->insert( 'page', array( |
| 165 | + 'page_id' => 0, |
| 166 | + 'page_namespace' => 0, |
| 167 | + 'page_title' => ' ', |
| 168 | + 'page_restrictions' => NULL, |
| 169 | + 'page_counter' => 0, |
| 170 | + 'page_is_redirect' => 0, |
| 171 | + 'page_is_new' => 0, |
| 172 | + 'page_random' => 0, |
| 173 | + 'page_touched' => $this->db->timestamp(), |
| 174 | + 'page_latest' => 0, |
| 175 | + 'page_len' => 0 ) ); |
| 176 | + } |
141 | 177 | } |
142 | 178 | } |
143 | 179 | |
Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -745,7 +745,7 @@ |
746 | 746 | } |
747 | 747 | |
748 | 748 | function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseOracle::duplicateTableStructure' ) { |
749 | | - $temporary = $temporary ? 'TRUE' : 'FALSE'; |
| 749 | + $temporary = 'FALSE'; //$temporary ? 'TRUE' : 'FALSE'; |
750 | 750 | |
751 | 751 | $newName = strtoupper( $newName ); |
752 | 752 | $oldName = strtoupper( $oldName ); |
— | — | @@ -768,9 +768,9 @@ |
769 | 769 | |
770 | 770 | // dirty code ... i know |
771 | 771 | $endArray = array(); |
772 | | - $endArray[] = $prefix.'MWUSER'; |
773 | | - $endArray[] = $prefix.'PAGE'; |
774 | | - $endArray[] = $prefix.'IMAGE'; |
| 772 | + $endArray[] = strtoupper($prefix.'MWUSER'); |
| 773 | + $endArray[] = strtoupper($prefix.'PAGE'); |
| 774 | + $endArray[] = strtoupper($prefix.'IMAGE'); |
775 | 775 | $fixedOrderTabs = $endArray; |
776 | 776 | while (($row = $result->fetchRow()) !== false) { |
777 | 777 | if (!in_array($row['table_name'], $fixedOrderTabs)) |