| From: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net> |
| Subject: | Long reloption values are truncated by pg_dump and pg_get_indexdef() |
| Date: | 2026-11-18 20:50:36 |
| Message-ID: | CAN4CZFP81mGXwn77TU0uLkgvyaCCCiFN=pHO4xWAfE9wTJsGLg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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/ea1c4d33-0780-473c-96dc-1468cf733a04@dunslane.net
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Quote-reloption-values-too-long-to-be-identifiers.patch | application/octet-stream | 5.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomás Senart | 2026-11-18 20:52:48 | Re: [PATCH v1] Avoid deforming unused trailing columns in COPY TO |
| Previous Message | Zsolt Parragi | 2026-11-18 20:45:58 | Allow extensions to define tablespace options |