Closed Bug 298400 Opened 20 years ago Closed 19 years ago

[PostgreSQL] SQL error using buglist.cgi and full text search. Column "relevance desc" not valid in GROUP BY

Categories

(Bugzilla :: Query/Bug List, defect)

2.19.3
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: dkl, Assigned: mkanat)

References

Details

Attachments

(1 file)

When using search-specific.html.tmpl (fulltext), the order by is set to "relevance  
desc". This gets added to the ORDER BY clause of the SQL statement properly, but
it also gets added to the field list in the GROUP BY clause which causes an SQL
error. 

     foreach my $field (@fields, @orderby) {
         next if ($field =~ /(AVG|SUM|COUNT|MAX|MIN|VARIANCE)\s*\(/i ||
-                 $field =~ /^\d+$/ || $field eq "bugs.bug_id");
+                 $field =~ /^\d+$/ || $field eq "bugs.bug_id" || $field eq
"relevance desc");
         if ($field =~ /.*AS\s+(\w+)$/i) {
             push(@groupby, $1) if !grep($_ eq $1, @groupby);
         } else {


The diff above in Bugzilla/Search.pm fixes the problem but I am not sure if it
is the most elegant way to do it.
Hrm... I might just have to hack in a fix for that manually. I'll see if I can't
come up with something better, though.
OS: Linux → All
Hardware: PC → All
Summary: SQL error using buglist.cgi and full text search on PostgreSQL. Column "relevance desc" not valid in GROUP BY → [PostgreSQL] SQL error using buglist.cgi and full text search. Column "relevance desc" not valid in GROUP BY
Target Milestone: --- → Bugzilla 2.20
Ohhhh... the problem is that it's using "desc" in the GROUP BY. I think that's
all we need to fix. :-)
Assignee: query-and-buglist → mkanat
Status: NEW → ASSIGNED
Yeah, I basically used your solution.

At first, I tried just removing the DESC with a regex, but then Pg also
complained that aggregates aren't allowed in the GROUP BY clause. :-)

So instead I'm just removing relevance entirely.
Attachment #189279 - Flags: review?(dkl)
*** Bug 300865 has been marked as a duplicate of this bug. ***
Comment on attachment 189279 [details] [diff] [review]
Exclude relevance from GROUP BY

This is really brief; one changed line, if you have a second to review it,
LpSolit.
Attachment #189279 - Flags: review?(dkl) → review?(LpSolit)
Comment on attachment 189279 [details] [diff] [review]
Exclude relevance from GROUP BY

I prefer joel to look at this patch. A one-liner doesn't mean it has no
side-effect. And I'm not familiar enough with the code in Search.pm to
guarantee it has none.
Attachment #189279 - Flags: review?(LpSolit) → review?(bugreport)
Comment on attachment 189279 [details] [diff] [review]
Exclude relevance from GROUP BY

I'm not sure joel has the time to do reviews, nowadays, but perhaps glob does?
:-)
Attachment #189279 - Flags: review?(bugreport) → review?(bugzilla)
Attachment #189279 - Flags: review?(bugzilla) → review?(wurblzap)
Comment on attachment 189279 [details] [diff] [review]
Exclude relevance from GROUP BY

I can't reproduce finding relevance in GROUP BY, but it looks sensible to me,
and it doesn't seem to break anything.

Asking for a second review.
Attachment #189279 - Flags: review?(wurblzap)
Attachment #189279 - Flags: review?
Attachment #189279 - Flags: review+
Comment on attachment 189279 [details] [diff] [review]
Exclude relevance from GROUP BY

r=joel by inspection.
Attachment #189279 - Flags: review? → review+
the patch applies cleanly to both 2.20 and tip. Requesting approval.
Flags: approval?
Flags: approval2.20?
Agreed.  ANSI SQL spec says GROUP BY only needs to include real columns, not
aggregates (and Postgres is enforcing that).  This is the right thing to do.
Flags: approval?
Flags: approval2.20?
Flags: approval2.20+
Flags: approval+
Whiteboard: [patch awaiting checkin]
Tip:

Checking in Bugzilla/Search.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v  <--  Search.pm
new revision: 1.108; previous revision: 1.107
done

2.20:

Checking in Bugzilla/Search.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v  <--  Search.pm
new revision: 1.99.2.4; previous revision: 1.99.2.3
done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Whiteboard: [patch awaiting checkin]
*** Bug 306348 has been marked as a duplicate of this bug. ***
*** Bug 315495 has been marked as a duplicate of this bug. ***
*** Bug 315495 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: