mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Adjust INET/CIDR display conventions and reimplement some INET/CIDR
functions, per recent discussions on pghackers. For now, I have called the verbose-display formatting function text(), but will reconsider if enough people object. initdb forced.
This commit is contained in:
@ -17,7 +17,7 @@ INSERT INTO INET_TBL (c, i) VALUES ('10', '11.1.2.3/8');
|
||||
INSERT INTO INET_TBL (c, i) VALUES ('10', '9.1.2.3/8');
|
||||
-- check that CIDR rejects invalid input:
|
||||
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/24', '192.168.1.226');
|
||||
ERROR: invalid CIDR value '192.168.1.2/24': width too small
|
||||
ERROR: invalid CIDR value '192.168.1.2/24': has bits set to right of mask
|
||||
SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL;
|
||||
ten | cidr | inet
|
||||
-----+--------------+------------------
|
||||
@ -34,35 +34,35 @@ SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL;
|
||||
(10 rows)
|
||||
|
||||
-- now test some support functions
|
||||
SELECT '' AS ten, i AS inet, host(i) FROM INET_TBL;
|
||||
ten | inet | host
|
||||
-----+------------------+---------------
|
||||
| 192.168.1.226/24 | 192.168.1.226
|
||||
| 192.168.1.226 | 192.168.1.226
|
||||
| 10.1.2.3/8 | 10.1.2.3
|
||||
| 10.1.2.3/8 | 10.1.2.3
|
||||
| 10.1.2.3 | 10.1.2.3
|
||||
| 10.1.2.3/24 | 10.1.2.3
|
||||
| 10.1.2.3/16 | 10.1.2.3
|
||||
| 10.1.2.3/8 | 10.1.2.3
|
||||
| 11.1.2.3/8 | 11.1.2.3
|
||||
| 9.1.2.3/8 | 9.1.2.3
|
||||
SELECT '' AS ten, i AS inet, host(i), text(i) FROM INET_TBL;
|
||||
ten | inet | host | text
|
||||
-----+------------------+---------------+------------------
|
||||
| 192.168.1.226/24 | 192.168.1.226 | 192.168.1.226/24
|
||||
| 192.168.1.226 | 192.168.1.226 | 192.168.1.226/32
|
||||
| 10.1.2.3/8 | 10.1.2.3 | 10.1.2.3/8
|
||||
| 10.1.2.3/8 | 10.1.2.3 | 10.1.2.3/8
|
||||
| 10.1.2.3 | 10.1.2.3 | 10.1.2.3/32
|
||||
| 10.1.2.3/24 | 10.1.2.3 | 10.1.2.3/24
|
||||
| 10.1.2.3/16 | 10.1.2.3 | 10.1.2.3/16
|
||||
| 10.1.2.3/8 | 10.1.2.3 | 10.1.2.3/8
|
||||
| 11.1.2.3/8 | 11.1.2.3 | 11.1.2.3/8
|
||||
| 9.1.2.3/8 | 9.1.2.3 | 9.1.2.3/8
|
||||
(10 rows)
|
||||
|
||||
SELECT '' AS ten, c AS cidr, broadcast(c),
|
||||
i AS inet, broadcast(i) FROM INET_TBL;
|
||||
ten | cidr | broadcast | inet | broadcast
|
||||
-----+--------------+-----------------+------------------+-----------------
|
||||
| 192.168.1/24 | 192.168.1.255 | 192.168.1.226/24 | 192.168.1.255
|
||||
| 192.168.1/24 | 192.168.1.255 | 192.168.1.226 | 255.255.255.255
|
||||
| 10/8 | 10.255.255.255 | 10.1.2.3/8 | 10.255.255.255
|
||||
| 10.0.0.0/32 | 255.255.255.255 | 10.1.2.3/8 | 10.255.255.255
|
||||
| 10.1.2.3/32 | 255.255.255.255 | 10.1.2.3 | 255.255.255.255
|
||||
| 10.1.2/24 | 10.1.2.255 | 10.1.2.3/24 | 10.1.2.255
|
||||
| 10.1/16 | 10.1.255.255 | 10.1.2.3/16 | 10.1.255.255
|
||||
| 10/8 | 10.255.255.255 | 10.1.2.3/8 | 10.255.255.255
|
||||
| 10/8 | 10.255.255.255 | 11.1.2.3/8 | 11.255.255.255
|
||||
| 10/8 | 10.255.255.255 | 9.1.2.3/8 | 9.255.255.255
|
||||
ten | cidr | broadcast | inet | broadcast
|
||||
-----+--------------+------------------+------------------+------------------
|
||||
| 192.168.1/24 | 192.168.1.255/24 | 192.168.1.226/24 | 192.168.1.255/24
|
||||
| 192.168.1/24 | 192.168.1.255/24 | 192.168.1.226 | 255.255.255.255
|
||||
| 10/8 | 10.255.255.255/8 | 10.1.2.3/8 | 10.255.255.255/8
|
||||
| 10.0.0.0/32 | 255.255.255.255 | 10.1.2.3/8 | 10.255.255.255/8
|
||||
| 10.1.2.3/32 | 255.255.255.255 | 10.1.2.3 | 255.255.255.255
|
||||
| 10.1.2/24 | 10.1.2.255/24 | 10.1.2.3/24 | 10.1.2.255/24
|
||||
| 10.1/16 | 10.1.255.255/16 | 10.1.2.3/16 | 10.1.255.255/16
|
||||
| 10/8 | 10.255.255.255/8 | 10.1.2.3/8 | 10.255.255.255/8
|
||||
| 10/8 | 10.255.255.255/8 | 11.1.2.3/8 | 11.255.255.255/8
|
||||
| 10/8 | 10.255.255.255/8 | 9.1.2.3/8 | 9.255.255.255/8
|
||||
(10 rows)
|
||||
|
||||
SELECT '' AS ten, c AS cidr, network(c) AS "network(cidr)",
|
||||
|
@ -23,7 +23,7 @@ SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL;
|
||||
|
||||
-- now test some support functions
|
||||
|
||||
SELECT '' AS ten, i AS inet, host(i) FROM INET_TBL;
|
||||
SELECT '' AS ten, i AS inet, host(i), text(i) FROM INET_TBL;
|
||||
SELECT '' AS ten, c AS cidr, broadcast(c),
|
||||
i AS inet, broadcast(i) FROM INET_TBL;
|
||||
SELECT '' AS ten, c AS cidr, network(c) AS "network(cidr)",
|
||||
|
Reference in New Issue
Block a user