> On Nov 19, 2026, at 04:50, Zsolt Parragi <[email protected]> wrote:
> 
> 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>

I can reproduce the issue with your repro example, and the fix looks good to me.

My only comment is about the new comment:
```
and is short enough not to be truncated as one.
```

From this comment, I cannot quickly understand why the length check is needed. 
I would propose something like:
```
and is shorter than NAMEDATALEN bytes. Longer values must be quoted as string 
literals to avoid identifier truncation when the output is parsed.
```

As a non-native English speaker, I always prefer simpler and more explicit code 
comments. If other folks consider the wording in the patch good enough, I’m 
fine with withdrawing my comment.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






Reply via email to