Re: LATERAL - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: LATERAL
Date
Msg-id 1252391147.28190.4.camel@vanquo.pezone.net
Whole thread Raw
In response to Re: LATERAL  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On mån, 2009-09-07 at 19:06 -0400, Robert Haas wrote:
> On Mon, Sep 7, 2009 at 3:43 AM, Peter Eisentraut<peter_e@gmx.net> wrote:
> > Because joins can be reordered, whereas LATERAL creates a kind of
> > syntactic sequence point for join reordering.  To pick up your example:
> >
> >> But this doesn't [work]:
> >>
> >> select g, h from generate_series(1,10) g, generate_series(1,g) h;
> >
> > You need to constrain the order of the from items in some way so the "g"
> > refers to something well-defined.  That's what LATERAL does.
> 
> I don't think so.  All joins constrain the join order,

I carefully did not say "constrain the join order" but "constraint the
order of the from items" and "a *syntactic* sequence point".  If the
order of the from items is free, then you could also write the above
example as

select g, h from generate_series(1,g) h, generate_series(1,10) g;

but that would no longer be valid with LATERAL in there.

>  but none of
> them except FULL JOIN constrain it completely, and this is no
> exception.

FWIW, the spec says somewhere that LATERAL is not allowed at or near an
outer join.  I'll have to read up on it again.



pgsql-hackers by date:

Previous
From: Itagaki Takahiro
Date:
Subject: Re: CREATE LIKE INCLUDING COMMENTS and STORAGES
Next
From: Peter Eisentraut
Date:
Subject: Re: More Snow Leopard fun: multiarch problems while building plperl