taking a stab at agg(foo ORDER BY bar)

Lists: pgsql-hackers
From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: taking a stab at agg(foo ORDER BY bar)
Date: 2009-10-04 08:51:05
Message-ID: 87hbuftudi.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The spec defines array_agg(foo ORDER BY ...) which we don't implement
yet; obviously, we have no reason not to define this for any
aggregate, rather than just array_agg.

This doesn't seem to present any problems as far as the syntax goes,
and the actual execution is just a small matter of coding, but I'm not
seeing the best way to handle it in parse-analysis. All the existing
infrastructure for ORDER BY seems to be dependent on targetlists, which
obviously we don't have in the context of an aggregate call.

Ideas?

--
Andrew (irc:RhodiumToad)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: taking a stab at agg(foo ORDER BY bar)
Date: 2009-10-04 15:10:10
Message-ID: 8950.1254669010@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> This doesn't seem to present any problems as far as the syntax goes,
> and the actual execution is just a small matter of coding, but I'm not
> seeing the best way to handle it in parse-analysis. All the existing
> infrastructure for ORDER BY seems to be dependent on targetlists, which
> obviously we don't have in the context of an aggregate call.

Well, if you don't want to refactor that code, it wouldn't be difficult
to make a one-entry tlist containing the aggregate argument, and then
throw it away again after you'd extracted what you need.

regards, tom lane