Re: Materialized views WIP patch

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Materialized views WIP patch
Дата
Msg-id 7366.1361377241@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Materialized views WIP patch  (Kevin Grittner <kgrittn@ymail.com>)
Ответы Re: Materialized views WIP patch  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-hackers
Kevin Grittner <kgrittn@ymail.com> writes:
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Having said that, I don't think I believe your analysis of why
>> this doesn't work.

> Well, it wouldn't be the first time you've seen a better way to do
> something in flex than I was able to see.  Taking just the gram.y
> part of the change which implemented this, and omitting the change
> in reservedness of MATERIALIZED, I have:

> -           TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior
> +           TRUNCATE trunc_type relation_expr_list opt_restart_seqs opt_drop_behavior

> +trunc_type:
> +           TABLE                       { $$ = OBJECT_TABLE; }
> +           | MATERIALIZED VIEW         { $$ = OBJECT_MATVIEW; }
> +           | /*EMPTY*/                 { $$ = OBJECT_UNSPECIFIED; }
> +       ;

Yeah, this is a standard gotcha when working with unreserved keywords.
You can't factor it like that because then the parser is required to
make a shift-reduce decision (on whether to reduce trunc_type to empty)
before it can "see past" the first word.  So for instance given
TRUNCATE MATERIALIZED ...        ^

the parser has to make that decision when it can't see past the word
"MATERIALIZED" and so doesn't know what comes after it.

The way to fix it is to not try to use the sub-production but spell it
all out:
  TRUNCATE TABLE relation_expr_list ...| TRUNCATE MATERIALIZED VIEW relation_expr_list ...| TRUNCATE relation_expr_list
...

Now the parser doesn't have to make any shift-reduce decision until
after it can "see past" the first identifier.  It's a bit tedious
but beats making a word more reserved than it has to be.
        regards, tom lane



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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: streaming header too small
Следующее
От: Misa Simic
Дата:
Сообщение: Altering Views