Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Subject: Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions
Date: 2026-03-24 17:26:34
Message-ID: CAD21AoAMST1V1OE=yvg3vQn=p6DDJBAaaFDx39z=P-+Z9iXwOQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 24, 2026 at 8:31 AM Aleksander Alekseev
<aleksander(at)tigerdata(dot)com> wrote:
>
> Hi,
>
> > > The patch looks basically good to me. I've made some changes to the
> > > regression test part as I want to have round-trip tests. I've merged
> > > the tests checking the sortability to the existing tests and added
> > > round-trip tests. With this change, we can test round-trip tests and
> > > sortability tests with random UUID value in every test run while
> > > minimizing the test time. Feedback is very welcome.
>
> v11 looks good to me.
>
> > It looks like leading, trailing, and embedded whitespace are all ignored. But I don’t see a test case covering this behavior, so maybe it would be good to add one.
>
> I intentionally didn't include this test because the code is trivial:
>
> ``
> /* Skip whitespace */
> if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
> continue;
> ```
>
> And also because we never tested it for base64. If we want to start
> testing it we should add tests both for base64 and base32hex which IMO
> should be a separate patch.

Agreed.

I've attached the updated version patch that includes the following points:

- changed the order of encodings in the doc and the hint message to
maintain alphabetical order.
- changed the query example to extract data from the encoded UUID
value to use rtrim() as it's more intuitive.
- added some regression tests for decoding unpadded inputs.

I'm going to push the patch unless there are comments on these changes.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v12-0001-Add-base32hex-support-to-encode-and-decode-funct.patch application/octet-stream 17.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2026-03-24 17:27:47 Re: index prefetching
Previous Message Daniil Davydov 2026-03-24 17:26:13 Re: Fix bug with accessing to temporary tables of other sessions