Re: LATERAL - Mailing list pgsql-hackers
From | Robert Haas |
---|---|
Subject | Re: LATERAL |
Date | |
Msg-id | 603c8f070909071829h6e3caa3as5477416836c1e577@mail.gmail.com Whole thread Raw |
In response to | Re: LATERAL (Stephen Frost <sfrost@snowman.net>) |
Responses |
Re: LATERAL
|
List | pgsql-hackers |
On Mon, Sep 7, 2009 at 9:12 PM, Stephen Frost<sfrost@snowman.net> wrote: > Robert, > > * Robert Haas (robertmhaas@gmail.com) wrote: >> On Mon, Sep 7, 2009 at 7:47 PM, Tom Lane<tgl@sss.pgh.pa.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
pgsql-hackers by date: