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

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Cc: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>, 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 14:10:04
Message-ID: CAGECzQRNgpxZswyN98UvV+gLCpqOxEUXvaq0TPTtn8qVfJ+7vQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 23 Oct 2025 at 15:07, Andrey Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
> > SELECT encode(uuidv7() :: bytea, 'base32');
>
> That's an excellent feedback! Would such conversion be idiomatic for Postgres users?
> Are there any other alternative approaches?

Agreed that extending the encode function is the way to go. An example
of that is the recently added support for base64url:
https://git.postgresql.org/cgit/postgresql.git/commit/?h=REL_18_0&id=e1d917182c1953b16b32a39ed2fe38e3d0823047

> > 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.

I've definitely used base32 to encode uuids myself. The primary
benefit being shorter strings, while still being able to spell them
out by voice to people without having to specify whether a letter is
upper or lowercase.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2025-10-23 14:13:03 Re: WIP: parallel GiST index builds
Previous Message Jelte Fennema-Nio 2025-10-23 13:56:35 libpq: Bump protocol version to version 3.2 at least until the first/second beta