On Wed, Mar 26, 2008 at 01:03:18AM +0000, Gregory Stark wrote:
> "Sam Mason" <sam@samason.me.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