pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: kou@clear-code.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13840: pg_dump generates unloadable SQL when third party string type index option is used
Date: Thu, 31 Dec 2015 15:35:22 +0000
Message-ID: <20151231153522.1117.56276@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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/



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (6+ messages)  latest in thread

Message-ID: <20151231153522.1117.56276@wrigleys.postgresql.org>
Permalink:  ../20151231153522.1117.56276@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20151231153522.1117.56276@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: kou@clear-code.com
  Subject: Re: BUG #13840: pg_dump generates unloadable SQL when third party string type index option is used
  In-Reply-To: <20151231153522.1117.56276@wrigleys.postgresql.org>
  References: <20151231153522.1117.56276@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox