Re: join from array or cursor - Mailing list pgsql-general

From Sam Mason
Subject Re: join from array or cursor
Date
Msg-id 20090821171317.GG5407@samason.me.uk
Whole thread Raw
In response to Re: join from array or cursor  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: join from array or cursor  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
On Fri, Aug 21, 2009 at 12:05:51PM -0400, Tom Lane wrote:
> Sam Mason <sam@samason.me.uk> writes:
> > ... PG should instead arrange that the expression
> > "t" is run exactly once and reuse the single result for all columns.
>
> We might be able to do that based on the row-returning-subselect
> infrastructure being discussed over here:
> http://archives.postgresql.org/message-id/4087.1250867036@sss.pgh.pa.us

Huh, fun.  Not sure if I'm interpreting this correctly, but what would
the difference in semantics between:

  SELECT (SELECT 1,2);

and

  SELECT (SELECT (1,2));

PG seems to make the distinction somewhat blurry at the moment.  For
example, upthread I did:

  SELECT (id((SELECT (1,2)::foo))).*;

and got back two columns, and yet when I do what I think is equivalent:

  SELECT x.*
  FROM (SELECT (1,2)::foo) x;

I get back my tuple, and not the values inside my tuple.


Should I be posting this to -hackers?

--
  Sam  http://samason.me.uk/

pgsql-general by date:

Previous
From: David Fetter
Date:
Subject: Re: New database or New Schema?
Next
From: Merlin Moncure
Date:
Subject: Re: join from array or cursor