Bug 428173

Summary: Searching for two flags does not find anything
Product: [Community] Bugzilla Reporter: Jan Pazdziora <jpazdziora>
Component: Query/Bug ListAssignee: PnT DevOps Devs <hss-ied-bugs>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: 3.6CC: agk, dkl, sgreen
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: https://bugzilla.redhat.com/buglist.cgi?query_format=&short_desc_type=allwordssubstr&short_desc=&version=&component=&target_milestone=&query_format=advanced&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&fixed_in_type=allwordssubstr&fixed_in=&qa_whiteboard_type=allwordssubstr&qa_whiteboard=&devel_whiteboard_type=allwordssubstr&devel_whiteboard=&keywords_type=allwords&keywords=&cust_facing=&cust_facing_type=substring&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailcc2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&changedin=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=sat-510%2B&field0-1-0=flagtypes.name&type0-1-0=equals&value0-1-0=pm_ack%3F
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-08-27 08:12:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Pazdziora 2008-01-09 19:25:32 UTC
Description of problem:

I try to find bugs that have two particular flags set. So I use the advanced
query and into Advanced Searching Using Boolean Charts put 'Flag' 'is equal to'
value1 And 'Flag' 'is equal to' value2.

Version-Release number of selected component (if applicable):

2.18-rh (bugzilla at bugzilla.redhat.com as of today).

How reproducible:

Deterministic.

Steps to Reproduce:
1. Use the URL in URL of this bugzilla or just create advanced query asking for
two flags.
  
Actual results:

