Allow explicit casting between bytea and uuid.
Masahiko Sawada <msawada@postgresql.org>
Author:
Masahiko Sawada <msawada@postgresql.org>
Date: 2026-03-19T20:51:50Z
Releases:
19 (unreleased)
Allow explicit casting between bytea and uuid. This enables the use of functions such as encode() and decode() with UUID values, allowing them to be converted to and from alternative formats like base64 or hex. The cast maps the 16-byte internal representation of a UUID directly to a bytea datum. This is more efficient than going through a text forepresentation. Bump catalog version. Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Co-authored-by: Aleksander Alekseev <aleksander@tigerdata.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru> Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl> Discussion: https://postgr.es/m/CAJ7c6TOramr1UTLcyB128LWMqita1Y7%3Darq3KHaU%3Dqikf5yKOQ%40mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/datatype.sgml | modified | +11 −0 |
| src/backend/utils/adt/bytea.c | modified | +27 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_cast.dat | modified | +6 −0 |
| src/include/catalog/pg_proc.dat | modified | +7 −0 |
| src/test/regress/expected/uuid.out | modified | +22 −0 |
| src/test/regress/sql/uuid.sql | modified | +5 −0 |
Discussion
- Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions 69 messages · 2025-10-23 → 2026-03-27