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

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Sugamoto Shinya <shinya34892(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Add hints for invalid binary encoding names in encode/decode functions
Date: 2025-11-12 14:35:58
Message-ID: c5c937dc-de8e-4284-be25-5d5eaf089d00@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message KAZAR Ayoub 2025-11-12 14:44:02 Re: Speed up COPY FROM text/CSV parsing using SIMD
Previous Message David Geier 2025-11-12 14:28:37 Re: tuple radix sort