Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8a65780

Browse files
committed
Update CIDR regresion tests to test for network masks inside the last
byte being tested, to catch any future breakage.
1 parent7ca3a0f commit8a65780

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

‎src/test/regress/expected/inet.out

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DROP TABLE INET_TBL;
66
ERROR: table "inet_tbl" does not exist
77
CREATE TABLE INET_TBL (c cidr, i inet);
88
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.226/24');
9-
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/24', '192.168.1.226');
9+
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/26', '192.168.1.226');
1010
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/24');
1111
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/25');
1212
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');
2323
INSERT INTO INET_TBL (c, i) VALUES ('10:23::8000/113', '10:23::ffff');
2424
INSERT INTO INET_TBL (c, i) VALUES ('::ffff:1.2.3.4', '::4.3.2.1/24');
2525
-- check that CIDR rejects invalid input:
26-
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/24', '192.168.1.226');
27-
ERROR: invalid cidr value: "192.168.1.2/24"
26+
INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/30', '192.168.1.226');
27+
ERROR: invalid cidr value: "192.168.1.2/30"
2828
DETAIL: Value has bits set to right of mask.
2929
INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1.2.3.4');
3030
ERROR: invalid input syntax for type cidr: "1234::1234::1234"
3131
-- check that CIDR rejects invalid input when converting from text:
32-
INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/24'), '192.168.1.226');
33-
ERROR: invalid cidr value: "192.168.1.2/24"
32+
INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/30'), '192.168.1.226');
33+
ERROR: invalid cidr value: "192.168.1.2/30"
3434
DETAIL: Value has bits set to right of mask.
3535
INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226');
3636
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;
3939
ten | cidr | inet
4040
-----+--------------------+------------------
4141
| 192.168.1.0/24 | 192.168.1.226/24
42-
| 192.168.1.0/24 | 192.168.1.226
42+
| 192.168.1.0/26 | 192.168.1.226
4343
| 192.168.1.0/24 | 192.168.1.0/24
4444
| 192.168.1.0/24 | 192.168.1.0/25
4545
| 192.168.1.0/24 | 192.168.1.255/24
@@ -85,7 +85,7 @@ SELECT '' AS ten, c AS cidr, broadcast(c),
8585
ten | cidr | broadcast | inet | broadcast
8686
-----+--------------------+------------------+------------------+---------------------------------------
8787
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.226/24 | 192.168.1.255/24
88-
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.226 | 192.168.1.226
88+
| 192.168.1.0/26 | 192.168.1.63/26 | 192.168.1.226 | 192.168.1.226
8989
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.0/24 | 192.168.1.255/24
9090
| 192.168.1.0/24 | 192.168.1.255/24 | 192.168.1.0/25 | 192.168.1.127/25
9191
| 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)",
108108
ten | cidr | network(cidr) | inet | network(inet)
109109
-----+--------------------+--------------------+------------------+------------------
110110
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.226/24 | 192.168.1.0/24
111-
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.226 | 192.168.1.226/32
111+
| 192.168.1.0/26 | 192.168.1.0/26 | 192.168.1.226 | 192.168.1.226/32
112112
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/24
113113
| 192.168.1.0/24 | 192.168.1.0/24 | 192.168.1.0/25 | 192.168.1.0/25
114114
| 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)",
131131
ten | cidr | masklen(cidr) | inet | masklen(inet)
132132
-----+--------------------+---------------+------------------+---------------
133133
| 192.168.1.0/24 | 24 | 192.168.1.226/24 | 24
134-
| 192.168.1.0/24 |24 | 192.168.1.226 | 32
134+
| 192.168.1.0/26 |26 | 192.168.1.226 | 32
135135
| 192.168.1.0/24 | 24 | 192.168.1.0/24 | 24
136136
| 192.168.1.0/24 | 24 | 192.168.1.0/25 | 25
137137
| 192.168.1.0/24 | 24 | 192.168.1.255/24 | 24
@@ -177,7 +177,7 @@ SELECT '' AS ten, i, c,
177177
ten | i | c | lt | le | eq | ge | gt | ne | sb | sbe | sup | spe
178178
-----+------------------+--------------------+----+----+----+----+----+----+----+-----+-----+-----
179179
| 192.168.1.226/24 | 192.168.1.0/24 | f | f | f | t | t | t | f | t | f | t
180-
| 192.168.1.226 | 192.168.1.0/24 | f | f | f | t | t | t |t |t | f | f
180+
| 192.168.1.226 | 192.168.1.0/26 | f | f | f | t | t | t |f |f | f | f
181181
| 192.168.1.0/24 | 192.168.1.0/24 | f | t | t | t | f | f | f | t | f | t
182182
| 192.168.1.0/25 | 192.168.1.0/24 | f | f | f | t | t | t | t | t | f | f
183183
| 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;
226226
----------------+------------------
227227
192.168.1.0/24 | 192.168.1.0/25
228228
192.168.1.0/24 | 192.168.1.255/25
229-
192.168.1.0/24 | 192.168.1.226
229+
192.168.1.0/26 | 192.168.1.226
230230
(3 rows)
231231

232232
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;
237237
192.168.1.0/24 | 192.168.1.255/24
238238
192.168.1.0/24 | 192.168.1.0/25
239239
192.168.1.0/24 | 192.168.1.255/25
240-
192.168.1.0/24 | 192.168.1.226
240+
192.168.1.0/26 | 192.168.1.226
241241
(6 rows)
242242

243243
SET enable_seqscan TO on;

‎src/test/regress/sql/inet.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
DROPTABLE INET_TBL;
88
CREATETABLEINET_TBL (ccidr, iinet);
99
INSERT INTO INET_TBL (c, i)VALUES ('192.168.1','192.168.1.226/24');
10-
INSERT INTO INET_TBL (c, i)VALUES ('192.168.1.0/24','192.168.1.226');
10+
INSERT INTO INET_TBL (c, i)VALUES ('192.168.1.0/26','192.168.1.226');
1111
INSERT INTO INET_TBL (c, i)VALUES ('192.168.1','192.168.1.0/24');
1212
INSERT INTO INET_TBL (c, i)VALUES ('192.168.1','192.168.1.0/25');
1313
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');
2424
INSERT INTO INET_TBL (c, i)VALUES ('10:23::8000/113','10:23::ffff');
2525
INSERT INTO INET_TBL (c, i)VALUES ('::ffff:1.2.3.4','::4.3.2.1/24');
2626
-- check that CIDR rejects invalid input:
27-
INSERT INTO INET_TBL (c, i)VALUES ('192.168.1.2/24','192.168.1.226');
27+
INSERT INTO INET_TBL (c, i)VALUES ('192.168.1.2/30','192.168.1.226');
2828
INSERT INTO INET_TBL (c, i)VALUES ('1234::1234::1234','::1.2.3.4');
2929
-- check that CIDR rejects invalid input when converting from text:
30-
INSERT INTO INET_TBL (c, i)VALUES (cidr('192.168.1.2/24'),'192.168.1.226');
30+
INSERT INTO INET_TBL (c, i)VALUES (cidr('192.168.1.2/30'),'192.168.1.226');
3131
INSERT INTO INET_TBL (c, i)VALUES (cidr('ffff:ffff:ffff:ffff::/24'),'::192.168.1.226');
3232
SELECT''AS ten, cAScidr, iASinetFROM INET_TBL;
3333

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp