pgsql: Allow explicit casting between bytea and uuid.

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow explicit casting between bytea and uuid.
Date: 2026-03-19 20:52:09
Message-ID: E1w3KLh-000Xjy-0E@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)ilmari(dot)org>
Co-authored-by: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Reviewed-by: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Discussion: https://postgr.es/m/CAJ7c6TOramr1UTLcyB128LWMqita1Y7%3Darq3KHaU%3Dqikf5yKOQ%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ba21f5bf8aff277aa1659a51d26109e0914df182

Modified Files
--------------
doc/src/sgml/datatype.sgml | 11 +++++++++++
src/backend/utils/adt/bytea.c | 27 +++++++++++++++++++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_cast.dat | 6 ++++++
src/include/catalog/pg_proc.dat | 7 +++++++
src/test/regress/expected/uuid.out | 22 ++++++++++++++++++++++
src/test/regress/sql/uuid.sql | 5 +++++
7 files changed, 79 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-03-19 22:03:05 pgsql: Add parallel vacuum worker usage to VACUUM (VERBOSE) and autovac
Previous Message Tom Lane 2026-03-19 19:21:44 pgsql: Improve hash join's handling of tuples with null join keys.