Software error:

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.alias, bugs.bug_severity, bugs.priority,
bugs.rep_platform, map_assigned_to.login_name, bugs.bug_status, bugs.resolution,
bugs.short_desc FROM bugs LEFT JOIN bug_group_map  ON bug_group_map.bug_id =
bugs.bug_id  LEFT JOIN cc ON cc.bug_id = bugs.bug_id AND cc.who = 62946 LEFT
JOIN flags AS flags_0 ON bugs.bug_id = flags_0.bug_id AND flags_0.is_active = 1
LEFT JOIN flagtypes AS flagtypes_0 ON flags_0.type_id = flagtypes_0.id LEFT JOIN
flags AS flags_0 ON bugs.bug_id = flags_0.bug_id AND flags_0.is_active = 1 LEFT
JOIN flagtypes AS flagtypes_0 ON flags_0.type_id = flagtypes_0.id , profiles AS
map_assigned_to WHERE bugs.assigned_to = map_assigned_to.userid AND
((CONCAT(flagtypes_0.name,flags_0.status) = 'sat-510+') AND
(CONCAT(flagtypes_0.name,flags_0.status) = 'pm_ack?')) AND
((bug_group_map.group_id IS NULL)  OR bug_group_map.group_id IN
(81,134,106,152,149,75,68,148,138,144,140,12,79,76,67,41,161,127,58,122,141,35,133,7,62,126,93,146,72,11,50,39,10,33,107,22,4,119,78,123,145,108,139,44,124,150,121,85,92,91,137,15,80,21,142,61,155,83,74,147,94)
 OR (bugs.reporter_accessible = 1 AND bugs.reporter = 62946)  OR
(bugs.cclist_accessible = 1 AND cc.who IS NOT NULL)  OR (bugs.assigned_to =
62946)  OR (bugs.qa_contact = 62946) ) GROUP BY bugs.bug_id,
bugs.bug_id,bugs.bug_severity,bugs.priority,bugs.bug_status,bugs.resolution,bugs.alias,bugs.bug_severity,bugs.priority,bugs.rep_platform,map_assigned_to.login_name,bugs.bug_status,bugs.resolution,bugs.short_desc
ORDER BY map_assigned_to.login_name,bugs.alias,bugs.bug_id asc"] at
Bugzilla/DB.pm line 71
	Bugzilla::DB::SendSQL('SELECT bugs.bug_id, bugs.bug_severity, bugs.priority,
bugs.bu...') called at /var/www/html/bugzilla/buglist.cgi line 659

For help, please send mail to the webmaster (bugzilla-owner), giving
this error message and the time and date of the error. 

Expected results:

No error, bug list with bugs having both those flags set.

Additional info:

Comment 1 David Lawrence 2008-09-16 16:55:44 UTC
Red Hat Bugzilla is now using version 3.2 of the Bugzilla codebase and therefore this bug will need to be re-verified against the new release. With the updated code this bug may no longer be relevant or may have been fixed in the new code.
Updating bug version to 3.2.

Comment 2 Jan Pazdziora 2008-09-17 06:42:44 UTC
Bugzilla 3.2 no longer gives the database error but it does not produce the correct output either.

Consider query

https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&product=Red+Hat+Network+Satellite&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=sat-5.2.0%2B

which returns RHN Satellite bugs with sat-5.2.0+ set (102 bugzillas found today).

Consider query

https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&product=Red+Hat+Network+Satellite&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=pm_ack%2B

which returns RHN Satellite bugs with pm_ack+ set (1033 bugzillas found today).

Now let's try to find bugzillas that have both flags set, for example 186920, 441342, or 441526:

https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&product=Red+Hat+Network+Satellite&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=sat-5.2.0%2B&field0-1-0=flagtypes.name&type0-1-0=equals&value0-1-0=pm_ack%2Bfield0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=pm_ack%2B

The above produces Zarro Boogs found.

Not the expected result.

I've updated this bugzilla's summary.

Comment 3 David Lawrence 2008-11-25 22:16:57 UTC
We may need to push this upstream or work in cooperation with them to find a solution to this problem.

Comment 4 David Lawrence 2010-01-15 16:56:06 UTC
Red Hat Bugzilla is now using version 3.4 of the Bugzilla codebase and
therefore this bug will need to be re-verified against the new release. With
the updated code this bug may no longer be relevant or may have been fixed in
the new code. Updating bug version to 3.4.

Comment 5 David Lawrence 2010-08-25 21:44:22 UTC
Red Hat has now upgraded to Bugzilla 3.6 and this bug will now be reassigned to that version. It would be helpful to the Bugzilla Development Team if this bug is verified to still be an issue with the latest version. If it is no longer an issue, then feel free to close, otherwise please comment that it is still a problem and we will try to address the issue as soon as we can.

Thanks
Bugzilla Development Team

Comment 7 David Lawrence 2010-08-26 17:45:07 UTC
When comparing different values for the same Bugzilla field, there is a flaw in the SQL that is generated which causes an impossible comparison since the same column in a table cannot be equal to two different values. The workaround is to use a separate boolean chart when AND'ing two values from the same field.

https://bugzilla.redhat.com/query.cgi?columnlist=bug_severity%2Cpriority%2Cop_sys%2Cassigned_to%2Cbug_status%2Cresolution%2Cshort_desc%2Cflags&field0-0-0=flagtypes.name&field1-0-0=flagtypes.name&product=Red%20Hat%20Network%20Satellite&query_format=advanced&type0-0-0=equals&type1-0-0=equals&value0-0-0=sat-5.2.0%2B&value1-0-0=pm_ack%2B

FWIW, the backend Search.pm code is getting revamped for a future Bugzilla release but is a large undertaking.

Dave

Comment 8 Jan Pazdziora 2010-08-27 08:12:10 UTC
Dave, the query from comment 7 works -- thanks! I think we can close this bugzilla now as the approach with two charts is sufficient.

Comment 9 Alasdair Kergon 2012-01-03 14:57:57 UTC
Perhaps it could at least detect when this combination of parameters is supplied and give a warning instead of pretending to carry out a query it can't actually handle correctly?

Comment 10 Alasdair Kergon 2012-01-03 15:17:42 UTC
I wonder if the fix is as simple as 'my $flags = "flags_$$chartid_$$row";' in _flagtypes_name()

Comment 11 Alasdair Kergon 2012-01-03 15:35:02 UTC
The 'cc' field suffers from the same bug if used within a chart.  Version 4 also looks broken (but I've not tried it).  It seems most of the queries using LEFT_JOIN fields forget to append a monotonic counter such as the row number when used within a chart.