BUG #13840: pg_dump generates unloadable SQL when third party string type index option is used

Поиск
Список
Период
Сортировка
От kou@clear-code.com
Тема BUG #13840: pg_dump generates unloadable SQL when third party string type index option is used
Дата
Msg-id 20151231153522.1117.56276@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #13840: pg_dump generates unloadable SQL when third party string type index option is used  (Kouhei Sutou <kou@clear-code.com>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      13840
Logged by:          Kouhei Sutou
Email address:      kou@clear-code.com
PostgreSQL version: 9.4.5
Operating system:   Debian GNU/Linux sid
Description:

PostgreSQL supports amindex extension. But pg_dump doesn't support
string type custom index options for amindex extension.

Amindex extension can support custom index options that can be used by
"CREATE INDEX ... WITH (option_name = option_value)" syntax. Amindex
extension uses add_string_reloption() to add a string type option.

PostgreSQL requires quotation for option_value such as:

  CREATE INDEX pgroonga_index ON t
    USING pgroonga (c)
    WITH (normalizer = 'none');

PGroonga(*) is used in the above example.
PGroonga is an amindex extension that adds "normalizer" option.
(*) http://pgroonga.github.io/

If we specify option value without quotation, PostgreSQL reports an
error:

  CREATE TABLE t (c text);
  CREATE INDEX pgroonga_index ON t USING pgroonga (c) WITH (normalizer =
none);
  -- ERROR:  syntax error at or near "none"
  -- LINE 1: ...onga_index ON t USING pgroonga (c) WITH (normalizer =
none);
  --                                                                  ^

pg_dump generates "CREATE INDEX ... WITH ..." without quotation for
option value:

  % pg_dump -d option_test
  ...
  CREATE TABLE t (
      c text
  );
  ...
  CREATE INDEX pgroonga_index ON t USING pgroonga (c) WITH
(normalizer=none);
  ...

"normalizer=none" causes error on restoring the dump.

pg_dump should generates "normalizer='none'" as option to avoid the
error.

FYI1: This problem isn't occurred for built-in options such as
"buffering" option for gist. Because values for "buffering" option are
registered as keywords. PostgreSQL can parse keyword-ed values without
quotation such as "buffering = on".

It's implemented in src/backend/parser/gram.y:

  def_arg:    func_type                        { $$ = (Node *)$1; }
                          | reserved_keyword                { $$ = (Node
*)makeString(pstrdup($1)); }
                          | qual_all_Op                    { $$ = (Node *)$1; }
                          | NumericOnly                    { $$ = (Node *)$1; }
                          | Sconst                        { $$ = (Node *)makeString($1); }

"reserved_keyword" doesn't require quotation.

It means that using PGroonga is easy-to-reproduce this problem. Here
is an install document of PGroonga: http://pgroonga.github.io/install/

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

Предыдущее
От:
Дата:
Сообщение: Re: BUG #13822: Slave terminated - WAL contains references to invalid page
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: BUG #13839: command line restart server fail