1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Add min and max aggregates for composite types (records).

Like min/max for arrays, these are just thin wrappers around
the existing btree comparison function for records.

Aleksander Alekseev

Discussion: https://postgr.es/m/CAO=iB8L4WYSNxCJ8GURRjQsrXEQ2-zn3FiCsh2LMqvWq2WcONg@mail.gmail.com
This commit is contained in:
Tom Lane
2024-07-11 11:50:50 -04:00
parent bb19b70081
commit a0f1fce80c
7 changed files with 71 additions and 4 deletions

View File

@@ -1315,6 +1315,24 @@ btrecordcmp(PG_FUNCTION_ARGS)
PG_RETURN_INT32(record_cmp(fcinfo));
}
Datum
record_larger(PG_FUNCTION_ARGS)
{
if (record_cmp(fcinfo) > 0)
PG_RETURN_DATUM(PG_GETARG_DATUM(0));
else
PG_RETURN_DATUM(PG_GETARG_DATUM(1));
}
Datum
record_smaller(PG_FUNCTION_ARGS)
{
if (record_cmp(fcinfo) < 0)
PG_RETURN_DATUM(PG_GETARG_DATUM(0));
else
PG_RETURN_DATUM(PG_GETARG_DATUM(1));
}
/*
* record_image_cmp :