Closed Bug 275523 Opened 20 years ago Closed 20 years ago

Replace INNER JOIN in Flag searches with LEFT JOIN

Categories

(Bugzilla :: Query/Bug List, defect)

2.18
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.18

People

(Reporter: agrieco, Assigned: goobix)

References

Details

Attachments

(1 file)

Problem manifests itself as follows: When doing a boolean search for flag and flag requestee, the following error is seen: DBD::mysql::st execute failed: Not unique table/alias: 'flags_0' [for Statement "SELECT bugs.bug_id, bugs.bug_severity, bugs.priority, bugs.bug_status, bugs.resolution, bugs.bug_severity, bugs.priority, bugs.rep_platform, map_assigned_to.login_name, bugs.bug_status, bugs.resolution, bugs.short_desc FROM bugs, profiles AS map_assigned_to, flags flags_0, profiles requestees_0 LEFT JOIN flags flags_0 ON (bugs.bug_id = flags_0.bug_id AND flags_0.is_active = 1) LEFT JOIN flagtypes flagtypes_0 ON (flags_0.type_id = flagtypes_0.id) LEFT JOIN bug_group_map ON bug_group_map.bug_id = bugs.bug_id AND bug_group_map.group_id NOT IN (6,3,10,12,4,1,7,9,11,2,5,8) LEFT JOIN cc ON cc.bug_id = bugs.bug_id AND cc.who = 1 WHERE bugs.assigned_to = map_assigned_to.userid AND bugs.bug_id = flags_0.bug_id AND flags_0.requestee_id = requestees_0.userid AND (bugs.resolution IN ('')) AND (CONCAT(flagtypes_0.name, flags_0.status) = 'inforequired?') AND (requestees_0.login_name = 'agrieco@cisco.com') AND ((bug_group_map.group_id IS NULL) OR (bugs.reporter_accessible = 1 AND bugs.reporter = 1) OR (bugs.cclist_accessible = 1 AND cc.who IS NOT NULL) OR (bugs.assigned_to = 1) OR (bugs.qa_contact = 1) ) GROUP BY bugs.bug_id ORDER BY bugs.bug_status,bugs.priority,map_assigned_to.login_name,bugs.bug_id "] at Bugzilla/DB.pm line 62 Bugzilla::DB::SendSQL('SELECT bugs.bug_id, bugs.bug_severity, bugs.priority, bugs.bu...') called at /local/apache2/htdocs/dev_bugz/buglist.cgi line 770 thanks Comments from bug 275422: Hmm, both an inner join and a left join on the same table alias... oof. ------- Additional Comment #6 From Joel Peshkin 2004-12-20 20:08 PST [reply] ------- I did add code a while ago to consolidate multiple identical joins into the same join using the same alias. However, I doubt that it would help when the joins are not identical and they use the same alias. This is another case where we should be using a LEFT JOIN regardless (mysql4 will optimize them out when they aren't otherwise necessary). Please write a bug on that and have it block the LEFT JOIN bug.
Blocks: 245158
Blocks: 275408
Blocks: 252564
No longer blocks: 245158
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: consolidation of multiple joins using the same alias → Replace INNER JOIN in Flag searches with LEFT JOIN
Attached patch patch v1Splinter Review
Assignee: justdave → vladd
Status: NEW → ASSIGNED
Attachment #169854 - Flags: review?
This blocks a 2.18 blocker, so it's normal to be a blocker in itself. Requesting blocker flags, and review on the patch. agrieco: can you test this patch and see if it solves the symptoms? I did perform basic testing on my localhost and it seems ok. Joel: do you have time for this quick patch review, considering it's a 2.18 blocker? Thanks!
Flags: blocking2.20?
Flags: blocking2.18?
OS: Linux → All
Hardware: PC → All
Target Milestone: --- → Bugzilla 2.18
agrieco: this patch is for the 2.19 tree; it should work on 2.18 as well if you apply first the patch in bug 245158.
Comment on attachment 169854 [details] [diff] [review] patch v1 r=joel if you've tested it. My testing database isn't in good shape for this right now. This will probably be very slow on very large databases. If people are going to do this a lot, we should look up the userid first. That can be an enhancment later.
Attachment #169854 - Flags: review? → review+
Flags: approval?
Flags: approval2.18?
I have validated that this patch, and the patch for bug 245158 together work to fix this problem. My database is extremely small, so no useful performance info can be garnered. thanks for the fix! agrieco
No longer blocks: 275408
(In reply to comment #4) > This will probably be very slow on very large databases. If people are going > to do this a lot, we should look up the userid first. That can be an > enhancment later. Please file a bug requesting this before we forget. Anything that speeds it up is probably a good idea whether or not we think it's slow :) In any case, I'll take accuracy over speed anyway. :)
Flags: blocking2.20?
Flags: blocking2.20+
Flags: blocking2.18?
Flags: blocking2.18+
Flags: approval?
Flags: approval2.18?
Flags: approval2.18+
Flags: approval+
Whiteboard: patch awaiting checkin
I've opened bug 276566 about that one.
Checking in Search.pm; /cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v <-- Search.pm new revision: 1.71; previous revision: 1.70 Checking in Search.pm; /cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v <-- Search.pm new revision: 1.57.2.5; previous revision: 1.57.2.4
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Whiteboard: patch awaiting checkin
*** Bug 180684 has been marked as a duplicate of this bug. ***
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: