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

Sugamoto Shinya <shinya34892@gmail.com>

From: Sugamoto Shinya <shinya34892@gmail.com>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>, Chao Li <li.evan.chao@gmail.com>, Daniel Gustafsson <daniel@yesql.se>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-11-17T14:08:14Z
Lists: pgsql-hackers

Attachments

On Thu, Nov 13, 2025 at 9:58 AM Fujii Masao <masao.fujii@gmail.com> wrote:

> On Wed, Nov 12, 2025 at 10:23 PM Sugamoto Shinya <shinya34892@gmail.com>
> wrote:
> > Thanks everyone for reviewing my proposal.
> > I've hard-coded the valid list of encoding names.
> >
> > Also, I modified the hint string into like "Valid encodings are \"hex\",
> \"base64\", \"base64url\", and \"escape\"."
> > by adding "and" before "escape".
> >
> > I attached my v2 patch to this message. Please let me know freely if you
> have any additional questions.
>
> Thanks for the updated patch! LGTM.
>
> One minor comment: in v2 patch, it seems the encodings in the HINT message
> are
> listed in the order they appear in the enclist struct. Wouldn't it be
> clearer to list them
> alphabetically, matching the order shown in the docs [1]: base64,
> base64url, escape, and hex?
>
> Regards,
>
> [1]
> https://www.postgresql.org/docs/devel/functions-binarystring.html#ENCODE-FORMAT-BASE64
>
> --
> Fujii Masao
>

Thanks, Fujii and Peter.

I ordered the valid encodings alphabetically and extracted those into
separate parameters.

Here is my new patch.

Regards,

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.