Re: Review: UNNEST (and other functions) WITH ORDINALITY

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Review: UNNEST (and other functions) WITH ORDINALITY
Дата
Msg-id CAM-w4HM=yMNQ0Meo_1LxQZwV7DSNqFAnE3nxw2B9AekYq9H-Rw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Review: UNNEST (and other functions) WITH ORDINALITY  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Review: UNNEST (and other functions) WITH ORDINALITY  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Wed, Jul 24, 2013 at 7:00 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I don't see any workable fix that doesn't involve the funny token, though.
> Consider
>
> CREATE VIEW v AS SELECT ... FROM UNNEST(...) WITH ORDINALITY;
> CREATE VIEW v AS SELECT ... FROM UNNEST(...) WITH NO DATA;
>
> WITH ORDINALITY really needs to be parsed as part of the FROM clause.
> WITH NO DATA really needs to *not* be parsed as part of the FROM clause.
> Without looking ahead more than one token, there is absolutely no way
> for the grammar to decide if it's got the whole FROM clause or not
> at the point where WITH is the next token.  So our choices are to have
> two-token lookahead at the lexer level, or to give up on bison and find
> something that can implement a parsing algorithm better than LALR(1).
> I know which one seems more likely to get done in the foreseeable future.


It occurs to me we might be being silly here.

Instead of collapsing WITH TIME and WITH ORDINALITY into a single
token why don't we just modify the WITH token to WITH_FOLLOWED_BY_TIME
and WITH_FOLLOWED_BY_ORDINALITY but still keep the following token.
Then we can just include those two tokens everywhere we include WITH.
Basically we would be giving the parser a free extra token of
lookahead whenever it gets WITH.

I think that's isomorphic to what Tom suggested but requires less
surgery on the parser and automatically covers any other cases we
don't need to track down.

-- 
greg



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Marko Tiikkaja
Дата:
Сообщение: Re: replication_reserved_connections
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Review: UNNEST (and other functions) WITH ORDINALITY