ERROR: table "inet_tbl" does not exist
CREATE TABLE INET_TBL (c cidr, i inet);
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.226/24');
-INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/24', '192.168.1.226');
+INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/26', '192.168.1.226');
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/24');
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/25');
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.255/24');
INSERT INTO INET_TBL (c, i) VALUES ('10:23::8000/113', '10:23::ffff');
INSERT INTO INET_TBL (c, i) VALUES ('::ffff:1.2.3.4', '::4.3.2.1/24');
-- 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"
+INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/30', '192.168.1.226');
+ERROR: invalid cidr value: "192.168.1.2/30"
DETAIL: Value has bits set to right of mask.
INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1.2.3.4');
ERROR: invalid input syntax for type cidr: "1234::1234::1234"
-- check that CIDR rejects invalid input when converting from text:
-INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/24'), '192.168.1.226');
-ERROR: invalid cidr value: "192.168.1.2/24"
+INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/30'), '192.168.1.226');
+ERROR: invalid cidr value: "192.168.1.2/30"
DETAIL: Value has bits set to right of mask.
INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226');
ERROR: invalid cidr value: "ffff:ffff:ffff:ffff::/24"
ten | cidr | inet
-----+--------------------+------------------
| 192.168.1.0/24 | 192.168.1.226/24
- | 192.168.1.0/24 | 192.168.1.226
+ | 192.168.1.0/26 | 192.168.1.226
| 192.168.1.0/24 | 192.168.1.0/24
| 192.168.1.0/24 | 192.168.1.0/25
| 192.168.1.0/24 | 192.168.1.255/24
ten | cidr | broadcast | inet | broadcast
-----+--------------------+------------------+------------------+---------------------------------------
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.226/24 | 192.168.1.255/24
- | 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.226 | 192.168.1.226
+ | 192.168.1.0/26 | 192.168.1.63/26 | 192.168.1.226 | 192.168.1.226
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.0/24 | 192.168.1.255/24
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.0/25 | 192.168.1.127/25
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.255/24 | 192.168.1.255/24
ten | cidr | network(cidr) | inet | network(inet)
-----+--------------------+--------------------+------------------+------------------
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.226/24 | 192.168.1.0/24
- | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.226 | 192.168.1.226/32
+ | 192.168.1.0/26 | 192.168.1.0/26 | 192.168.1.226 | 192.168.1.226/32
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/24
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/25 | 192.168.1.0/25
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.0/24
ten | cidr | masklen(cidr) | inet | masklen(inet)
-----+--------------------+---------------+------------------+---------------
| 192.168.1.0/24 | 24 | 192.168.1.226/24 | 24
- | 192.168.1.0/24 | 24 | 192.168.1.226 | 32
+ | 192.168.1.0/26 | 26 | 192.168.1.226 | 32
| 192.168.1.0/24 | 24 | 192.168.1.0/24 | 24
| 192.168.1.0/24 | 24 | 192.168.1.0/25 | 25
| 192.168.1.0/24 | 24 | 192.168.1.255/24 | 24
ten | i | c | lt | le | eq | ge | gt | ne | sb | sbe | sup | spe
-----+------------------+--------------------+----+----+----+----+----+----+----+-----+-----+-----
| 192.168.1.226/24 | 192.168.1.0/24 | f | f | f | t | t | t | f | t | f | t
- | 192.168.1.226 | 192.168.1.0/24 | f | f | f | t | t | t | t | t | f | f
+ | 192.168.1.226 | 192.168.1.0/26 | f | f | f | t | t | t | f | f | f | f
| 192.168.1.0/24 | 192.168.1.0/24 | f | t | t | t | f | f | f | t | f | t
| 192.168.1.0/25 | 192.168.1.0/24 | f | f | f | t | t | t | t | t | f | f
| 192.168.1.255/24 | 192.168.1.0/24 | f | f | f | t | t | t | f | t | f | t
----------------+------------------
192.168.1.0/24 | 192.168.1.0/25
192.168.1.0/24 | 192.168.1.255/25
- 192.168.1.0/24 | 192.168.1.226
+ 192.168.1.0/26 | 192.168.1.226
(3 rows)
SELECT * FROM inet_tbl WHERE i<<='192.168.1.0/24'::cidr;
192.168.1.0/24 | 192.168.1.255/24
192.168.1.0/24 | 192.168.1.0/25
192.168.1.0/24 | 192.168.1.255/25
- 192.168.1.0/24 | 192.168.1.226
+ 192.168.1.0/26 | 192.168.1.226
(6 rows)
SET enable_seqscan TO on;
DROP TABLE INET_TBL;
CREATE TABLE INET_TBL (c cidr, i inet);
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.226/24');
-INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/24', '192.168.1.226');
+INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/26', '192.168.1.226');
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/24');
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/25');
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.255/24');
INSERT INTO INET_TBL (c, i) VALUES ('10:23::8000/113', '10:23::ffff');
INSERT INTO INET_TBL (c, i) VALUES ('::ffff:1.2.3.4', '::4.3.2.1/24');
-- check that CIDR rejects invalid input:
-INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/24', '192.168.1.226');
+INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/30', '192.168.1.226');
INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1.2.3.4');
-- check that CIDR rejects invalid input when converting from text:
-INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/24'), '192.168.1.226');
+INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/30'), '192.168.1.226');
INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226');
SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL;