Closed Bug 245158 Opened 18 years ago Closed 17 years ago

Search.pm fails if multiple LEFT JOINs are on the same table in the same chart

Categories

(Bugzilla :: Query/Bug List, defect, P2)

2.17.7

Tracking

()

RESOLVED FIXED
Bugzilla 2.18

People

(Reporter: bugreport, Assigned: bugreport)

References

Details

Attachments

(1 file, 3 obsolete files)

If, in a single chart, I try to search for 
"CC" "contains" "justdave" AND
"CC" "contains" "@bugzilla.org"
the resulting query will fail because it tries to do 2 distinct LEFT JOIN
operations on the same table with the same alias.

In order for this to work properly (see bug 237107), Search.pm must do a single
LEFT JOIN for each such case and merge the ON criteria.
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → Bugzilla 2.18
Attachment #149679 - Flags: review?
Attachment #149679 - Attachment is obsolete: true
Attachment #149683 - Flags: review?
Attachment #149679 - Flags: review?
Attachment #149683 - Flags: review?
Attachment #149683 - Attachment is obsolete: true
Attachment #149685 - Flags: review?
Flags: blocking2.18?
Comment on attachment 149685 [details] [diff] [review]
v3 - makes sure that ON clauses are in parentheses before ANDing them

grr...	justdave is right
Attachment #149685 - Attachment is obsolete: true
Attachment #149685 - Flags: review?
Attachment #151257 - Flags: review?(justdave)
Attachment #151257 - Flags: review?(dkl)
Yeah, this looks pretty straightforward, but something about it just makes me
want to wait until we branch to check it in....  (blocking2.18-)
Flags: blocking2.18? → blocking2.18-
Target Milestone: Bugzilla 2.18 → Bugzilla 2.20
Blocks: 245272
Comment on attachment 151257 [details] [diff] [review]
revised - append conditons to correct JOIN 

r=zach
Attachment #151257 - Flags: review?(justdave) → review+
Flags: approval?
Blocks: 226434
Attachment #151257 - Flags: review?(dkl)
Flags: approval? → approval+
Checking in Bugzilla/Search.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v  <--  Search.pm
new revision: 1.58; previous revision: 1.57
done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
IS this valid? You can left join to yourself, perfectly validly.
Yes, this is valid.  

The reason it fails is the same table alias is used.  When we are in the same
chart, we DO want to combine all the conditions on the same left join rather
than creating a new alias.
Actually, I didn't answer that very completely...

The fix combines the JOINs only if they use the identical table alias.  So,
there are lots of cases where we want to join the same table several times and
those are untouched.  This only combines the joins when we used the same alias
(previously an error condition) because we meant to do that.
Let's go ahead and put this on the 2.18 branch.  It's been tested enough now
that I trust it on the branch, and it's a useful fix.
Depends on: 275523
No longer depends on: 275523
Requesting approval for 2.18 checkin (patch applies cleanly)
Status: RESOLVED → REOPENED
Flags: approval2.18?
Resolution: FIXED → ---
Flags: approval2.18? → approval2.18+
Target Milestone: Bugzilla 2.20 → Bugzilla 2.18
*** Bug 275408 has been marked as a duplicate of this bug. ***
Joel: can you check this in for 2.18? It's pretty critical for that release :-)
Status: REOPENED → ASSIGNED
Checked in on 2.18 branch

Checking in Bugzilla/Search.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v  <--  Search.pm
new revision: 1.57.2.7; previous revision: 1.57.2.6
done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago17 years ago
Resolution: --- → FIXED
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.