pgsql: Add min() and max() aggregate support for uuid.

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add min() and max() aggregate support for uuid.
Date: 2026-07-01 18:43:14
Message-ID: E1wezty-000zKr-0l@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add min() and max() aggregate support for uuid.

The uuid type already has a full set of comparison operators and a
btree operator class, so it is totally ordered. min() and max() were
the only common aggregates missing for it. Add the uuid_larger() and
uuid_smaller() support functions and register the min(uuid) and
max(uuid) aggregates that use them.

uuid values are compared lexicographically over their 128 bits. For
UUIDv7, whose most significant bits encode a Unix timestamp, this
coincides with chronological order, so min() and max() return the
oldest and newest values.

Bump catalog version.

Author: Tristan Partin <tristan(at)partin(dot)io>
Reviewed-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Discussion: https://postgr.es/m/DJGML0T9FCDV.3VA29JLODXEHZ@partin.io

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2e606d75c0bf9c867b51ad228eae384a9d1de21a

Modified Files
--------------
doc/src/sgml/datatype.sgml | 4 ++++
doc/src/sgml/func/func-aggregate.sgml | 6 ++++--
src/backend/utils/adt/uuid.c | 18 ++++++++++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_aggregate.dat | 6 ++++++
src/include/catalog/pg_proc.dat | 12 ++++++++++++
src/test/regress/expected/opr_sanity.out | 2 ++
src/test/regress/expected/uuid.out | 7 +++++++
src/test/regress/sql/uuid.sql | 3 +++
9 files changed, 57 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-07-02 00:34:39 pgsql: Add system view pg_stat_kind_info
Previous Message Tom Lane 2026-07-01 17:44:51 pgsql: Fix macro-redefinition warning introduced by aeb07c55f.