8.4, 9.0 bug (doesn't exist in 9.1) related to window functions

Started by Jeff Davisabout 14 years ago3 messagesbugs
Jump to latest
#1Jeff Davis
pgsql@j-davis.com

In REL8_4_STABLE and REL9_0_STABLE:

=> select ntile(3) OVER ( ORDER BY CASE WHEN count(i) = 0 THEN NULL ELSE
count(i) END asc ) from ( SELECT NULL::integer as i limit 0 ) s ;
ERROR: cannot extract attribute from empty tuple slot

A different error appears in 9.1.0 ("could not find pathkey item to
sort"), but it's fixed sometime later in the 9.1 series.

If you get rid of the CASE statement, then it still fails in 8.4 and
9.0, but it succeeds in 9.1.0 and beyond.

Regards,
Jeff Davis

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jeff Davis (#1)
Re: 8.4, 9.0 bug (doesn't exist in 9.1) related to window functions

Jeff Davis <pgsql@j-davis.com> writes:

In REL8_4_STABLE and REL9_0_STABLE:

=> select ntile(3) OVER ( ORDER BY CASE WHEN count(i) = 0 THEN NULL ELSE
count(i) END asc ) from ( SELECT NULL::integer as i limit 0 ) s ;
ERROR: cannot extract attribute from empty tuple slot

I believe this is the same case fixed here:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=c1d9579dd

and as noted in that commit message, it didn't appear worth the risk
of fixing it in released branches.

regards, tom lane

#3Jeff Davis
pgsql@j-davis.com
In reply to: Tom Lane (#2)
Re: 8.4, 9.0 bug (doesn't exist in 9.1) related to window functions

On Thu, 2012-01-26 at 20:43 -0500, Tom Lane wrote:

Jeff Davis <pgsql@j-davis.com> writes:

=> select ntile(3) OVER ( ORDER BY CASE WHEN count(i) = 0 THEN NULL ELSE
count(i) END asc ) from ( SELECT NULL::integer as i limit 0 ) s ;
ERROR: cannot extract attribute from empty tuple slot

I believe this is the same case fixed here:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=c1d9579dd

and as noted in that commit message, it didn't appear worth the risk
of fixing it in released branches.

Thank you. For the record, it looks like the one that fixed the similar
problem in early 9.1 was here:

http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=269c5dd2f46e3490da05d5dd5dad07828df281d9

Regards,
Jeff Davis