Re: LATERAL

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: LATERAL
Date: 2009-09-08 06:25:47
Message-ID: 1252391147.28190.4.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2009-09-08 06:34:36 Re: More Snow Leopard fun: multiarch problems while building plperl
Previous Message Itagaki Takahiro 2009-09-08 05:56:27 Re: CREATE LIKE INCLUDING COMMENTS and STORAGES