diff options
author | Tom Lane | 2014-08-29 02:37:58 +0000 |
---|---|---|
committer | Tom Lane | 2014-08-29 02:37:58 +0000 |
commit | 6c40f8316ed38a92049784b3e3d3b514ed379b5a (patch) | |
tree | 906ae853055c894e2e2fbdc6f6a71d02ebf6b36f /src/backend/utils/adt/network.c | |
parent | ec544a65c9090bc9da11ea384d1369fd552ca8b0 (diff) |
Add min and max aggregates for inet/cidr data types.
Haribabu Kommi, reviewed by Muhammad Asif Naeem
Diffstat (limited to 'src/backend/utils/adt/network.c')
-rw-r--r-- | src/backend/utils/adt/network.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 69c7ac182f0..3a705da6197 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -472,6 +472,33 @@ network_ne(PG_FUNCTION_ARGS) } /* + * 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. */ Datum |