Closed Bug 150882 Opened 22 years ago Closed 22 years ago

SQL error when sorting by bugs.votes with explicit direction


(Bugzilla :: Query/Bug List, defect)

Not set



Bugzilla 2.16


(Reporter: darkshadow, Assigned: bbaetz)




(Keywords: regression)


(1 file)

go to:
("View Bugs Already Reported Today")
and submit a query. here is what you'll see (taken from the first example):

Please stand by ...
Content-type: text/html
Software error:
SELECT DISTINCT bugs.bug_id, bugs.groupset, bugs.bug_severity, bugs.priority,
bugs.rep_platform, map_assigned_to.login_name, bugs.bug_status, bugs.resolution,
bugs.short_desc FROM bugs, profiles map_assigned_to, profiles map_reporter LEFT
JOIN profiles map_qa_contact ON bugs.qa_contact = map_qa_contact.userid LEFT
JOIN cc selectVisible_cc ON bugs.bug_id = selectVisible_cc.bug_id AND
selectVisible_cc.who = 22572 WHERE ((bugs.groupset & 0) = bugs.groupset OR
(bugs.reporter_accessible = 1 AND bugs.reporter = 22572) OR
(bugs.cclist_accessible = 1 AND selectVisible_cc.who = 22572 AND not
isnull(selectVisible_cc.who))) AND bugs.assigned_to = map_assigned_to.userid AND
bugs.reporter = map_reporter.userid AND (bugs.product = 'Browser' OR
bugs.product = 'MailNews') AND (bugs.bug_status = 'UNCONFIRMED' OR
bugs.bug_status = 'NEW' OR bugs.bug_status = 'ASSIGNED' OR bugs.bug_status =
'REOPENED' OR bugs.bug_status = 'RESOLVED') AND ((to_days(now()) -
to_days(bugs.delta_ts)) < '2') AND (bugs.creation_ts > '2002-06-11 00:00:00')
ORDER BY bugs.votes desc desc, bugs.priority, bugs.bug_severity : You have an
error in your SQL syntax near 'desc, bugs.priority, bugs.bug_severity ' at line
4 at line 276.

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

I suppose this is the 1000th report of this bug, but I can't search for it....
I just tried the link, and it worked for me.  Were you logged in when it
happened?  What happens if you log out/in (whatever is the opposite of how you
were before) and then try it?
It happens always, it seems not to depend on if I'm logged in or out. It also
shoudn't, if the "You have an error in your SQL syntax near 'desc,
bugs.priority, bugs.bug_severity ' at line 4 at line 276"-part of the
error message is right ;)
What browser are you using?
i'm seeing the same thing, whether logged out or logged in. using 2002061108 on
win2000. happens with any query.
works now.  I opened the URL in IE and it worked ok.  couldn't imagine why that
should be, i then went back to mozilla and deleted all the cookies set by  tried the query URL again and it worked.  I guess my (and
Sven's) old bugzilla cookies are confusing the new bugzilla somehow?

Sven - try going into the cookie manager and deleting the cookies set by, and then see if that fixes it for you too.
'bugs.votes desc' in the order param is coverted to 'bugs.votes desc desc' which
obviously fails

    # If we are sorting by votes, sort in descending order.
    if ($db_order =~ /bugs.votes\s*(asc|desc){0}/i) {
        $db_order =~ s/bugs.votes/bugs.votes desc/i;

isn't doing what you expected it to do. That regexp looks odd to me, though.

Patch coming

2.14 had the desc in the votes DefCol, which is probably why it wasn't affected
Assignee: endico → bbaetz
Keywords: regression
Target Milestone: --- → Bugzilla 2.16
Attached patch patchSplinter Review
Keywords: patch, review
Summary: Query not working → SQL error when sorting by bug.votes with explicit direction
I deleted all cookies from, but the problem remains :-(
I use Mozilla 1.1 trunk 2002060208 on Linux, it doesn't happen on a 10 hours old
self compiled cvs trunk and a new profile.
try the link:

That should reset the order cookie.

Or you could just specifiy a sort order on the query screen.
Comment on attachment 87310 [details] [diff] [review]


Attachment #87310 - Flags: review+
Checked in, trunk + branch:

Checking in buglist.cgi;
/cvsroot/mozilla/webtools/bugzilla/buglist.cgi,v  <--  buglist.cgi
new revision: 1.175; previous revision: 1.174

Checking in buglist.cgi;
/cvsroot/mozilla/webtools/bugzilla/buglist.cgi,v  <--  buglist.cgi
new revision:; previous revision:
Closed: 22 years ago
Resolution: --- → FIXED
Summary: SQL error when sorting by bug.votes with explicit direction → SQL error when sorting by bugs.votes with explicit direction
Whiteboard: [applied to b.m.o]
Whiteboard: [applied to b.m.o]
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.