From 8a657808b0476eb9482eca51a4dd63075c517a58 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 8 Oct 2004 01:45:37 +0000 Subject: [PATCH] Update CIDR regresion tests to test for network masks inside the last byte being tested, to catch any future breakage. --- src/test/regress/expected/inet.out | 24 ++++++++++++------------ src/test/regress/sql/inet.sql | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/test/regress/expected/inet.out b/src/test/regress/expected/inet.out index 7a8e038dbf..ddcdbba456 100644 --- a/src/test/regress/expected/inet.out +++ b/src/test/regress/expected/inet.out @@ -6,7 +6,7 @@ DROP TABLE INET_TBL; 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'); @@ -23,14 +23,14 @@ INSERT INTO INET_TBL (c, i) VALUES ('10:23::f1', '10:23::f1/64'); 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" @@ -39,7 +39,7 @@ SELECT '' AS ten, c AS cidr, i AS inet FROM INET_TBL; 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 @@ -85,7 +85,7 @@ SELECT '' AS ten, c AS cidr, broadcast(c), 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 @@ -108,7 +108,7 @@ SELECT '' AS ten, c AS cidr, network(c) AS "network(cidr)", 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 @@ -131,7 +131,7 @@ SELECT '' AS ten, c AS cidr, masklen(c) AS "masklen(cidr)", 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 @@ -177,7 +177,7 @@ SELECT '' AS ten, i, c, 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 @@ -226,7 +226,7 @@ SELECT * FROM inet_tbl WHERE i<<'192.168.1.0/24'::cidr; ----------------+------------------ 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; @@ -237,7 +237,7 @@ 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; diff --git a/src/test/regress/sql/inet.sql b/src/test/regress/sql/inet.sql index ecae68f6e9..46a49006cf 100644 --- a/src/test/regress/sql/inet.sql +++ b/src/test/regress/sql/inet.sql @@ -7,7 +7,7 @@ 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'); @@ -24,10 +24,10 @@ INSERT INTO INET_TBL (c, i) VALUES ('10:23::f1', '10:23::f1/64'); 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; -- 2.40.0