Created attachment 346067 [details] [diff] [review] Patch to reorder SQL when removing a shared saved search (v1) If you have a saved search that you are sharing with another group and you want to delete it, it causes a SQL error when clicking 'Forget' from the userpreferences.cgi screen. [Mon Nov 03 12:58:51 2008] [error] DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`bugs3/namedquery_group_map`, CONSTRAINT `fk_namedquery_group_map_namedquery_id_namedqueries_id` FOREIGN KEY (`namedquery_id`) REFERENCES `namedqueries` (`id`) ON UPDATE CASCADE) [for Statement "DELETE FROM namedqueries\n WHERE id = ?"] at /var/www/html/bugzilla/buglist.cgi line 509 Looking in buglist.cgi, the code is trying to remove the query in namedqueries before it has deleted the row in namedquery_group_map. Reversing the order of SQL statements solves the issue. Patch attached to fix. Dave
I don't get it. The constraint is supposed to delete parents as well. Why doesn't this work?
Hum ok, the FK constraint is not 3.2, only on tip. But in this case, why does it whine at all?
Actually this is not an upstream bug but a miss configured FK constraint on our end. The original code works in 3.2 since 3.2 does not yet have a FK constraint for the namedquery_group_map table and tip has the proper ON DELETE CASCADE which will remove the extra data automatically. I still feel that the patch I have submitted does though order the statements properly and would make since for a database that a) has their FK misconfigured or b) doesn't have a FK configured at all. Let me know if I should close this bug as NOTABUG or commit the patch. Dave
Yeah, NOTABUG for us, upstream.
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.