min max support ip

This commit is contained in:
xiteming 2021-08-26 10:32:24 +08:00
parent b75bb44385
commit ee7c6ffb8f
16 changed files with 496 additions and 8 deletions

View File

@ -6005,7 +6005,7 @@
AddBuiltinFunc(_0(697), _1("masklen"), _2(1), _3(true), _4(false), _5(network_masklen), _6(23), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("network_masklen"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
),
AddFuncGroup(
"max", 22,
"max", 23,
AddBuiltinFunc(_0(2050), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 2277), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(2115), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(20), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 20), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(2116), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(23), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
@ -6027,8 +6027,9 @@
AddBuiltinFunc(_0(2797), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(27), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 27), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(3526), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(3500), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 3500), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(5538), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(5545), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 5545), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(9010), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(9003), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 9003), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
),
AddBuiltinFunc(_0(9010), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(9003), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 9003), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(6668), _1("max"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(869), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
),
AddFuncGroup(
"md5", 2,
AddBuiltinFunc(_0(2311), _1("md5"), _2(1), _3(true), _4(false), _5(md5_text), _6(25), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 25), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("md5_text"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
@ -6052,7 +6053,7 @@
AddBuiltinFunc(_0(5559), _1("median_transfn"), _2(2), _3(false), _4(false), _5(median_transfn), _6(2281), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 2281, 2276), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("median_transfn"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false)),
),
AddFuncGroup(
"min", 21,
"min", 22,
AddBuiltinFunc(_0(2051), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(2277), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 2277), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(2131), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(20), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 20), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(2132), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(23), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 23), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
@ -6073,7 +6074,8 @@
AddBuiltinFunc(_0(2245), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(1042), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 1042), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(2798), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(27), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 27), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(3527), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(3500), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 3500), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(9009), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(9003), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 9003), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
AddBuiltinFunc(_0(9009), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(9003), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 9003), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')),
AddBuiltinFunc(_0(6669), _1("min"), _2(1), _3(false), _4(false), _5(aggregate_dummy), _6(869), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(true), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(1, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("aggregate_dummy"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
),
AddFuncGroup(
"mktinterval", 1,
@ -6235,6 +6237,10 @@
"network_gt", 1,
AddBuiltinFunc(_0(923), _1("network_gt"), _2(2), _3(true), _4(false), _5(network_gt), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(true), _18('i'), _19(0), _20(2, 869, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("network_gt"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
),
AddFuncGroup(
"network_larger", 1,
AddBuiltinFunc(_0(6666), _1("network_larger"), _2(2), _3(true), _4(false), _5(network_larger), _6(869), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 869, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("network_larger"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
),
AddFuncGroup(
"network_le", 1,
AddBuiltinFunc(_0(922), _1("network_le"), _2(2), _3(true), _4(false), _5(network_le), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(true), _18('i'), _19(0), _20(2, 869, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("network_le"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
@ -6247,6 +6253,10 @@
"network_ne", 1,
AddBuiltinFunc(_0(925), _1("network_ne"), _2(2), _3(true), _4(false), _5(network_ne), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(true), _18('i'), _19(0), _20(2, 869, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("network_ne"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
),
AddFuncGroup(
"network_smaller", 1,
AddBuiltinFunc(_0(6667), _1("network_smaller"), _2(2), _3(true), _4(false), _5(network_smaller), _6(869), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 869, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("network_smaller"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))
),
AddFuncGroup(
"network_sub", 1,
AddBuiltinFunc(_0(927), _1("network_sub"), _2(2), _3(true), _4(false), _5(network_sub), _6(16), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('i'), _19(0), _20(2, 869, 869), _21(NULL), _22(NULL), _23(NULL), _24(NULL), _25("network_sub"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'))

View File

@ -471,7 +471,30 @@ Datum 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.
*/

View File

@ -59,7 +59,7 @@ bool open_join_children = true;
bool will_shutdown = false;
/* hard-wired binary version number */
const uint32 GRAND_VERSION_NUM = 92307;
const uint32 GRAND_VERSION_NUM = 92308;
const uint32 MATVIEW_VERSION_NUM = 92213;
const uint32 PARTIALPUSH_VERSION_NUM = 92087;

View File

@ -166,6 +166,7 @@ DATA(insert ( 2127 timestamptz_larger timestamptz_larger - 1324 1184 _null_ _nu
DATA(insert ( 2128 interval_larger interval_larger - 1334 1186 _null_ _null_ n 0));
DATA(insert ( 2129 text_larger text_larger - 666 25 _null_ _null_ n 0));
DATA(insert ( 2130 numeric_larger numeric_larger - 1756 1700 _null_ _null_ n 0));
DATA(insert ( 6668 network_larger network_larger - 1205 869 _null_ _null_ n 0));
#define NUMERICLARGERFUNCOID 2130
DATA(insert ( 2050 array_larger array_larger - 1073 2277 _null_ _null_ n 0));
DATA(insert ( 2244 bpchar_larger bpchar_larger - 1060 1042 _null_ _null_ n 0));
@ -196,6 +197,7 @@ DATA(insert ( 2143 timestamptz_smaller timestamptz_smaller - 1322 1184 _null_ _
DATA(insert ( 2144 interval_smaller interval_smaller - 1332 1186 _null_ _null_ n 0));
DATA(insert ( 2145 text_smaller text_smaller - 664 25 _null_ _null_ n 0));
DATA(insert ( 2146 numeric_smaller numeric_smaller - 1754 1700 _null_ _null_ n 0));
DATA(insert ( 6669 network_smaller network_smaller - 1203 869 _null_ _null_ n 0));
#define NUMERICSMALLERFUNCOID 2146
DATA(insert ( 2051 array_smaller array_smaller - 1072 2277 _null_ _null_ n 0));
DATA(insert ( 2245 bpchar_smaller bpchar_smaller - 1058 1042 _null_ _null_ n 0));

View File

@ -4,3 +4,4 @@ DROP AGGREGATE IF EXISTS pg_catalog.last(anyelement) CASCADE;
DROP AGGREGATE IF EXISTS pg_catalog.first(anyelement) CASCADE;
DROP FUNCTION IF EXISTS pg_catalog.last_transition(anyelement, anyelement) CASCADE;
DROP FUNCTION IF EXISTS pg_catalog.first_transition(anyelement, anyelement) CASCADE;

View File

@ -0,0 +1,4 @@
DROP AGGREGATE IF EXISTS pg_catalog.max(inet) CASCADE;
DROP AGGREGATE IF EXISTS pg_catalog.min(inet) CASCADE;
DROP FUNCTION IF EXISTS pg_catalog.network_larger(inet, inet) CASCADE;
DROP FUNCTION IF EXISTS pg_catalog.network_smaller(inet, inet) CASCADE;

View File

@ -0,0 +1,4 @@
DROP AGGREGATE IF EXISTS pg_catalog.max(inet) CASCADE;
DROP AGGREGATE IF EXISTS pg_catalog.min(inet) CASCADE;
DROP FUNCTION IF EXISTS pg_catalog.network_larger(inet, inet) CASCADE;
DROP FUNCTION IF EXISTS pg_catalog.network_smaller(inet, inet) CASCADE;

View File

@ -35,4 +35,4 @@ SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6561;
create aggregate last(anyelement) (
sfunc = last_transition,
stype = anyelement
);
);

View File

@ -0,0 +1,25 @@
DROP FUNCTION IF EXISTS pg_catalog.network_larger(inet, inet) CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6666;
CREATE FUNCTION pg_catalog.network_larger (
inet, inet
) RETURNS inet LANGUAGE INTERNAL STRICT as 'network_larger';
DROP FUNCTION IF EXISTS pg_catalog.network_smaller(inet, inet) CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6667;
CREATE FUNCTION pg_catalog.network_smaller (
inet, inet
) RETURNS inet LANGUAGE INTERNAL STRICT as 'network_smaller';
DROP aggregate IF EXISTS pg_catalog.max(inet) CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6668;
create aggregate max(inet) (
sfunc = network_larger,
stype = inet
);
DROP aggregate IF EXISTS pg_catalog.min(inet) CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6669;
create aggregate min(inet) (
sfunc = network_smaller,
stype = inet
);

View File

@ -35,4 +35,4 @@ SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6561;
create aggregate last(anyelement) (
sfunc = last_transition,
stype = anyelement
);
);

View File

@ -0,0 +1,25 @@
DROP FUNCTION IF EXISTS pg_catalog.network_larger(inet, inet) CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6666;
CREATE FUNCTION pg_catalog.network_larger (
inet, inet
) RETURNS inet LANGUAGE INTERNAL STRICT as 'network_larger';
DROP FUNCTION IF EXISTS pg_catalog.network_smaller(inet, inet) CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6667;
CREATE FUNCTION pg_catalog.network_smaller (
inet, inet
) RETURNS inet LANGUAGE INTERNAL STRICT as 'network_smaller';
DROP aggregate IF EXISTS pg_catalog.max(inet) CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6668;
create aggregate max(inet) (
sfunc = network_larger,
stype = inet
);
DROP aggregate IF EXISTS pg_catalog.min(inet) CASCADE;
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC, 6669;
create aggregate min(inet) (
sfunc = network_smaller,
stype = inet
);

View File

@ -1097,6 +1097,8 @@ extern Datum network_eq(PG_FUNCTION_ARGS);
extern Datum network_ge(PG_FUNCTION_ARGS);
extern Datum network_gt(PG_FUNCTION_ARGS);
extern Datum network_ne(PG_FUNCTION_ARGS);
extern Datum network_smaller(PG_FUNCTION_ARGS);
extern Datum network_larger(PG_FUNCTION_ARGS);
extern Datum hashinet(PG_FUNCTION_ARGS);
extern Datum network_sub(PG_FUNCTION_ARGS);
extern Datum network_subeq(PG_FUNCTION_ARGS);

View File

@ -0,0 +1,240 @@
--To test that the min and max functions support IP address type parameters
--Test whether the function is normal when inet type data is input: support, and the result is in line with expectations
--Create a table space
drop tablespace if exists row_tabspace01;
NOTICE: Tablespace "row_tabspace01" does not exist, skipping.
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
NOTICE: table "row_tab01" does not exist, skipping
create table row_tab01(ip_addr inet,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values('192.168.1.0','taishan00');
insert into row_tab01 values('192.168.1.1','taishan01');
insert into row_tab01 values('192.168.1.2','taishan02');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
min_ip_addr
-------------
192.168.1.0
(1 row)
select max(ip_addr) as max_ip_addr from row_tab01;
max_ip_addr
-------------
192.168.1.2
(1 row)
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--Create a column table space
drop tablespace if exists column_tabspace01;
NOTICE: Tablespace "column_tabspace01" does not exist, skipping.
create tablespace column_tabspace01 relative location 'tablespace/column_space01';
--Create table
drop table if exists column_tab01;
NOTICE: table "column_tab01" does not exist, skipping
create table column_tab01(ip_addr inet,ip_name char(9)) with(orientation=column);
--Insert data
insert into column_tab01 values('192.168.1.0','taishan00');
insert into column_tab01 values('192.168.1.1','taishan01');
insert into column_tab01 values('192.168.1.2','taishan02');
--function test
select min(ip_addr) as min_ip_addr from column_tab01;
min_ip_addr
-------------
192.168.1.0
(1 row)
select max(ip_addr) as max_ip_addr from column_tab01;
max_ip_addr
-------------
192.168.1.2
(1 row)
--Delete table
drop table column_tab01 cascade;
drop tablespace column_tabspace01;
--Test whether the function is normal when cidr type data is input: support, and the result is in line with expectations
---When the mask is all 1, the IP address is unique, and the comparison result does not display the mask
--IPV4 test
--Test mask comparison function
--Create a table space
drop tablespace if exists row_tabspace01;
NOTICE: Tablespace "row_tabspace01" does not exist, skipping.
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
NOTICE: table "row_tab01" does not exist, skipping
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('192.168.1.8/32','taishan00');
insert into row_tab01 values ('192.168.1.8/31','taishan00');
insert into row_tab01 values ('192.168.1.8/30','taishan00');
insert into row_tab01 values ('192.168.1.8/29','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
min_ip_addr
----------------
192.168.1.8/29
(1 row)
select max(ip_addr) as max_ip_addr from row_tab01;
max_ip_addr
-------------
192.168.1.8
(1 row)
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--IPV4 test
--Test the IP address comparison function
--Create a table space
drop tablespace if exists row_tabspace01;
NOTICE: Tablespace "row_tabspace01" does not exist, skipping.
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
NOTICE: table "row_tab01" does not exist, skipping
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('10.1.2.8/29','taishan00');
insert into row_tab01 values ('10.1.2.16/29','taishan00');
insert into row_tab01 values ('10.1.2.32/29','taishan00');
insert into row_tab01 values ('10.1.2.48/29','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
min_ip_addr
-------------
10.1.2.8/29
(1 row)
select max(ip_addr) as max_ip_addr from row_tab01;
max_ip_addr
--------------
10.1.2.48/29
(1 row)
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--IPV6 test
--Test mask comparison function
--Create a table space
drop tablespace if exists row_tabspace01;
NOTICE: Tablespace "row_tabspace01" does not exist, skipping.
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
NOTICE: table "row_tab01" does not exist, skipping
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127','taishan00');
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/128','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
min_ip_addr
--------------------------------------
2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127
(1 row)
select max(ip_addr) as max_ip_addr from row_tab01;
max_ip_addr
----------------------------------
2001:4f8:3:ba:2e0:81ff:fe22:d1f0
(1 row)
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--IPV6 test
--Test the IP address comparison function
drop tablespace if exists row_tabspace01;
NOTICE: Tablespace "row_tabspace01" does not exist, skipping.
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
NOTICE: table "row_tab01" does not exist, skipping
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1e0/127','taishan00');
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
min_ip_addr
--------------------------------------
2001:4f8:3:ba:2e0:81ff:fe22:d1e0/127
(1 row)
select max(ip_addr) as max_ip_addr from row_tab01;
max_ip_addr
--------------------------------------
2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127
(1 row)
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--when insert IP address type different
--Create a table space
drop tablespace if exists row_tabspace01;
NOTICE: Tablespace "row_tabspace01" does not exist, skipping.
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
NOTICE: table "row_tab01" does not exist, skipping
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('10.1.2.48/29','taishan00');
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
min_ip_addr
--------------
10.1.2.48/29
(1 row)
select max(ip_addr) as max_ip_addr from row_tab01;
max_ip_addr
--------------------------------------
2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127
(1 row)
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--when insert IP address type different
--Create a table space
drop tablespace if exists row_tabspace01;
NOTICE: Tablespace "row_tabspace01" does not exist, skipping.
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
NOTICE: table "row_tab01" does not exist, skipping
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('taishan00');
ERROR: invalid input syntax for type cidr: "taishan00"
LINE 1: insert into row_tab01 values ('taishan00');
^
CONTEXT: referenced column: ip_addr
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127','taishan00');
insert into row_tab01 values ('0','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
min_ip_addr
-------------
0.0.0.0/8
(1 row)
select max(ip_addr) as max_ip_addr from row_tab01;
max_ip_addr
--------------------------------------
2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127
(1 row)
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;

View File

@ -2837,6 +2837,10 @@ WHERE d.classoid IS NULL AND p1.oid <= 9999 order by 1;
6559 | last_transition
6560 | first
6561 | last
6666 | network_larger
6667 | network_smaller
6668 | max
6669 | min
7101 | db4ai_predict_by_bool
7102 | db4ai_predict_by_int32
7103 | db4ai_predict_by_int64

View File

@ -176,6 +176,10 @@ test: single_node_produce_commit_rollback
test: instr_unique_sql
test: shutdown
# To check min_max fuc support IP
test: min_max_support_IP
# interval partition
test: hw_partition_interval
test: hw_partition_interval_exchange

View File

@ -0,0 +1,144 @@
--To test that the min and max functions support IP address type parameters
--Test whether the function is normal when inet type data is input: support, and the result is in line with expectations
--Create a table space
drop tablespace if exists row_tabspace01;
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
create table row_tab01(ip_addr inet,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values('192.168.1.0','taishan00');
insert into row_tab01 values('192.168.1.1','taishan01');
insert into row_tab01 values('192.168.1.2','taishan02');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
select max(ip_addr) as max_ip_addr from row_tab01;
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--Create a column table space
drop tablespace if exists column_tabspace01;
create tablespace column_tabspace01 relative location 'tablespace/column_space01';
--Create table
drop table if exists column_tab01;
create table column_tab01(ip_addr inet,ip_name char(9)) with(orientation=column);
--Insert data
insert into column_tab01 values('192.168.1.0','taishan00');
insert into column_tab01 values('192.168.1.1','taishan01');
insert into column_tab01 values('192.168.1.2','taishan02');
--function test
select min(ip_addr) as min_ip_addr from column_tab01;
select max(ip_addr) as max_ip_addr from column_tab01;
--Delete table
drop table column_tab01 cascade;
drop tablespace column_tabspace01;
--Test whether the function is normal when cidr type data is input: support, and the result is in line with expectations
---When the mask is all 1, the IP address is unique, and the comparison result does not display the mask
--IPV4 test
--Test mask comparison function
--Create a table space
drop tablespace if exists row_tabspace01;
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('192.168.1.8/32','taishan00');
insert into row_tab01 values ('192.168.1.8/31','taishan00');
insert into row_tab01 values ('192.168.1.8/30','taishan00');
insert into row_tab01 values ('192.168.1.8/29','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
select max(ip_addr) as max_ip_addr from row_tab01;
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--IPV4 test
--Test the IP address comparison function
--Create a table space
drop tablespace if exists row_tabspace01;
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('10.1.2.8/29','taishan00');
insert into row_tab01 values ('10.1.2.16/29','taishan00');
insert into row_tab01 values ('10.1.2.32/29','taishan00');
insert into row_tab01 values ('10.1.2.48/29','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
select max(ip_addr) as max_ip_addr from row_tab01;
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--IPV6 test
--Test mask comparison function
--Create a table space
drop tablespace if exists row_tabspace01;
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127','taishan00');
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/128','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
select max(ip_addr) as max_ip_addr from row_tab01;
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--IPV6 test
--Test the IP address comparison function
drop tablespace if exists row_tabspace01;
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1e0/127','taishan00');
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
select max(ip_addr) as max_ip_addr from row_tab01;
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--when insert IP address type different
--Create a table space
drop tablespace if exists row_tabspace01;
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('10.1.2.48/29','taishan00');
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
select max(ip_addr) as max_ip_addr from row_tab01;
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;
--when insert IP address type different
--Create a table space
drop tablespace if exists row_tabspace01;
create tablespace row_tabspace01 relative location 'tablespace/row_space01';
--Create table
drop table if exists row_tab01;
create table row_tab01(ip_addr cidr,ip_name char(9)) with(orientation=row);
--Insert data
insert into row_tab01 values ('taishan00');
insert into row_tab01 values ('2001:4f8:3:ba:2e0:81ff:fe22:d1f0/127','taishan00');
insert into row_tab01 values ('0','taishan00');
--function test
select min(ip_addr) as min_ip_addr from row_tab01;
select max(ip_addr) as max_ip_addr from row_tab01;
--Delete table
drop table row_tab01 cascade;
drop tablespace row_tabspace01;