]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add base32hex support to encode() and decode() functions.
authorMasahiko Sawada <msawada@postgresql.org>
Wed, 25 Mar 2026 18:35:19 +0000 (11:35 -0700)
committerMasahiko Sawada <msawada@postgresql.org>
Wed, 25 Mar 2026 18:35:19 +0000 (11:35 -0700)
commit497c1170cb108cd84fe13db19c049177376fec5f
treeec28f7bcfc0f4060dad51cd90d8369a7dbedd32e
parentc8b4a3ec087b037b1f59554d622855cf9cc44cfb
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
doc/src/sgml/func/func-binarystring.sgml
src/backend/utils/adt/encode.c
src/test/regress/expected/strings.out
src/test/regress/expected/uuid.out
src/test/regress/sql/strings.sql
src/test/regress/sql/uuid.sql