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

From: kou(at)clear-code(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #13840: pg_dump generates unloadable SQL when third party string type index option is used
Date: 2015-12-31 15:35:22
Message-ID: 20151231153522.1117.56276@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 13840
Logged by: Kouhei Sutou
Email address: kou(at)clear-code(dot)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/

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2016-01-01 07:39:40 Re: BUG #13839: command line restart server fail
Previous Message Bruce Momjian 2015-12-31 01:31:16 Re: BUG #13783: 'create database test owner testowner' as 'postgres' leaves test.public owned by postgres