Issue Details (XML | Word | Printable)

Key: CORE-1943
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Adriano dos Santos Fernandes
Reporter: fabianobonin
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
Firebird Core

GROUP BY RAND() returns infinite rows

Created: 19/Jun/08 01:08 PM   Updated: 19/Jan/16 06:05 AM
Component/s: Engine
Affects Version/s: 2.1.0, 2.0.4
Fix Version/s: 2.5 Beta 1

Issue Links:

QA Status: Done successfully

 Description  « Hide
The query below returns infinite rows:

 rdb$database a
group by

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Sean Leyne added a comment - 19/Jun/08 01:13 PM

This seems to be a "non-sense case" -- it does not reflected anything close to a real-world scenario -- as such, I think this should be considered a "won't fix" case.

Can you explain why GROUP BY RAND() would ever be used?

Adriano dos Santos Fernandes added a comment - 19/Jun/08 02:02 PM
Database engines should deal with "non-sense cases" too. Job of GROUP BY is not produce rows.

Dmitry Yemanov added a comment - 19/Jun/08 02:34 PM
I agree with Adriano. We already had such a problem previously with GROUP BY <constant>. The current one should also be solved. Our GROUP BY processing is somewhat non-optimal (to say at least).

fabianobonin added a comment - 19/Jun/08 06:28 PM
In my case, i was grouping by a "case", 'cause i need to group some rows from a procedure and keep others not grouped, but as the procedure didn't have a unique column, i used rand() to fake one. I fixed it changing the procedure to return a unique column and using it instead.

group by
  case when ... then ... else rand() end

Pavel Cisar added a comment - 25/Apr/11 02:08 PM
QA test added.