pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Masahiko Sawada <msawada@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow explicit casting between bytea and uuid.
Date: Thu, 19 Mar 2026 20:52:09 +0000
Message-ID: <E1w3KLh-000Xjy-0E@gemulon.postgresql.org> (raw)

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

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(-)



Message-ID: <E1w3KLh-000Xjy-0E@gemulon.postgresql.org>
Permalink:  ../E1w3KLh-000Xjy-0E@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w3KLh-000Xjy-0E@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: msawada@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow explicit casting between bytea and uuid.
  In-Reply-To: <E1w3KLh-000Xjy-0E@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox