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

Masahiko Sawada <msawada@postgresql.org>

Commit: 2e606d75c0bf9c867b51ad228eae384a9d1de21a
Author: Masahiko Sawada <msawada@postgresql.org>
Date: 2026-07-01T18:42:54Z
Releases: master
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@partin.io>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/DJGML0T9FCDV.3VA29JLODXEHZ@partin.io

Files

Documentation touched

Discussion