Re: writing a MIN(RECORD) aggregate

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: writing a MIN(RECORD) aggregate
Date: 2008-03-26 01:35:57
Message-ID: 20080326013557.GL6870@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 26, 2008 at 01:03:18AM +0000, Gregory Stark wrote:
> "Sam Mason" <sam(at)samason(dot)me(dot)uk> writes:
> > The reason for the sub-select is only because SQL doesn't provide any
> > other way to name expressions. Hum, or at least this should work...
> > There doesn't seem to be any nice way of getting fields out of a record!
>
> Yeah, to disambiguate it you have to use (r).i

OK, that sort of makes sense. The next problem is that PG doesn't
remember the column names:

SELECT (ROW(i)).i FROM (SELECT 1) x(i);

Results in PG saying it doesn't know where "i" is inside the row, which
seems a little strange. I think it's this detail that accounts for
my problems in trying to get this all working before. This seems to
suggest that there are two record-like data structures in PG, one for
the records returned as part of the SELECT list and another that I'm
using here.

As a side case, would it be nice if:

SELECT (SELECT 1 AS a, 2 AS b);

resulted in a record with two members?

Sam

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-03-26 01:42:38 Re: stored procedure stats in collector
Previous Message Tom Lane 2008-03-26 01:32:10 Bogosity in contrib/xml2/Makefile