r53510 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53509‎ | r53510 | r53511 >
Date:01:54, 20 July 2009
Author:greg
Status:deferred
Tags:
Comment:
Full support for modified oldimage FK constraint to do ON UPDATE CASCASE as well as ON DELETE CASCADE. Thanks to Robert Fleming for reporting and supplying a patch in bug #19445.
Modified paths:
  • /trunk/phase3/maintenance/postgres/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -288,7 +288,7 @@
289289 oi_deleted SMALLINT NOT NULL DEFAULT 0,
290290 oi_sha1 TEXT NOT NULL DEFAULT ''
291291 );
292 -ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE ON UPDATE CASCADE;
 292+ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE ON UPDATE CASCADE;
293293 CREATE INDEX oi_name_timestamp ON oldimage (oi_name,oi_timestamp);
294294 CREATE INDEX oi_name_archive_name ON oldimage (oi_name,oi_archive_name);
295295 CREATE INDEX oi_sha1 ON oldimage (oi_sha1);
Index: trunk/phase3/maintenance/updaters.inc
@@ -1739,14 +1739,20 @@
17401740 dbsource(archive($nr[2]));
17411741 }
17421742
1743 - if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) {
1744 - wfOut( "Making foreign key on table \"oldimage\" (to image) a cascade delete\n" );
1745 - $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
1746 - $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ".
1747 - "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" );
 1743+ if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey_cascaded")) {
 1744+ wfOut( "... table \"oldimage\" has correct cascading delete/update foreign key to image\n" );
17481745 }
1749 - else
1750 - wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" );
 1746+ else {
 1747+ if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) {
 1748+ $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
 1749+ }
 1750+ if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey_cascade")) {
 1751+ $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey_cascade" );
 1752+ }
 1753+ wfOut( "Making foreign key on table \"oldimage\" (to image) a cascade delete/update\n" );
 1754+ $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded ".
 1755+ "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE ON UPDATE CASCADE" );
 1756+ }
17511757
17521758 if (!$wgDatabase->triggerExists("page", "page_deleted")) {
17531759 wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53509For oldimage table, do ON UPDATE CASCADE. Per bug #19445....greg01:42, 20 July 2009

Status & tagging log