Add base32hex support to encode() and decode() functions.
Masahiko Sawada <msawada@postgresql.org>
Author:
Masahiko Sawada <msawada@postgresql.org>
Date: 2026-03-25T18:35:19Z
Releases:
19 (unreleased)
Add base32hex support to encode() and decode() functions. This adds support for base32hex encoding and decoding, as defined in RFC 4648 Section 7. Unlike standard base32, base32hex uses the extended hex alphabet (0-9, A-V) which preserves the lexicographical order of the encoded data. This is particularly useful for representing UUIDv7 values in a compact string format while maintaining their time-ordered sort property. The encode() function produces output padded with '=', while decode() accepts both padded and unpadded input. Following the behavior of other encoding types, decoding is case-insensitive. Suggested-by: Sergey Prokhorenko <sergeyprokhorenko@yahoo.com.au> Author: Andrey Borodin <x4mmm@yandex-team.ru> Co-authored-by: Aleksander Alekseev <aleksander@tigerdata.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Илья Чердаков <i.cherdakov.pg@gmail.com> Reviewed-by: Chengxi Sun <chengxisun92@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://postgr.es/m/CAJ7c6TOramr1UTLcyB128LWMqita1Y7%3Darq3KHaU%3Dqikf5yKOQ%40mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func/func-binarystring.sgml | modified | +27 −0 |
| src/backend/utils/adt/encode.c | modified | +157 −4 |
| src/test/regress/expected/strings.out | modified | +159 −3 |
| src/test/regress/expected/uuid.out | modified | +14 −4 |
| src/test/regress/sql/strings.sql | modified | +56 −1 |
| src/test/regress/sql/uuid.sql | modified | +7 −1 |
Discussion
- Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions 69 messages · 2025-10-23 → 2026-03-27