Index: trunk/phase3/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql |
— | — | @@ -0,0 +1,5 @@ |
| 2 | +define mw_prefix='{$wgDBprefix}'; |
| 3 | + |
| 4 | +ALTER TABLE &mw_prefix.recentchanges DROP CONSTRAINT &mw_prefix.recentchanges_fk2; |
| 5 | +ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; |
| 6 | + |
Property changes on: trunk/phase3/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 7 | + native |
Index: trunk/phase3/maintenance/oracle/tables.sql |
— | — | @@ -420,7 +420,7 @@ |
421 | 421 | ); |
422 | 422 | ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id); |
423 | 423 | 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; |
424 | | -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; |
| 424 | +ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; |
425 | 425 | CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp); |
426 | 426 | CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title); |
427 | 427 | CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id); |
Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -1176,9 +1176,7 @@ |
1177 | 1177 | // a hack for deleting pages, users and images (which have non-nullable FKs) |
1178 | 1178 | // all deletions on these tables have transactions so final failure rollbacks these updates |
1179 | 1179 | $table = $this->tableName( $table ); |
1180 | | - if ( $table == $this->tableName( 'page' ) ) { |
1181 | | - $this->update( 'recentchanges', array( 'rc_cur_id' => 0 ), array( 'rc_cur_id' => $conds['page_id'] ), $fname ); |
1182 | | - } elseif ( $table == $this->tableName( 'user' ) ) { |
| 1180 | + if ( $table == $this->tableName( 'user' ) ) { |
1183 | 1181 | $this->update( 'archive', array( 'ar_user' => 0 ), array( 'ar_user' => $conds['user_id'] ), $fname ); |
1184 | 1182 | $this->update( 'ipblocks', array( 'ipb_user' => 0 ), array( 'ipb_user' => $conds['user_id'] ), $fname ); |
1185 | 1183 | $this->update( 'image', array( 'img_user' => 0 ), array( 'img_user' => $conds['user_id'] ), $fname ); |
Index: trunk/phase3/includes/installer/OracleUpdater.php |
— | — | @@ -36,6 +36,7 @@ |
37 | 37 | array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ), |
38 | 38 | array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ), |
39 | 39 | array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ), |
| 40 | + array( 'doRecentchangesFK2Cascade' ), |
40 | 41 | |
41 | 42 | //1.19 |
42 | 43 | array( 'addTable', 'config', 'patch-config.sql' ), |
— | — | @@ -49,7 +50,7 @@ |
50 | 51 | array( 'addIndex', 'page', 'i03', 'patch-page_redirect_namespace_len.sql' ), |
51 | 52 | array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ), |
52 | 53 | |
53 | | - // till 2.0 i guess |
| 54 | + // KEEP THIS AT THE BOTTOM!! |
54 | 55 | array( 'doRebuildDuplicateFunction' ), |
55 | 56 | |
56 | 57 | ); |
— | — | @@ -159,6 +160,24 @@ |
160 | 161 | } |
161 | 162 | |
162 | 163 | /** |
| 164 | + * Removed forcing of invalid state on recentchanges_fk2. |
| 165 | + * cascading taken in account in the deleting function |
| 166 | + */ |
| 167 | + protected function doRecentchangesFK2Cascade() { |
| 168 | + $this->output( "Altering RECENTCHANGES_FK2 ... " ); |
| 169 | + |
| 170 | + $meta = $this->db->query( 'SELECT 1 FROM all_constraints WHERE owner = \''.strtoupper($this->db->getDBname()).'\' AND constraint_name = \''.$this->db->tablePrefix().'RECENTCHANGES_FK2\' AND delete_rule = \'CASCADE\'' ); |
| 171 | + $row = $meta->fetchRow(); |
| 172 | + if ( $row ) { |
| 173 | + $this->output( "FK up to date\n" ); |
| 174 | + return; |
| 175 | + } |
| 176 | + |
| 177 | + $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false ); |
| 178 | + $this->output( "ok\n" ); |
| 179 | + } |
| 180 | + |
| 181 | + /** |
163 | 182 | * rebuilding of the function that duplicates tables for tests |
164 | 183 | */ |
165 | 184 | protected function doRebuildDuplicateFunction() { |
— | — | @@ -178,4 +197,15 @@ |
179 | 198 | $this->db->query( 'BEGIN fill_wiki_info; END;' ); |
180 | 199 | } |
181 | 200 | |
| 201 | + /** |
| 202 | + * Overload: because of the DDL_MODE tablename escaping is a bit dodgy |
| 203 | + */ |
| 204 | + protected function purgeCache() { |
| 205 | + # We can't guarantee that the user will be able to use TRUNCATE, |
| 206 | + # but we know that DELETE is available to us |
| 207 | + $this->output( "Purging caches..." ); |
| 208 | + $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ ); |
| 209 | + $this->output( "done.\n" ); |
| 210 | + } |
| 211 | + |
182 | 212 | } |