Skip site navigation (1) Skip section navigation (2)

Unexpected Result in Windowing

From: David Fetter <david(at)fetter(dot)org>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Unexpected Result in Windowing
Date: 2009-03-30 01:35:16
Message-ID: 20090330013516.GA19608@fetter.org (view raw or flat)
Thread:
Lists: pgsql-hackers
Folks,

Robert Treat brought this up.

I create a table with something to partition by, and some meaningless
junk.  I'm trying to get a random ordering inside each window:

CREATE TABLE foo(i, t) AS
SELECT i, md5((i*generate_series(1,10))::text) /* Nonsense text */
FROM generate_series(10,1) i;

SELECT
    i,
    t,
    RANK() OVER (
        PARTITION BY i
        ORDER BY random()
    )
FROM foo;
ERROR:  ORDER/GROUP BY expression not found in targetlist

Oops.  I found this error message only in backend/optimizer/util/tlist.c
and am wondering whether there needs to be a different code path for
windowing, or...?

Any ideas?

Cheers,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2009-03-30 01:55:36
Subject: Re: TupleTableSlot API problem
Previous:From: Andrew GierthDate: 2009-03-30 00:58:18
Subject: Re: TupleTableSlot API problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group