pg_get_indexdef() doesn't quote string reloptions

From: Eric Ridge <e_ridge(at)tcdi(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_get_indexdef() doesn't quote string reloptions
Date: 2014-10-13 15:21:49
Message-ID: 5D265224-30B2-4A1E-811E-E4F60E21FA45@tcdi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all!

I've been working on implementing a custom index using the Index Access Method API and have the need for custom reloptions that are "complex" strings (ie, also contain non-alphaumerics).

pg_get_indexdef() and pg_dump don't quote the reloption values, making a restore (or cut-n-paste of the pg_get_indexdef() output) impossible if the reloption value contains non-alphanumerics.

For example, the statement:

# CREATE INDEX idxfoo ON table USING myindex (col) WITH (option = 'some complex string');

cannot be restored as it gets rewritten as:

CREATE INDEX idxfoo ON table USING myindex (col) WITH (option = some complex string);
(note the lack of quotes around the option value)

Looks like (at least) ruleutils.c:flatten_reloptions() needs to be smarter.

eric

PROPRIETARY AND COMPANY CONFIDENTIAL COMMUNICATIONS
The information contained in this communication is intended only for
the use of the addressee. Any other use is strictly prohibited.
Please notify the sender if you have received this message in error.
This communication is protected by applicable legal privileges and is
company confidential.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2014-10-13 15:22:47 Re: jsonb generator functions
Previous Message Andres Freund 2014-10-13 15:21:32 Re: [PATCH] PostgreSQL 9.4 mmap(2) performance regression on FreeBSD...