pgsql: Add min() and max() aggregate support for uuid.
pgsql: Add min() and max() aggregate support for uuid.
От:
Masahiko Sawada <msawada@postgresql.org>
Дата:
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 Reviewed-by: Bharath Rupireddy Reviewed-by: Zsolt Parragi Reviewed-by: Masahiko Sawada 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(-)