Re: [PATCH] Add hints for invalid binary encoding names in encode/decode functions

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Chao Li <li.evan.chao@gmail.com>, Sugamoto Shinya <shinya34892@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2025-11-12T14:35:58Z
Lists: pgsql-hackers
On 10.11.25 10:06, Chao Li wrote:
> The list is defined in encode.c (search for enclist in the file), I guess we can add a function to return a string with a encoding names.
> 
> 2
> ```
> +				 errhint("Valid binary encodings are: %s",
> +						 "\"hex\", \"base64\", \"base64url\", \"escape\".")));
> ```
> 
> Looks like putting punctuation inside %s is not normal. By looking at other hint messages, they usually do something like:
> 
> ```
> errhint("Perhaps you meant the option \"%s\".”, value)
> ```

Yes, this is because the punctuation is itself subject to translation. 
(Most obviously, different languages use different quotation marks.)  So 
the preferred style is something like

errhint("Valid encodings are: \"%s\", \"%s\", and \"%s\", "hex", ...)

or however many you need.

See also 
<https://www.postgresql.org/message-id/202511070936.jj4o4ktd4b6l%40alvherre.pgsql> 
for a related discussion.




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add HINT listing valid encodings to encode() and decode() errors.

  2. Revise GUC names quoting in messages again

  3. doc: Mention how to use quotes with GUC names in error messages

  4. Adjust assorted hint messages that list all valid options.