From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Stephen Frost <sfrost(at)snowman(dot)net> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: LATERAL |
Date: | 2009-09-08 01:29:59 |
Message-ID: | 603c8f070909071829h6e3caa3as5477416836c1e577@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Sep 7, 2009 at 9:12 PM, Stephen Frost<sfrost(at)snowman(dot)net> wrote:
> Robert,
>
> * Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
>> On Mon, Sep 7, 2009 at 7:47 PM, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> > Because as often as not, they're mistakes. Please don't think
>> > you're smarter than the spec here.
>>
>> You're frequently the first to criticize the spec, but I have no
>> interest in second-guessing whatever behavior the spec specifies for
>> this construct.
>
> I'm not entirely sure you followed what Tom was getting at here. If you
> did, feel free to ignore me.
>
>> I'm just trying to understand it, and as far as I can
>> tell, LATERAL() is just a piece of syntactic sugar that allows
>> expressions within to reference FROM items at the same query level.
>
> What I'm gathering is that this may be correct, though I don't know for
> sure. The point I think Tom was making is that even if it *is* just
> syntactic sugar, we don't want to allow expressions to reference FROM
> items at the same query level *unless* LATERAL is specified. Your
> earlier comments sounded like you would want to implement allowing
> expressions to refer to FROM items at the same query level without
> LATERAL being specified.
Fair enough. I think I started to drift off in the direction of
making that argument, but it wasn't really my point. The original
point I was trying to make is that we may not need to invent any kind
of new name-resolution or scoping in order to make LATERAL() work.
Instead, LATERAL() can just do everything normally with the exception
of not throwing the following errors when they would otherwise be
thrown:
subquery in FROM cannot refer to other relations of the same query level
function expression in FROM cannot refer to other relations of the
same query level
I'm not sure if I'm right about this, but if I am, it seems likely to
be a pretty straightforward change.
>> I haven't got a copy of the spec, so that's a bit of a handicap. If
>> someone who does can look this up and comment on how it's supposed to
>> work, I would certainly appreciate that. My understanding of it is
>> currently based on random articles cherry-picked around the Internet
>> and a handful of emails from archives.postgresql.org, which seems a
>> little thin.
>
> You can get a 'draft' that's very close to the spec pretty easily..
> Just do '??sql' in IRC sometime..
Thanks for the tip.
...Robert
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2009-09-08 02:08:51 | Re: LATERAL |
Previous Message | Stephen Frost | 2009-09-08 01:12:17 | Re: LATERAL |