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
Operations

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: 25/Apr/11 02:08 PM
Component/s: Engine
Affects Version/s: 2.1.0, 2.0.4
Fix Version/s: 2.5 Beta 1

Time Tracking:
Not Specified

Issue Links:
Relate
 

Planning Status: Unspecified


 Description  « Hide
The query below returns infinite rows:

select
 1
from
 rdb$database a
group by
 rand()

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

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.