pgsql: Support UUIDv6 in uuid_extract_timestamp().

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Support UUIDv6 in uuid_extract_timestamp().
Date: 2026-08-04 17:57:56
Message-ID: E1wrJOm-00000000CL5-3yAU@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Support UUIDv6 in uuid_extract_timestamp().

Previously, uuid_extract_timestamp() returned NULL for UUIDv6 values,
even though it already extracted timestamps from UUIDv1 and
UUIDv7.

This commit adds a UUIDv6 branch that reassembles the timestamp from
that layout and then converts it exactly as the UUIDv1 branch does. We
provide no uuidv6() generator, but such values can be produced by
client applications and stored in the database, just as UUIDv1 values
already are.

Author: Tristan Partin <tristan(at)partin(dot)io>
Reviewed-by: Miłosz Bieniek <bieniek(dot)milosz(at)proton(dot)me>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Discussion: https://postgr.es/m/DJHJW50YWKIT.XIOT4NOZRQ03@partin.io

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/451871b740d7ad252b8aeaf16a20bcf831a39254

Modified Files
--------------
doc/src/sgml/func/func-uuid.sgml | 2 +-
src/backend/utils/adt/uuid.c | 17 +++++++++++++++++
src/test/regress/expected/uuid.out | 6 ++++++
src/test/regress/sql/uuid.sql | 1 +
4 files changed, 25 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-08-04 20:41:14 pgsql: Add comments to uuid_extract_timestamp().
Previous Message Daniel Gustafsson 2026-08-04 13:45:05 pgsql: Reindent conditional to improve readability