1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

Implement max() and min() aggregates for array types. Patch from Koju

Iijima, reviewed by Neil Conway. Catalog version number bumped,
regression tests updated.
This commit is contained in:
Neil Conway
2005-02-28 03:45:24 +00:00
parent 517872c566
commit 484f0464ff
8 changed files with 118 additions and 9 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.115 2004/12/31 22:01:21 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.116 2005/02/28 03:45:21 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -3387,3 +3387,33 @@ makeMdArrayResult(ArrayBuildState *astate,
return PointerGetDatum(result);
}
Datum
array_larger(PG_FUNCTION_ARGS)
{
ArrayType *v1,
*v2,
*result;
v1 = PG_GETARG_ARRAYTYPE_P(0);
v2 = PG_GETARG_ARRAYTYPE_P(1);
result = ((array_cmp(fcinfo) > 0) ? v1 : v2);
PG_RETURN_ARRAYTYPE_P(result);
}
Datum
array_smaller(PG_FUNCTION_ARGS)
{
ArrayType *v1,
*v2,
*result;
v1 = PG_GETARG_ARRAYTYPE_P(0);
v2 = PG_GETARG_ARRAYTYPE_P(1);
result = ((array_cmp(fcinfo) < 0) ? v1 : v2);
PG_RETURN_ARRAYTYPE_P(result);
}