Index: branches/REL1_18/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: branches/REL1_18/phase3/maintenance/oracle/archives/patch_recentchanges_fk2_cascade.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 7 | + native |
Index: branches/REL1_18/phase3/maintenance/oracle/tables.sql |
— | — | @@ -386,7 +386,7 @@ |
387 | 387 | ); |
388 | 388 | ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id); |
389 | 389 | 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; |
390 | | -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; |
| 390 | +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; |
391 | 391 | CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp); |
392 | 392 | CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title); |
393 | 393 | CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id); |
Index: branches/REL1_18/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -1175,9 +1175,7 @@ |
1176 | 1176 | // a hack for deleting pages, users and images (which have non-nullable FKs) |
1177 | 1177 | // all deletions on these tables have transactions so final failure rollbacks these updates |
1178 | 1178 | $table = $this->tableName( $table ); |
1179 | | - if ( $table == $this->tableName( 'page' ) ) { |
1180 | | - $this->update( 'recentchanges', array( 'rc_cur_id' => 0 ), array( 'rc_cur_id' => $conds['page_id'] ), $fname ); |
1181 | | - } elseif ( $table == $this->tableName( 'user' ) ) { |
| 1179 | + if ( $table == $this->tableName( 'user' ) ) { |
1182 | 1180 | $this->update( 'archive', array( 'ar_user' => 0 ), array( 'ar_user' => $conds['user_id'] ), $fname ); |
1183 | 1181 | $this->update( 'ipblocks', array( 'ipb_user' => 0 ), array( 'ipb_user' => $conds['user_id'] ), $fname ); |
1184 | 1182 | $this->update( 'image', array( 'img_user' => 0 ), array( 'img_user' => $conds['user_id'] ), $fname ); |
Index: branches/REL1_18/phase3/includes/installer/OracleUpdater.php |
— | — | @@ -36,6 +36,9 @@ |
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' ), |
| 41 | + |
| 42 | + // KEEP THIS AT THE BOTTOM!! |
40 | 43 | array( 'doRebuildDuplicateFunction' ), |
41 | 44 | |
42 | 45 | ); |
— | — | @@ -135,6 +138,24 @@ |
136 | 139 | } |
137 | 140 | |
138 | 141 | /** |
| 142 | + * Removed forcing of invalid state on recentchanges_fk2. |
| 143 | + * cascading taken in account in the deleting function |
| 144 | + */ |
| 145 | + protected function doRecentchangesFK2Cascade() { |
| 146 | + $this->output( "Altering RECENTCHANGES_FK2 ... " ); |
| 147 | + |
| 148 | + $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\'' ); |
| 149 | + $row = $meta->fetchRow(); |
| 150 | + if ( $row ) { |
| 151 | + $this->output( "FK up to date\n" ); |
| 152 | + return; |
| 153 | + } |
| 154 | + |
| 155 | + $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false ); |
| 156 | + $this->output( "ok\n" ); |
| 157 | + } |
| 158 | + |
| 159 | + /** |
139 | 160 | * rebuilding of the function that duplicates tables for tests |
140 | 161 | */ |
141 | 162 | protected function doRebuildDuplicateFunction() { |
— | — | @@ -154,4 +175,15 @@ |
155 | 176 | $this->db->query( 'BEGIN fill_wiki_info; END;' ); |
156 | 177 | } |
157 | 178 | |
| 179 | + /** |
| 180 | + * Overload: because of the DDL_MODE tablename escaping is a bit dodgy |
| 181 | + */ |
| 182 | + protected function purgeCache() { |
| 183 | + # We can't guarantee that the user will be able to use TRUNCATE, |
| 184 | + # but we know that DELETE is available to us |
| 185 | + $this->output( "Purging caches..." ); |
| 186 | + $this->db->delete( '/*Q*/'.$this->db->tableName( 'objectcache' ), '*', __METHOD__ ); |
| 187 | + $this->output( "done.\n" ); |
| 188 | + } |
| 189 | + |
158 | 190 | } |