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

Add min and max aggregates for inet/cidr data types.

Haribabu Kommi, reviewed by Muhammad Asif Naeem
This commit is contained in:
Tom Lane
2014-08-28 22:37:58 -04:00
parent ec544a65c9
commit 6c40f8316e
8 changed files with 59 additions and 3 deletions

View File

@@ -471,6 +471,33 @@ network_ne(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(network_cmp_internal(a1, a2) != 0);
}
/*
* MIN/MAX support functions.
*/
Datum
network_smaller(PG_FUNCTION_ARGS)
{
inet *a1 = PG_GETARG_INET_PP(0);
inet *a2 = PG_GETARG_INET_PP(1);
if (network_cmp_internal(a1, a2) < 0)
PG_RETURN_INET_P(a1);
else
PG_RETURN_INET_P(a2);
}
Datum
network_larger(PG_FUNCTION_ARGS)
{
inet *a1 = PG_GETARG_INET_PP(0);
inet *a2 = PG_GETARG_INET_PP(1);
if (network_cmp_internal(a1, a2) > 0)
PG_RETURN_INET_P(a1);
else
PG_RETURN_INET_P(a2);
}
/*
* Support function for hash indexes on inet/cidr.
*/