Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
6c40f831
Commit
6c40f831
authored
Aug 28, 2014
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add min and max aggregates for inet/cidr data types.
Haribabu Kommi, reviewed by Muhammad Asif Naeem
parent
ec544a65
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59 additions
and
3 deletions
+59
-3
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+4
-2
src/backend/utils/adt/network.c
src/backend/utils/adt/network.c
+27
-0
src/include/catalog/catversion.h
src/include/catalog/catversion.h
+1
-1
src/include/catalog/pg_aggregate.h
src/include/catalog/pg_aggregate.h
+2
-0
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+8
-0
src/include/utils/builtins.h
src/include/utils/builtins.h
+2
-0
src/test/regress/expected/inet.out
src/test/regress/expected/inet.out
+12
-0
src/test/regress/sql/inet.sql
src/test/regress/sql/inet.sql
+3
-0
No files found.
doc/src/sgml/func.sgml
View file @
6c40f831
...
@@ -12192,7 +12192,8 @@ NULL baz</literallayout>(3 rows)</entry>
...
@@ -12192,7 +12192,8 @@ NULL baz</literallayout>(3 rows)</entry>
</indexterm>
</indexterm>
<function>
max(
<replaceable
class=
"parameter"
>
expression
</replaceable>
)
</function>
<function>
max(
<replaceable
class=
"parameter"
>
expression
</replaceable>
)
</function>
</entry>
</entry>
<entry>
any array, numeric, string, or date/time type
</entry>
<entry>
any numeric, string, date/time, network, or enum type,
or arrays of these types
</entry>
<entry>
same as argument type
</entry>
<entry>
same as argument type
</entry>
<entry>
<entry>
maximum value of
<replaceable
maximum value of
<replaceable
...
@@ -12208,7 +12209,8 @@ NULL baz</literallayout>(3 rows)</entry>
...
@@ -12208,7 +12209,8 @@ NULL baz</literallayout>(3 rows)</entry>
</indexterm>
</indexterm>
<function>
min(
<replaceable
class=
"parameter"
>
expression
</replaceable>
)
</function>
<function>
min(
<replaceable
class=
"parameter"
>
expression
</replaceable>
)
</function>
</entry>
</entry>
<entry>
any array, numeric, string, or date/time type
</entry>
<entry>
any numeric, string, date/time, network, or enum type,
or arrays of these types
</entry>
<entry>
same as argument type
</entry>
<entry>
same as argument type
</entry>
<entry>
<entry>
minimum value of
<replaceable
minimum value of
<replaceable
...
...
src/backend/utils/adt/network.c
View file @
6c40f831
...
@@ -471,6 +471,33 @@ network_ne(PG_FUNCTION_ARGS)
...
@@ -471,6 +471,33 @@ network_ne(PG_FUNCTION_ARGS)
PG_RETURN_BOOL
(
network_cmp_internal
(
a1
,
a2
)
!=
0
);
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.
* Support function for hash indexes on inet/cidr.
*/
*/
...
...
src/include/catalog/catversion.h
View file @
6c40f831
...
@@ -53,6 +53,6 @@
...
@@ -53,6 +53,6 @@
*/
*/
/* yyyymmddN */
/* yyyymmddN */
#define CATALOG_VERSION_NO 201408
162
#define CATALOG_VERSION_NO 201408
281
#endif
#endif
src/include/catalog/pg_aggregate.h
View file @
6c40f831
...
@@ -164,6 +164,7 @@ DATA(insert ( 2050 n 0 array_larger - - - - f f 1073 2277 0 0 0 _nu
...
@@ -164,6 +164,7 @@ DATA(insert ( 2050 n 0 array_larger - - - - f f 1073 2277 0 0 0 _nu
DATA
(
insert
(
2244
n
0
bpchar_larger
-
-
-
-
f
f
1060
1042
0
0
0
_null_
_null_
));
DATA
(
insert
(
2244
n
0
bpchar_larger
-
-
-
-
f
f
1060
1042
0
0
0
_null_
_null_
));
DATA
(
insert
(
2797
n
0
tidlarger
-
-
-
-
f
f
2800
27
0
0
0
_null_
_null_
));
DATA
(
insert
(
2797
n
0
tidlarger
-
-
-
-
f
f
2800
27
0
0
0
_null_
_null_
));
DATA
(
insert
(
3526
n
0
enum_larger
-
-
-
-
f
f
3519
3500
0
0
0
_null_
_null_
));
DATA
(
insert
(
3526
n
0
enum_larger
-
-
-
-
f
f
3519
3500
0
0
0
_null_
_null_
));
DATA
(
insert
(
3564
n
0
network_larger
-
-
-
-
f
f
1205
869
0
0
0
_null_
_null_
));
/* min */
/* min */
DATA
(
insert
(
2131
n
0
int8smaller
-
-
-
-
f
f
412
20
0
0
0
_null_
_null_
));
DATA
(
insert
(
2131
n
0
int8smaller
-
-
-
-
f
f
412
20
0
0
0
_null_
_null_
));
...
@@ -186,6 +187,7 @@ DATA(insert ( 2051 n 0 array_smaller - - - - f f 1072 2277 0 0 0 _n
...
@@ -186,6 +187,7 @@ DATA(insert ( 2051 n 0 array_smaller - - - - f f 1072 2277 0 0 0 _n
DATA
(
insert
(
2245
n
0
bpchar_smaller
-
-
-
-
f
f
1058
1042
0
0
0
_null_
_null_
));
DATA
(
insert
(
2245
n
0
bpchar_smaller
-
-
-
-
f
f
1058
1042
0
0
0
_null_
_null_
));
DATA
(
insert
(
2798
n
0
tidsmaller
-
-
-
-
f
f
2799
27
0
0
0
_null_
_null_
));
DATA
(
insert
(
2798
n
0
tidsmaller
-
-
-
-
f
f
2799
27
0
0
0
_null_
_null_
));
DATA
(
insert
(
3527
n
0
enum_smaller
-
-
-
-
f
f
3518
3500
0
0
0
_null_
_null_
));
DATA
(
insert
(
3527
n
0
enum_smaller
-
-
-
-
f
f
3518
3500
0
0
0
_null_
_null_
));
DATA
(
insert
(
3565
n
0
network_smaller
-
-
-
-
f
f
1203
869
0
0
0
_null_
_null_
));
/* count */
/* count */
DATA
(
insert
(
2147
n
0
int8inc_any
-
int8inc_any
int8dec_any
-
f
f
0
20
0
20
0
"0"
"0"
));
DATA
(
insert
(
2147
n
0
int8inc_any
-
int8inc_any
int8dec_any
-
f
f
0
20
0
20
0
"0"
"0"
));
...
...
src/include/catalog/pg_proc.h
View file @
6c40f831
...
@@ -2122,6 +2122,10 @@ DATA(insert OID = 922 ( network_le PGNSP PGUID 12 1 0 0 0 f f f t t f i 2 0 1
...
@@ -2122,6 +2122,10 @@ DATA(insert OID = 922 ( network_le PGNSP PGUID 12 1 0 0 0 f f f t t f i 2 0 1
DATA
(
insert
OID
=
923
(
network_gt
PGNSP
PGUID
12
1
0
0
0
f
f
f
t
t
f
i
2
0
16
"869 869"
_null_
_null_
_null_
_null_
network_gt
_null_
_null_
_null_
));
DATA
(
insert
OID
=
923
(
network_gt
PGNSP
PGUID
12
1
0
0
0
f
f
f
t
t
f
i
2
0
16
"869 869"
_null_
_null_
_null_
_null_
network_gt
_null_
_null_
_null_
));
DATA
(
insert
OID
=
924
(
network_ge
PGNSP
PGUID
12
1
0
0
0
f
f
f
t
t
f
i
2
0
16
"869 869"
_null_
_null_
_null_
_null_
network_ge
_null_
_null_
_null_
));
DATA
(
insert
OID
=
924
(
network_ge
PGNSP
PGUID
12
1
0
0
0
f
f
f
t
t
f
i
2
0
16
"869 869"
_null_
_null_
_null_
_null_
network_ge
_null_
_null_
_null_
));
DATA
(
insert
OID
=
925
(
network_ne
PGNSP
PGUID
12
1
0
0
0
f
f
f
t
t
f
i
2
0
16
"869 869"
_null_
_null_
_null_
_null_
network_ne
_null_
_null_
_null_
));
DATA
(
insert
OID
=
925
(
network_ne
PGNSP
PGUID
12
1
0
0
0
f
f
f
t
t
f
i
2
0
16
"869 869"
_null_
_null_
_null_
_null_
network_ne
_null_
_null_
_null_
));
DATA
(
insert
OID
=
3562
(
network_larger
PGNSP
PGUID
12
1
0
0
0
f
f
f
f
t
f
i
2
0
869
"869 869"
_null_
_null_
_null_
_null_
network_larger
_null_
_null_
_null_
));
DESCR
(
"larger of two"
);
DATA
(
insert
OID
=
3563
(
network_smaller
PGNSP
PGUID
12
1
0
0
0
f
f
f
f
t
f
i
2
0
869
"869 869"
_null_
_null_
_null_
_null_
network_smaller
_null_
_null_
_null_
));
DESCR
(
"smaller of two"
);
DATA
(
insert
OID
=
926
(
network_cmp
PGNSP
PGUID
12
1
0
0
0
f
f
f
f
t
f
i
2
0
23
"869 869"
_null_
_null_
_null_
_null_
network_cmp
_null_
_null_
_null_
));
DATA
(
insert
OID
=
926
(
network_cmp
PGNSP
PGUID
12
1
0
0
0
f
f
f
f
t
f
i
2
0
23
"869 869"
_null_
_null_
_null_
_null_
network_cmp
_null_
_null_
_null_
));
DESCR
(
"less-equal-greater"
);
DESCR
(
"less-equal-greater"
);
DATA
(
insert
OID
=
927
(
network_sub
PGNSP
PGUID
12
1
0
0
0
f
f
f
f
t
f
i
2
0
16
"869 869"
_null_
_null_
_null_
_null_
network_sub
_null_
_null_
_null_
));
DATA
(
insert
OID
=
927
(
network_sub
PGNSP
PGUID
12
1
0
0
0
f
f
f
f
t
f
i
2
0
16
"869 869"
_null_
_null_
_null_
_null_
network_sub
_null_
_null_
_null_
));
...
@@ -3163,6 +3167,8 @@ DATA(insert OID = 2244 ( max PGNSP PGUID 12 1 0 0 0 t f f f f f i 1 0 1042 "
...
@@ -3163,6 +3167,8 @@ DATA(insert OID = 2244 ( max PGNSP PGUID 12 1 0 0 0 t f f f f f i 1 0 1042 "
DESCR
(
"maximum value of all bpchar input values"
);
DESCR
(
"maximum value of all bpchar input values"
);
DATA
(
insert
OID
=
2797
(
max
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
27
"27"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DATA
(
insert
OID
=
2797
(
max
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
27
"27"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DESCR
(
"maximum value of all tid input values"
);
DESCR
(
"maximum value of all tid input values"
);
DATA
(
insert
OID
=
3564
(
max
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
869
"869"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DESCR
(
"maximum value of all inet input values"
);
DATA
(
insert
OID
=
2131
(
min
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
20
"20"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DATA
(
insert
OID
=
2131
(
min
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
20
"20"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DESCR
(
"minimum value of all bigint input values"
);
DESCR
(
"minimum value of all bigint input values"
);
...
@@ -3202,6 +3208,8 @@ DATA(insert OID = 2245 ( min PGNSP PGUID 12 1 0 0 0 t f f f f f i 1 0 1042 "
...
@@ -3202,6 +3208,8 @@ DATA(insert OID = 2245 ( min PGNSP PGUID 12 1 0 0 0 t f f f f f i 1 0 1042 "
DESCR
(
"minimum value of all bpchar input values"
);
DESCR
(
"minimum value of all bpchar input values"
);
DATA
(
insert
OID
=
2798
(
min
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
27
"27"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DATA
(
insert
OID
=
2798
(
min
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
27
"27"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DESCR
(
"minimum value of all tid input values"
);
DESCR
(
"minimum value of all tid input values"
);
DATA
(
insert
OID
=
3565
(
min
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
869
"869"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DESCR
(
"minimum value of all inet input values"
);
/* count has two forms: count(any) and count(*) */
/* count has two forms: count(any) and count(*) */
DATA
(
insert
OID
=
2147
(
count
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
20
"2276"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
DATA
(
insert
OID
=
2147
(
count
PGNSP
PGUID
12
1
0
0
0
t
f
f
f
f
f
i
1
0
20
"2276"
_null_
_null_
_null_
_null_
aggregate_dummy
_null_
_null_
_null_
));
...
...
src/include/utils/builtins.h
View file @
6c40f831
...
@@ -908,6 +908,8 @@ extern Datum network_eq(PG_FUNCTION_ARGS);
...
@@ -908,6 +908,8 @@ extern Datum network_eq(PG_FUNCTION_ARGS);
extern
Datum
network_ge
(
PG_FUNCTION_ARGS
);
extern
Datum
network_ge
(
PG_FUNCTION_ARGS
);
extern
Datum
network_gt
(
PG_FUNCTION_ARGS
);
extern
Datum
network_gt
(
PG_FUNCTION_ARGS
);
extern
Datum
network_ne
(
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
hashinet
(
PG_FUNCTION_ARGS
);
extern
Datum
network_sub
(
PG_FUNCTION_ARGS
);
extern
Datum
network_sub
(
PG_FUNCTION_ARGS
);
extern
Datum
network_subeq
(
PG_FUNCTION_ARGS
);
extern
Datum
network_subeq
(
PG_FUNCTION_ARGS
);
...
...
src/test/regress/expected/inet.out
View file @
6c40f831
...
@@ -204,6 +204,18 @@ SELECT '' AS ten, i, c,
...
@@ -204,6 +204,18 @@ SELECT '' AS ten, i, c,
| ::4.3.2.1/24 | ::ffff:1.2.3.4/128 | t | t | f | f | f | t | f | f | t | t | t
| ::4.3.2.1/24 | ::ffff:1.2.3.4/128 | t | t | f | f | f | t | f | f | t | t | t
(17 rows)
(17 rows)
SELECT max(i) AS max, min(i) AS min FROM INET_TBL;
max | min
-------------+-----------
10:23::ffff | 9.1.2.3/8
(1 row)
SELECT max(c) AS max, min(c) AS min FROM INET_TBL;
max | min
-----------------+------------
10:23::8000/113 | 10.0.0.0/8
(1 row)
-- check the conversion to/from text and set_netmask
-- check the conversion to/from text and set_netmask
SELECT '' AS ten, set_masklen(inet(text(i)), 24) FROM INET_TBL;
SELECT '' AS ten, set_masklen(inet(text(i)), 24) FROM INET_TBL;
ten | set_masklen
ten | set_masklen
...
...
src/test/regress/sql/inet.sql
View file @
6c40f831
...
@@ -56,6 +56,9 @@ SELECT '' AS ten, i, c,
...
@@ -56,6 +56,9 @@ SELECT '' AS ten, i, c,
i
&&
c
AS
ovr
i
&&
c
AS
ovr
FROM
INET_TBL
;
FROM
INET_TBL
;
SELECT
max
(
i
)
AS
max
,
min
(
i
)
AS
min
FROM
INET_TBL
;
SELECT
max
(
c
)
AS
max
,
min
(
c
)
AS
min
FROM
INET_TBL
;
-- check the conversion to/from text and set_netmask
-- check the conversion to/from text and set_netmask
SELECT
''
AS
ten
,
set_masklen
(
inet
(
text
(
i
)),
24
)
FROM
INET_TBL
;
SELECT
''
AS
ten
,
set_masklen
(
inet
(
text
(
i
)),
24
)
FROM
INET_TBL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment