Hello pg_dump's appendReloptionsArray() and ruleutils' get_reloptions() print an option value without quotes if it is a valid identifier that doesn't need quoting. They don't check the length, so a string value of 64 bytes or more is printed unquoted. When the output is replayed the scanner truncates it to 63 bytes. The only sign of this is a NOTICE during restore, the option silently ends up with a different value.
None of the built-in reloptions can have such a value, but string
options defined by extensions can. Simple repro with the
dummy_index_am test module:
CREATE EXTENSION dummy_index_am;
CREATE TABLE t (i int4);
CREATE INDEX ti ON t USING dummy_index_am (i)
WITH (option_string_null =
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
SELECT pg_get_indexdef('ti'::regclass);
-- ... WITH
(option_string_null=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
pg_dump prints the same, and restoring it results in a 63 character value.
Currently this only affects index AMs with string options, but there
are 2 proposals that make it more likely to happen: tablespace options
defined by extensions [1] (where I ran into it), and table AM
reloptions [2].
The attached patch quotes values that are too long to be identifiers
in both places, and adds a test to dummy_index_am.
[1]:
https://postgr.es/m/CAN4CZFNxu5BgBge12C%3Df3JV9LdZvUiG%2BpQHOCutATewSywzFuw%40mail.gmail.com
[2]: https://postgr.es/m/[email protected]
v1-0001-Quote-reloption-values-too-long-to-be-identifiers.patch
Description: Binary data
