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

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Sergey Prokhorenko <sergeyprokhorenko(at)yahoo(dot)com(dot)au>
Subject: Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions
Date: 2025-10-23 13:06:43
Message-ID: 18022523-0F8F-4C07-AFF5-57DC9086D78E@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello!

> On 23 Oct 2025, at 14:55, Aleksander Alekseev <aleksander(at)tigerdata(dot)com> wrote:
>
> Secondly, in order to propose a patch please use `git format-patch`
> and send it as an attachment. Then register it on the nearest open
> commitfest [1].

I think it's not about review yet, but more of a discussing viability and general approach.
The code itself is trivial in this case.

My first reaction was very skeptical too. Yes, this representation (28V4APV8JC9D792M89J185Q000) seems more developer-friendly than default (123e4567-e89b-12d3-a456-426614174000). But why should we bother with propagating one data format over another?

Yet, this format is RFC-blessed. It makes sense to consider providing an alternative to unfriendly format.

> The interface you are proposing is ugly and is not composable. The
> right way of doing this IMO would be:
>
> 1. Implement uuid -> bytea and bytea -> uuid casting
> 2. Implement encode(bytea, 'base32') and decode(text, 'base32')
>
> So the overall interface should be like this:
>
> SELECT encode(uuidv7() :: bytea, 'base32');

That's an excellent feedback! Would such conversion be idiomatic for Postgres users?
Are there any other alternative approaches?

> The value of converting uuid to base32 is not obvious though, so I
> would recommend explaining it in more detail.

Yes, and maybe some examples of other systems that adopted this format would be handy too. Sergey, can you, please, extend reasoning why this particular format is prominent? RFC 4648 describes a bunch of formats.

> Consider starting a new
> thread for each separate patch.

I think this thread is fine for discussing.

Thank you!

Best regards, Andrey Borodin.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2025-10-23 13:32:56 Re: [PATCH] Free memory allocated by waitonlock_error_callback()
Previous Message Jelte Fennema-Nio 2025-10-23 13:04:56 Add GoAway protocol message for graceful but fast server shutdown/switchover