1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
|
From pgsql-hackers-owner+M4219@hub.org Tue Jul 4 20:10:16 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id UAA13204
for <pgman@candle.pha.pa.us>; Tue, 4 Jul 2000 20:10:15 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e650A8S29252;
Tue, 4 Jul 2000 20:10:08 -0400 (EDT)
Received: from merganser.its.uu.se (merganser.its.uu.se [130.238.6.236])
by hub.org (8.10.1/8.10.1) with ESMTP id e6505pS14530
for <pgsql-hackers@postgresql.org>; Tue, 4 Jul 2000 20:05:52 -0400 (EDT)
Received: from regulus.student.UU.SE ([130.238.5.2]:37402 "EHLO
regulus.its.uu.se") by merganser.its.uu.se with ESMTP
id <S176281AbQGEAFU>; Wed, 5 Jul 2000 02:05:20 +0200
Received: from peter (helo=localhost)
by regulus.its.uu.se with local-esmtp (Exim 3.02 #2)
id 139cnr-0003QO-00
for pgsql-hackers@postgresql.org; Wed, 05 Jul 2000 02:12:35 +0200
Date: Wed, 5 Jul 2000 02:12:35 +0200 (CEST)
From: Peter Eisentraut <peter_e@gmx.net>
To: PostgreSQL Development <pgsql-hackers@postgresql.org>
Subject: [HACKERS] Repair plan for inet and cidr types
Message-ID: <Pine.LNX.4.21.0007050118110.3542-100000@localhost.localdomain>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
As we know, the inet and cidr types are still broken in several ways,
amongst others input and output functions, operators, ordering. I've
collected the bug reports from the last year or so from the archives.
There's apparently a lack of understanding of what exactly are these types
are supposed to do. Therefore, instead of addressing each bug
individually, let me first state what I reconstructed as the specification
of these types, and then add what is currently wrong with it.
* CIDR
The cidr type stores the identity of an IP _network_. A network
specification is of the form 'x.x.x.x/y'. The documentation states that if
y is omitted then it is constructed from the old A, B, C class scheme. So
be it. In a real world network, the bits (y+1)...32 have to be zero, but
the cidr type does not currently enforce this. This has been the source of
bugs in the past, and no doubt the source of some confusion as well. I
propose that cidr _reject_ input of the form '127.0.0.5/16'. If you think
about it, this is the same as int4 rejecting 3.5 as input.
* INET
The inet type stores the identity of an IP _host_. A host specification is
of the form 'x.x.x.x'. Optionally, the inet type also stores the identity
of the network the host is in. E.g., '127.0.0.5/16' means the host
127.0.0.5 in the network 127.0/16.
* Type equivalency
This has also been a source of problems. I propose that cidr and inet are
not made equivalent types at any level. No automatic casting either. A
network and a host are not the same thing. To construct a cidr value from
an inet value, you'd have to use some sort of (to be created) network()
function, e.g., network('127.0.0.5/16') => '127.0/16'. IMO, there is no
reasonable way to construct an inet value from a cidr value.
* Operators
Because the types are equivalent, the operators have also been bunched
together in confusing ways. I propose that ordering operators (>, +, <)
between inet and cidr be eliminated, they do not make sense. The only
useful operation between cidr and inet is the << ("contains") operator.
Ordering withing cidr and inet be defined in terms of their bit
representation, as is the case now. The << family of operators should also
be removed for the inet type -- a host cannot "contain" another host. What
you probably wanted is `inet1 << network(inet2)'.
Does anyone see this differently? If not, can we agree on this
specification?
--
Peter Eisentraut Sernanders väg 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
From pgsql-hackers-owner+M4230@hub.org Tue Jul 4 22:13:37 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id WAA13773
for <pgman@candle.pha.pa.us>; Tue, 4 Jul 2000 22:13:37 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e652DSS19722;
Tue, 4 Jul 2000 22:13:28 -0400 (EDT)
Received: from druid.net (root@druid.net [216.126.72.98])
by hub.org (8.10.1/8.10.1) with ESMTP id e652D9S19504
for <pgsql-hackers@postgresql.org>; Tue, 4 Jul 2000 22:13:09 -0400 (EDT)
Received: from localhost (4223 bytes) by druid.net
via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp
(sender: <darcy>) (ident <darcy> using unix)
id <m139egU-000AXpC@druid.net>
for <pgsql-hackers@postgresql.org>; Tue, 4 Jul 2000 22:13:06 -0400 (EDT)
(Smail-3.2.0.109 1999-Oct-27 #3 built 2000-Jun-28)
Message-Id: <m139egU-000AXpC@druid.net>
From: darcy@druid.net (D'Arcy J.M. Cain)
Subject: Re: [HACKERS] Repair plan for inet and cidr types
In-Reply-To: <Pine.LNX.4.21.0007050118110.3542-100000@localhost.localdomain>
"from Peter Eisentraut at Jul 5, 2000 02:12:35 am"
To: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 4 Jul 2000 22:13:06 -0400 (EDT)
CC: PostgreSQL Development <pgsql-hackers@postgresql.org>
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Thus spake Peter Eisentraut
> There's apparently a lack of understanding of what exactly are these types
> are supposed to do. Therefore, instead of addressing each bug
> individually, let me first state what I reconstructed as the specification
> of these types, and then add what is currently wrong with it.
I have been browsing through the old messages on the topic. There was, in
fact some very good work defining the type before anyone actually started
to code. There was a surprising amount of controversy over the actual
definitions but I think in the end we hammered it out at least to the
point that everyone could work with it.
> * CIDR
>
> The cidr type stores the identity of an IP _network_. A network
> specification is of the form 'x.x.x.x/y'. The documentation states that if
> y is omitted then it is constructed from the old A, B, C class scheme. So
> be it. In a real world network, the bits (y+1)...32 have to be zero, but
> the cidr type does not currently enforce this. This has been the source of
> bugs in the past, and no doubt the source of some confusion as well. I
> propose that cidr _reject_ input of the form '127.0.0.5/16'. If you think
> about it, this is the same as int4 rejecting 3.5 as input.
There is also the option of accepting it but masking out the host bits
before storing it. That gives us automatic conversion if we store an
inet into a cidr if our intent is to store the network part.
What sort of bugs do you think it caused btw?
> * INET
>
> The inet type stores the identity of an IP _host_. A host specification is
> of the form 'x.x.x.x'. Optionally, the inet type also stores the identity
> of the network the host is in. E.g., '127.0.0.5/16' means the host
> 127.0.0.5 in the network 127.0/16.
That sounds right. We also allowed for hosts to be stored implicitely by
simply making the netmask /32.
> * Type equivalency
>
> This has also been a source of problems. I propose that cidr and inet are
> not made equivalent types at any level. No automatic casting either. A
> network and a host are not the same thing. To construct a cidr value from
> an inet value, you'd have to use some sort of (to be created) network()
> function, e.g., network('127.0.0.5/16') => '127.0/16'. IMO, there is no
> reasonable way to construct an inet value from a cidr value.
I'm not sure I understand why this is necessary. I can see not allowing
cidr ==> inet conversions but inet ==> cidr can be done as it is a matter
of dropping information - the host part.
> * Operators
>
> Because the types are equivalent, the operators have also been bunched
> together in confusing ways. I propose that ordering operators (>, +, <)
> between inet and cidr be eliminated, they do not make sense. The only
> useful operation between cidr and inet is the << ("contains") operator.
> Ordering withing cidr and inet be defined in terms of their bit
> representation, as is the case now. The << family of operators should also
> be removed for the inet type -- a host cannot "contain" another host. What
> you probably wanted is `inet1 << network(inet2)'.
Then let's define that as the meaning of "inet1 << inet2" i.e. define
the << operator between inet types as meaning "tell me if inet1 is in
the same network as inet2." In fact, if we define << as only allowed
between inet and cidr (or cidr and cidr?) then the implied cast will
deal with it if that cast causes the host bits to drop as suggested
above.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M4232@hub.org Tue Jul 4 22:20:30 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id WAA13808
for <pgman@candle.pha.pa.us>; Tue, 4 Jul 2000 22:20:29 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e652KDS33988;
Tue, 4 Jul 2000 22:20:13 -0400 (EDT)
Received: from druid.net (root@druid.net [216.126.72.98])
by hub.org (8.10.1/8.10.1) with ESMTP id e652JuS33839
for <pgsql-hackers@postgresql.org>; Tue, 4 Jul 2000 22:19:57 -0400 (EDT)
Received: from localhost (1460 bytes) by druid.net
via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp
(sender: <darcy>) (ident <darcy> using unix)
id <m139emz-000AXrC@druid.net>
for <pgsql-hackers@postgresql.org>; Tue, 4 Jul 2000 22:19:49 -0400 (EDT)
(Smail-3.2.0.109 1999-Oct-27 #3 built 2000-Jun-28)
Message-Id: <m139emz-000AXrC@druid.net>
From: darcy@druid.net (D'Arcy J.M. Cain)
Subject: Re: [HACKERS] Repair plan for inet and cidr types
In-Reply-To: <Pine.LNX.4.21.0007050118110.3542-100000@localhost.localdomain>
"from Peter Eisentraut at Jul 5, 2000 02:12:35 am"
To: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 4 Jul 2000 22:19:49 -0400 (EDT)
CC: PostgreSQL Development <pgsql-hackers@postgresql.org>
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Thus spake Peter Eisentraut
> network and a host are not the same thing. To construct a cidr value from
> an inet value, you'd have to use some sort of (to be created) network()
> function, e.g., network('127.0.0.5/16') => '127.0/16'. IMO, there is no
Oh, I forgot to mention:
darcy=> select network('127.1.2.3/24'::inet);
network
----------
127.1.2/24
(1 row)
There is also a host and netmask function and note:
darcy=> select host('127.1.2.3/24'::cidr);
ERROR: CIDR type has no host part
But I still see no reason why that can't be implicit if we assign the
"'127.1.2.3/24'::inet" value to a cidr. In other words let "select
('127.1.2.3/24'::inet)::cidr" give the same output.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M4234@hub.org Tue Jul 4 22:31:46 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id WAA13855
for <pgman@candle.pha.pa.us>; Tue, 4 Jul 2000 22:31:46 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e652VdS74063;
Tue, 4 Jul 2000 22:31:39 -0400 (EDT)
Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2])
by hub.org (8.10.1/8.10.1) with ESMTP id e652VSS73985
for <pgsql-hackers@postgresql.org>; Tue, 4 Jul 2000 22:31:28 -0400 (EDT)
Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1])
by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id WAA29694;
Tue, 4 Jul 2000 22:31:26 -0400 (EDT)
To: Peter Eisentraut <peter_e@gmx.net>
cc: PostgreSQL Development <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] Repair plan for inet and cidr types
In-reply-to: <Pine.LNX.4.21.0007050118110.3542-100000@localhost.localdomain>
References: <Pine.LNX.4.21.0007050118110.3542-100000@localhost.localdomain>
Comments: In-reply-to Peter Eisentraut <peter_e@gmx.net>
message dated "Wed, 05 Jul 2000 02:12:35 +0200"
Date: Tue, 04 Jul 2000 22:31:25 -0400
Message-ID: <29691.962764285@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Peter Eisentraut <peter_e@gmx.net> writes:
> There's apparently a lack of understanding of what exactly are these types
> are supposed to do. Therefore, instead of addressing each bug
> individually, let me first state what I reconstructed as the specification
> of these types, and then add what is currently wrong with it.
This sounds good offhand, but then I never paid a whole lot of attention
to the details originally. Did you go through the original inet/cidr
design discussions (the threads where Paul Vixie was participating)?
I don't believe Paul is subscribed here anymore, but I'd feel a lot
happier if you can contact him and get him to sign off on the clarified
design. Maybe this is what he had in mind all along, or maybe not.
regards, tom lane
PS: You do know who Paul Vixie is, I assume ;-). I can think of few
better-qualified experts in this domain...
From pgsql-hackers-owner+M4312@hub.org Wed Jul 5 10:48:17 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id KAA02483
for <pgman@candle.pha.pa.us>; Wed, 5 Jul 2000 10:48:16 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e65EllS08607;
Wed, 5 Jul 2000 10:47:47 -0400 (EDT)
Received: from elektron.elka.pw.edu.pl (root@elektron.elka.pw.edu.pl [148.81.63.249])
by hub.org (8.10.1/8.10.1) with ESMTP id e65CiPS89307
for <pgsql-hackers@PostgreSQL.org>; Wed, 5 Jul 2000 08:44:55 -0400 (EDT)
Received: from elektron.elka.pw.edu.pl ([148.81.63.249]:41059 "EHLO
elektron.elka.pw.edu.pl") by elektron.elka.pw.edu.pl with ESMTP
id <S225388AbQGEMoB>; Wed, 5 Jul 2000 14:44:01 +0200
Date: Wed, 5 Jul 2000 14:43:49 +0200 (MET DST)
From: Jakub Bartosz Bielecki <J.B.Bielecki@elka.pw.edu.pl>
To: Sevo Stille <sevo@ip23.net>
cc: Jakub Bartosz Bielecki <J.B.Bielecki@elka.pw.edu.pl>,
pgsql-hackers@PostgreSQL.org
Subject: Re: [HACKERS] Re: postgres - development of inet/cidr
In-Reply-To: <3960A5FE.E626BAE1@ip23.net>
Message-ID: <Pine.SOL.4.21.0007051410330.1267-100000@elektron.elka.pw.edu.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
On Mon, 3 Jul 2000, Sevo Stille wrote:
>
> This would be proper behaviour for the cidr datatype, which describes a
> network. "select '10.0.0.1/27'::cidr='10.0.0.2/27'::cidr;" has to return
> true, as both define the same network, the mask putting the 1 vs. 2
> outside the comparison scope.
>
> On inet, I consider the above broken - going by the documentation,
> having a netmask on a inet datatype does not define a network address
> but rather supplies additional information on the cidr network the host
> as specified by the address is in. Accordingly, it should only truncate
> if the comparison casts to cidr.
OK. After some inspection in list's archives I found the following
statement (http://www.postgresql.org/mhonarc/pgsql-hackers/1998-07):
> It does not work that way. /24 is
> not a shorthand for specifying a netmask -- in CIDR, it's a "prefix
> length".
> That means "192.7.34.21/24" is either (a) a syntax error or
> (b) equivilent to "192.7.34/24".
Everybody seemed to agree with the above opinion at that time.
This is obviously _not_ the way that CIDR is handled at this moment.
"select '1.2.3.4/24'" returns "1.2.3/24" only because the _output_ routine
silently cuts host bits. Input routine stores it exactly as '1.2.3.4/24'.
Since IMHO it's wrong I prepared a patch (I'm sending it to pgsql-patch).
It fixes the CIDR input routine to zero host bits (ie beyond-prefix bits).
Please note that I didn't change the INET input routine.
Eventually I had to change a bit comparison functions.
To this moment they worked in a CIDR way (didn't compare host bits at all)
although they were used by both INET and CIDR.
Since CIDR is zero-padded now, whole 32 bits are compared by > = <
operators.
Subnet operators <<, >> are still the same, don't compare host bits.
> The big question is whether comparisons that only work on a cidr data
> type (contains/contained) or have a cidr type on one side can safely
> cast the inet type to cidr implicitly. For:
> "select '10.0.0.1/27'::inet = '10.0.0.2/27'::inet;" FALSE
> "select '10.0.0.1/27'::cidr = '10.0.0.2/27'::cidr;" TRUE
> "select '10.0.0.1/27'::cidr = '10.0.0.2/27'::inet;" FALSE
> "select '10.0.0.1/27'::cidr >> '10.0.0.2/27'::inet;" TRUE
OK.
> "select '10.0.0.1/27'::cidr << '10.0.0.2/27'::inet;" ERROR
Currently it's not an error... There is no way (and no reason) to
distinguish between INET and CIDR. Above example is exactly
equivalent to:
select '10.0.0.0/27'::inet << '10.0.0.2/27'::inet; -- FALSE
but:
select '10.0.0.0/27'::inet <<= '10.0.0.2/27'::inet; -- TRUE
> But we need to reach an agreement on the proper
> behaviour on greater/smaller comparisons. Should:
>
> "select '10.0.0.1/27'::inet > '10.0.0.2/27'::cidr;"
>
> be true or false? Casting to cidr prior to comparison would make it
> equivalent to "select '10.0.0.0/27'::cidr > '10.0.0.0/27'::cidr;", which
> is false, both networks being equal.
It should be (and is!) true... Since second argument is
really '10.0.0.0/27'.
From pgsql-patches-owner+M284@hub.org Wed Jul 5 09:03:39 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id JAA27744
for <pgman@candle.pha.pa.us>; Wed, 5 Jul 2000 09:03:38 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e65D3OS38516;
Wed, 5 Jul 2000 09:03:24 -0400 (EDT)
Received: from elektron.elka.pw.edu.pl (root@elektron.elka.pw.edu.pl [148.81.63.249])
by hub.org (8.10.1/8.10.1) with ESMTP id e65Cr5S11483
for <pgsql-patches@postgresql.org>; Wed, 5 Jul 2000 08:53:06 -0400 (EDT)
Received: from elektron.elka.pw.edu.pl ([148.81.63.249]:42221 "EHLO
elektron.elka.pw.edu.pl") by elektron.elka.pw.edu.pl with ESMTP
id <S225089AbQGEMwn>; Wed, 5 Jul 2000 14:52:43 +0200
Date: Wed, 5 Jul 2000 14:52:33 +0200 (MET DST)
From: Jakub Bartosz Bielecki <J.B.Bielecki@elka.pw.edu.pl>
To: pgsql-patches@postgresql.org
Subject: [PATCHES] Re: [HACKERS] Re: postgres - development of inet/cidr
Message-ID: <Pine.SOL.4.21.0007051446090.1267-200000@elektron.elka.pw.edu.pl>
MIME-Version: 1.0
Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-959030623-962801553=:1267"
X-Mailing-List: pgsql-patches@postgresql.org
Precedence: bulk
Sender: pgsql-patches-owner@hub.org
Status: OR
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---559023410-959030623-962801553=:1267
Content-Type: TEXT/PLAIN; charset=US-ASCII
1. Fixed obvious bug with strcpy() called on text type in network.c
2. Fixed CIDR input routine to cut 'host' bits in inet_net_pton.c
3. Changed network_{lt,gt,eq} to compare all bits of INET/CIDR in network.c
Jakub
---559023410-959030623-962801553=:1267
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=inet-patch
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SOL.4.21.0007051452330.1267@elektron.elka.pw.edu.pl>
Content-Description: inet-patch
Content-Disposition: attachment; filename=inet-patch
KioqIC4vYmFja2VuZC91dGlscy9hZHQvaW5ldF9uZXRfcHRvbi5jLm9yaWcJ
VHVlIEp1bCAgNCAyMzowMDowNiAyMDAwDQotLS0gLi9iYWNrZW5kL3V0aWxz
L2FkdC9pbmV0X25ldF9wdG9uLmMJV2VkIEp1bCAgNSAxMToxMTozMiAyMDAw
DQoqKioqKioqKioqKioqKioNCioqKiAxMDEsMTA3ICoqKioNCiAgCQkJCXRt
cCwNCiAgCQkJCWRpcnR5LA0KICAJCQkJYml0czsNCiEgCWNvbnN0IHVfY2hh
ciAqb2RzdCA9IGRzdDsNCiAgDQogIAljaCA9ICpzcmMrKzsNCiAgCWlmIChj
aCA9PSAnMCcgJiYgKHNyY1swXSA9PSAneCcgfHwgc3JjWzBdID09ICdYJykN
Ci0tLSAxMDEsMTA3IC0tLS0NCiAgCQkJCXRtcCwNCiAgCQkJCWRpcnR5LA0K
ICAJCQkJYml0czsNCiEgCXVfY2hhciAqb2RzdCA9IGRzdDsNCiAgDQogIAlj
aCA9ICpzcmM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B1bnNpZ25lZCBpbnQgYTIsIGludCBiaXRzKQ0K
---559023410-959030623-962801553=:1267--
From pgsql-hackers-owner+M4284@hub.org Wed Jul 5 09:04:09 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id JAA27751
for <pgman@candle.pha.pa.us>; Wed, 5 Jul 2000 09:04:08 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e65D44S42069;
Wed, 5 Jul 2000 09:04:04 -0400 (EDT)
Received: from turing.csis.gvsu.edu (IDENT:qmailr@csis.gvsu.edu [148.61.162.182])
by hub.org (8.10.1/8.10.1) with SMTP id e65D2HS35607
for <pgsql-hackers@postgresql.org>; Wed, 5 Jul 2000 09:02:17 -0400 (EDT)
Received: (qmail 4436 invoked by uid 0); 5 Jul 2000 13:02:17 -0000
Received: from eos05.csis.gvsu.edu (eisentrp@148.61.162.105)
by turing.csis.gvsu.edu with QMQP; 5 Jul 2000 13:02:17 -0000
From: eisentrp@csis.gvsu.edu
Date: Wed, 5 Jul 2000 09:02:17 -0400 (EDT)
Reply-To: Peter Eisentraut <peter_e@gmx.net>
To: "D'Arcy J.M. Cain" <darcy@druid.net>
cc: PostgreSQL Development <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] Repair plan for inet and cidr types
In-Reply-To: <m139egU-000AXpC@druid.net>
Message-ID: <Pine.LNX.4.21.0007050842080.10677-100000@eos05.csis.gvsu.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
On Tue, 4 Jul 2000, D'Arcy J.M. Cain wrote:
> I'm not sure I understand why this is necessary. I can see not allowing
> cidr ==> inet conversions but inet ==> cidr can be done as it is a matter
> of dropping information - the host part.
Automatic casts should not lose information. How would you feel if floats
were automatically rounded when you store them into int fields? I think
this is an important principle in any type system.
> Then let's define that as the meaning of "inet1 << inet2" i.e. define
> the << operator between inet types as meaning "tell me if inet1 is in
> the same network as inet2."
Again, let the user say what he wants: inet1 << network(inet2).
Also note that "is inet1 in the same network as inet2" is different from
"is inet1 contained in the network of inet2" (which is what it does now).
The operator you defined is symmetric (if inet1 is in the same network as
inet2, then inet2 is also in the same network as inet1), whereas the << is
antisymmetric. In fact, AFAICT, the operator you defined doesn't exist
yet, although it perhaps should.
--
Peter Eisentraut Sernanders vaeg 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
From pgsql-hackers-owner+M4293@hub.org Wed Jul 5 09:50:15 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id JAA28183
for <pgman@candle.pha.pa.us>; Wed, 5 Jul 2000 09:50:14 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e65Do1S55862;
Wed, 5 Jul 2000 09:50:01 -0400 (EDT)
Received: from andie.ip23.net (andie.ip23.net [212.83.32.23])
by hub.org (8.10.1/8.10.1) with ESMTP id e65DmGS51928
for <pgsql-hackers@PostgreSQL.org>; Wed, 5 Jul 2000 09:48:16 -0400 (EDT)
Received: from imap1.ip23.net (imap1.ip23.net [212.83.32.35])
by andie.ip23.net (8.9.3/8.9.3) with ESMTP id PAA33008;
Wed, 5 Jul 2000 15:48:10 +0200 (CEST)
Received: from ip23.net (spc.ip23.net [212.83.32.122])
by imap1.ip23.net (8.9.3/8.9.3) with ESMTP id QAA00989;
Wed, 5 Jul 2000 16:01:01 +0200 (CEST)
Message-ID: <39633C99.DD58D11F@ip23.net>
Date: Wed, 05 Jul 2000 15:48:09 +0200
From: Sevo Stille <sevo@ip23.net>
Organization: IP23
X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.10 i686)
X-Accept-Language: en, de
MIME-Version: 1.0
To: Jakub Bartosz Bielecki <J.B.Bielecki@elka.pw.edu.pl>
CC: pgsql-hackers@PostgreSQL.org
Subject: Re: [HACKERS] Re: postgres - development of inet/cidr
References: <Pine.SOL.4.21.0007051410330.1267-100000@elektron.elka.pw.edu.pl>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Jakub Bartosz Bielecki wrote:
> > "select '10.0.0.1/27'::cidr << '10.0.0.2/27'::inet;" ERROR
>
> Currently it's not an error... There is no way (and no reason) to
> distinguish between INET and CIDR.
Yes, there is. CIDR is defined as the network 10.0.0.1 & /27, while INET
is defined as host 10.0.0.1 within network 10.0.0.1 & /27. You can do
almost every network and host calculation both in CIDR and INET, but
you need implicit knowledge for it. Two columns are necessary to define
a host and its network in CIDR, and a network cannot be specified
without a host using INET - except for ugly in-band hacks like using
10.0.0.0/27 for the network which would prevent you from specifying a
base address.
> Above example is exactly
> equivalent to:
> select '10.0.0.0/27'::inet << '10.0.0.2/27'::inet; -- FALSE
Nope. If the right hand side is automatically propagated to a network,
it is true. If not, the above IMHO should better raise an error, as a
host can never contain a host.
> but:
> select '10.0.0.0/27'::inet <<= '10.0.0.2/27'::inet; -- TRUE
Well, you might argue that a host could contain-or-equal a host, but as
only the equals part could ever be true, that is a redundant operator
without any meaning beyond equals, and accordingly it should not be
valid for that case.
> > But we need to reach an agreement on the proper
> > behaviour on greater/smaller comparisons. Should:
> >
> > "select '10.0.0.1/27'::inet > '10.0.0.2/27'::cidr;"
> >
> > be true or false? Casting to cidr prior to comparison would make it
> > equivalent to "select '10.0.0.0/27'::cidr > '10.0.0.0/27'::cidr;", which
> > is false, both networks being equal.
>
> It should be (and is!) true... Since second argument is
> really '10.0.0.0/27'.
Yes, but that does not make it any truer. CIDR 10.0.0.0/27 is
definitively not 10.0.0.0 but [10.0.0.0 .. 10.0.0.31]. A CIDR address is
never synonymous to a plain host address. You'll see the problem if you
try to calculate the inverse - any zeroed CIDR address in the entire
range from 10.0/8 to 10.0.0.0/32 would mask to 10.0.0.0. Accordingly,
there is no simple answer to a "host bigger/smaller than network"
question. For many applications, it may be useful to define that to mean
that the host is smaller than the network bottom address respectively
bigger than the top address, but any of the other possible views would
be perfectly legal as well.
Sevo
--
sevo@ip23.net
From pgsql-hackers-owner+M4354@hub.org Wed Jul 5 16:49:21 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id QAA17585
for <pgman@candle.pha.pa.us>; Wed, 5 Jul 2000 16:49:20 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e65KmdS82556;
Wed, 5 Jul 2000 16:48:39 -0400 (EDT)
Received: from druid.net (root@druid.net [216.126.72.98])
by hub.org (8.10.1/8.10.1) with ESMTP id e65KkqS77601
for <pgsql-hackers@postgresql.org>; Wed, 5 Jul 2000 16:46:52 -0400 (EDT)
Received: from localhost (2500 bytes) by druid.net
via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp
(sender: <darcy>) (ident <darcy> using unix)
id <m139w4G-000AXpC@druid.net>
for <pgsql-hackers@postgresql.org>; Wed, 5 Jul 2000 16:46:48 -0400 (EDT)
(Smail-3.2.0.109 1999-Oct-27 #3 built 2000-Jun-28)
Message-Id: <m139w4G-000AXpC@druid.net>
From: darcy@druid.net (D'Arcy J.M. Cain)
Subject: Re: [HACKERS] Repair plan for inet and cidr types
In-Reply-To: <Pine.LNX.4.21.0007050842080.10677-100000@eos05.csis.gvsu.edu>
"from eisentrp@csis.gvsu.edu at Jul 5, 2000 09:02:17 am"
To: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 5 Jul 2000 16:46:48 -0400 (EDT)
CC: PostgreSQL Development <pgsql-hackers@postgresql.org>
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Thus spake eisentrp@csis.gvsu.edu
> On Tue, 4 Jul 2000, D'Arcy J.M. Cain wrote:
> > I'm not sure I understand why this is necessary. I can see not allowing
> > cidr ==> inet conversions but inet ==> cidr can be done as it is a matter
> > of dropping information - the host part.
>
> Automatic casts should not lose information. How would you feel if floats
> were automatically rounded when you store them into int fields? I think
> this is an important principle in any type system.
If it was defined well I would have no problem with it.
> > Then let's define that as the meaning of "inet1 << inet2" i.e. define
> > the << operator between inet types as meaning "tell me if inet1 is in
> > the same network as inet2."
>
> Again, let the user say what he wants: inet1 << network(inet2).
I think that's what I meant. I'm just saying that inet::cidr should be
the same as network(inet). Allowing that cast makes a lot of operations
work intuitively.
> Also note that "is inet1 in the same network as inet2" is different from
> "is inet1 contained in the network of inet2" (which is what it does now).
Hmm. It is a subtle difference and I did miss it.
> The operator you defined is symmetric (if inet1 is in the same network as
> inet2, then inet2 is also in the same network as inet1), whereas the << is
> antisymmetric. In fact, AFAICT, the operator you defined doesn't exist
> yet, although it perhaps should.
I guess what I was really getting at was this.
host OP cidr
where inet would cast to host on one side and cidr on the other. What
we have now is
cidr OP cidr
with both sides casting to cidr. Of course there is no such thing as a host
type so I don't know how we would cast such a thing.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M4421@hub.org Thu Jul 6 08:54:47 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id IAA06169
for <pgman@candle.pha.pa.us>; Thu, 6 Jul 2000 08:54:46 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e66CrgS44851;
Thu, 6 Jul 2000 08:53:42 -0400 (EDT)
Received: from elektron.elka.pw.edu.pl (root@elektron.elka.pw.edu.pl [148.81.63.249])
by hub.org (8.10.1/8.10.1) with ESMTP id e66Cr5S44024
for <pgsql-hackers@PostgreSQL.org>; Thu, 6 Jul 2000 08:53:05 -0400 (EDT)
Received: from elektron.elka.pw.edu.pl ([148.81.63.249]:64907 "EHLO
elektron.elka.pw.edu.pl") by elektron.elka.pw.edu.pl with ESMTP
id <S225243AbQGFMw2>; Thu, 6 Jul 2000 14:52:28 +0200
Date: Thu, 6 Jul 2000 14:52:17 +0200 (MET DST)
From: Jakub Bartosz Bielecki <J.B.Bielecki@elka.pw.edu.pl>
To: Sevo Stille <sevo@ip23.net>
cc: Jakub Bartosz Bielecki <J.B.Bielecki@elka.pw.edu.pl>,
pgsql-hackers@PostgreSQL.org
Subject: Re: [HACKERS] Re: postgres - development of inet/cidr
In-Reply-To: <39633C99.DD58D11F@ip23.net>
Message-ID: <Pine.SOL.4.21.0007061354040.20142-100000@elektron.elka.pw.edu.pl>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
On Wed, 5 Jul 2000, Sevo Stille wrote:
>
> > > "select '10.0.0.1/27'::cidr << '10.0.0.2/27'::inet;" ERROR
> >
> > Currently it's not an error... There is no way (and no reason) to
> > distinguish between INET and CIDR.
>
> Yes, there is. CIDR is defined as the network 10.0.0.1 & /27, while INET
> is defined as host 10.0.0.1 within network 10.0.0.1 & /27. You can do
> almost every network and host calculation both in CIDR and INET, but
> you need implicit knowledge for it.
I was talking about *current* implementation of INET/CIDR (which IMHO
is very ill).
There is INET for users that want simply to store IP's and don't care
about all the technical jargon.
There is CIDR for advanced users who want to store network data.
Currently these 2 types are handled by 1 implementation, moreover despite
INET netmask and CIDR prefix-length are something completely different,
both are stored in the same field of inet structure (yuck).
At the moment it works fine. But that's only a hack.
I guess the purpose was to prevent duplication of code... Blah...
> > select '10.0.0.0/27'::inet << '10.0.0.2/27'::inet; -- FALSE
>
> Nope. If the right hand side is automatically propagated to a network,
> it is true. If not, the above IMHO should better raise an error, as a
> host can never contain a host.
>
> > select '10.0.0.0/27'::inet <<= '10.0.0.2/27'::inet; -- TRUE
>
> Well, you might argue that a host could contain-or-equal a host, but as
> only the equals part could ever be true, that is a redundant operator
> without any meaning beyond equals, and accordingly it should not be
> valid for that case.
>
> > > "select '10.0.0.1/27'::inet > '10.0.0.2/27'::cidr;"
> > It should be (and is!) true... Since second argument is
> > really '10.0.0.0/27'.
>
> Yes, but that does not make it any truer. CIDR 10.0.0.0/27 is
> definitively not 10.0.0.0 but [10.0.0.0 .. 10.0.0.31].
Same as above... You are perfectly right.
Everything works until user starts messing with _both_ INET and CIDR
at the same time.
The possible solution is:
- inhibit cidr-to-inet cast (and maybe also inet-to-cidr, because
it would throw away netmask),
- CIDR operators: > = < << >>
- INET operators: > = < (and why not & | if it would be useful???)
functions: cidr network(inet); // '10.0.0.0/27'
text host(inet); // '10.0.0.1'
int masklen(inet); // 27
- write an usable manual.
Comments?
I *might* work on it if I find some spare time. But it's unlikely :(
From pgsql-hackers-owner+M4503@hub.org Fri Jul 7 12:11:37 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id MAA26802
for <pgman@candle.pha.pa.us>; Fri, 7 Jul 2000 12:11:36 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e67GAgW67823;
Fri, 7 Jul 2000 12:10:42 -0400 (EDT)
Received: from merganser.its.uu.se (merganser.its.uu.se [130.238.6.236])
by hub.org (8.10.1/8.10.1) with ESMTP id e67G9qW66262
for <pgsql-hackers@postgresql.org>; Fri, 7 Jul 2000 12:09:52 -0400 (EDT)
Received: from regulus.student.UU.SE ([130.238.5.2]:53522 "EHLO
regulus.its.uu.se") by merganser.its.uu.se with ESMTP
id <S493726AbQGGQJO>; Fri, 7 Jul 2000 18:09:14 +0200
Received: from peter (helo=localhost)
by regulus.its.uu.se with local-esmtp (Exim 3.02 #2)
id 13Aani-0003A6-00; Fri, 07 Jul 2000 18:16:26 +0200
Date: Fri, 7 Jul 2000 18:16:26 +0200 (CEST)
From: Peter Eisentraut <peter_e@gmx.net>
To: "D'Arcy J.M. Cain" <darcy@druid.net>
cc: PostgreSQL Development <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] Repair plan for inet and cidr types
In-Reply-To: <m139w4G-000AXpC@druid.net>
Message-ID: <Pine.LNX.4.21.0007070156410.4191-100000@localhost.localdomain>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
D'Arcy J.M. Cain writes:
> > Automatic casts should not lose information. How would you feel if floats
> > were automatically rounded when you store them into int fields? I think
> > this is an important principle in any type system.
>
> If it was defined well I would have no problem with it.
That is certainly not how type systems operate anywhere.
> I guess what I was really getting at was this.
>
> host OP cidr
>
> where inet would cast to host on one side and cidr on the other. What
> we have now is
>
> cidr OP cidr
>
> with both sides casting to cidr. Of course there is no such thing as a host
> type so I don't know how we would cast such a thing.
I think that while the implicit casting could sometimes be convenient,
it's also a source of confusion. Consider the statement
select '10.0.0.3'::cidr < '10.0.0.2'::inet; => f
This cannot possibly make sense on closer inspection. Firstly, it's
semantic nonsense, you cannot order a network and a host. Secondly, it's
also wrong. According to the documentation, the '10.0.0.3'::cidr should be
converted to '10/8' internally. Then one of two things could have happened
here: 1) cidr was implicitly converted to inet and '10.0.0.3' is taken to
be a host, which is completely wrong. Or 2) inet was converted to cidr.
But then we're looking at '10/8' < '10.0.0.2/32', which should be true.
See also
select '10.0.0.2'::cidr = '10.0.0.2'::inet; => t
which is wrong for similar reasons.
Then let's look at the << family of operators.
select '10.0.0.2'::cidr >> '10.0.0.2'::inet; => f
Again, there are two ways this could currently be resolved:
'10/8'::cidr >> '10.0.0.2/32'::cidr which does return true
or
'10.0.0.2'::inet >> '10.0.0.2'::inet
which doesn't make any sense.
On closer inspection, the inet << cidr case is completely misbehaving:
select '10.0.0.5/8'::inet << '10.0.0.0/16'::cidr; => f
select '10.0.0.5/24'::inet << '10.0.0.0/16'::cidr; => t
This is not what I'd expect.
Concretely, the cases
inet << cidr
cidr << cidr
are not the same:
'10.0.0.5/8'::inet << '10.0.0.0/16'::cidr
should be true
'10.0.0.5/8'::cidr << '10.0.0.0/16'::cidr
should be false, if you allow the left-side value in at all, which I
wouldn't.
What this tells me is that the cast from inet to cidr is not well-defined
in the mathematical sense, and therefore no implicit casting should be
allowed.
So the bottom line here is that these two types are, while from a related
domain, different, and the user should be the one that controls when and
how they are mixed together.
--
Peter Eisentraut Sernanders väg 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
From pgsql-hackers-owner+M5242@hub.org Sun Jul 23 10:01:45 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id KAA21261
for <pgman@candle.pha.pa.us>; Sun, 23 Jul 2000 10:01:44 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6NE1Th91342;
Sun, 23 Jul 2000 10:01:29 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6NE10h91172
for <pgsql-hackers@hub.org>; Sun, 23 Jul 2000 10:01:00 -0400 (EDT)
Received: (from ler@localhost)
by lerami.lerctr.org (8.10.1/8.10.1/20000715) id e6NE0w219946
for pgsql-hackers@hub.org; Sun, 23 Jul 2000 09:00:58 -0500 (CDT)
From: Larry Rosenman <ler@lerctr.org>
Message-Id: <200007231400.e6NE0w219946@lerami.lerctr.org>
Subject: [HACKERS] INET/CIDR types
To: pgsql-hackers@hub.org
Date: Sun, 23 Jul 2000 09:00:57 -0500 (CDT)
X-Mailer: ELM [version 2.4ME+ PL79 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
I noticed a discussion on this list about a re-do of the INET/CIDR
types. I was wondering if there was ANY way at all to add
an output function that ALWAYS returns all 4 octets of an INET or CIDR
type with and without the /netmask?
I'm writing a IP Allocation/Tracking app for the ISP I work for, and
find the current output format causes confusion for the less
technical types.
Larry Rosenman
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 (voice) Internet: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
From pgsql-hackers-owner+M5264@hub.org Mon Jul 24 10:34:39 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id KAA09676
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 10:34:38 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OEXZh83378;
Mon, 24 Jul 2000 10:33:35 -0400 (EDT)
Received: from druid.net (root@druid.net [216.126.72.98])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OEXGh83201
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 10:33:16 -0400 (EDT)
Received: from localhost (1444 bytes) by druid.net
via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp
(sender: <darcy>) (ident <darcy> using unix)
id <m13GjIB-000AXgC@druid.net>
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 10:33:15 -0400 (EDT)
(Smail-3.2.0.109 1999-Oct-27 #3 built 2000-Jun-28)
Message-Id: <m13GjIB-000AXgC@druid.net>
From: darcy@druid.net (D'Arcy J.M. Cain)
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <200007231400.e6NE0w219946@lerami.lerctr.org> "from Larry Rosenman
at Jul 23, 2000 09:00:57 am"
To: Larry Rosenman <ler@lerctr.org>
Date: Mon, 24 Jul 2000 10:33:14 -0400 (EDT)
CC: pgsql-hackers@hub.org
Reply-To: pgsql-hackers@hub.org
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Thus spake Larry Rosenman
> I noticed a discussion on this list about a re-do of the INET/CIDR
> types. I was wondering if there was ANY way at all to add
> an output function that ALWAYS returns all 4 octets of an INET or CIDR
> type with and without the /netmask?
>
> I'm writing a IP Allocation/Tracking app for the ISP I work for, and
> find the current output format causes confusion for the less
> technical types.
The host() function does this for the INET type. It doesn't work for
the CIDR type (it throws an error) because CIDR doesn't have a host
part per se.
darcy=> select '1.2.0.0/23'::inet;
?column?
--------
1.2.0/23
(1 row)
darcy=> select host('1.2.0.0/23'::inet);
host
-------
1.2.0.0
(1 row)
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M5265@hub.org Mon Jul 24 10:43:14 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id KAA09722
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 10:43:13 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OEfLh86364;
Mon, 24 Jul 2000 10:41:21 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OEf6h86190
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 10:41:06 -0400 (EDT)
Received: (from ler@localhost)
by lerami.lerctr.org (8.10.1/8.10.1/20000715) id e6OEf5D12433;
Mon, 24 Jul 2000 09:41:05 -0500 (CDT)
From: Larry Rosenman <ler@lerctr.org>
Message-Id: <200007241441.e6OEf5D12433@lerami.lerctr.org>
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <m13GjIB-000AXgC@druid.net> "from darcy@druid.net at Jul 24, 2000
10:33:14 am"
To: pgsql-hackers@hub.org
Date: Mon, 24 Jul 2000 09:41:05 -0500 (CDT)
CC: Larry Rosenman <ler@lerctr.org>
X-Mailer: ELM [version 2.4ME+ PL79 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
The bad news is that I'm tracking CIDR blocks.
If I could get a network() function to return essentially
host()::inet for CIDR's that would work.
Larry
> Thus spake Larry Rosenman
> > I noticed a discussion on this list about a re-do of the INET/CIDR
> > types. I was wondering if there was ANY way at all to add
> > an output function that ALWAYS returns all 4 octets of an INET or CIDR
> > type with and without the /netmask?
> >
> > I'm writing a IP Allocation/Tracking app for the ISP I work for, and
> > find the current output format causes confusion for the less
> > technical types.
>
> The host() function does this for the INET type. It doesn't work for
> the CIDR type (it throws an error) because CIDR doesn't have a host
> part per se.
>
> darcy=> select '1.2.0.0/23'::inet;
> ?column?
> --------
> 1.2.0/23
> (1 row)
>
> darcy=> select host('1.2.0.0/23'::inet);
> host
> -------
> 1.2.0.0
> (1 row)
>
> --
> D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
> http://www.druid.net/darcy/ | and a sheep voting on
> +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 (voice) Internet: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
From pgsql-hackers-owner+M5270@hub.org Mon Jul 24 15:17:30 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id PAA11467
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 15:17:29 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OJHEh72992;
Mon, 24 Jul 2000 15:17:14 -0400 (EDT)
Received: from druid.net (root@druid.net [216.126.72.98])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OJF3h71969
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 15:15:04 -0400 (EDT)
Received: from localhost (1687 bytes) by druid.net
via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp
(sender: <darcy>) (ident <darcy> using unix)
id <m13Gngs-000AXeC@druid.net>
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 15:15:02 -0400 (EDT)
(Smail-3.2.0.109 1999-Oct-27 #3 built 2000-Jun-28)
Message-Id: <m13Gngs-000AXeC@druid.net>
From: darcy@druid.net (D'Arcy J.M. Cain)
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <200007241441.e6OEf5D12433@lerami.lerctr.org> "from Larry Rosenman
at Jul 24, 2000 09:41:05 am"
To: Larry Rosenman <ler@lerctr.org>
Date: Mon, 24 Jul 2000 15:15:01 -0400 (EDT)
CC: pgsql-hackers@hub.org
Reply-To: pgsql-hackers@hub.org
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Thus spake Larry Rosenman
> The bad news is that I'm tracking CIDR blocks.
Then there is no host part. I would argue that if someone is getting
confused with the current output then perhaps they shouldn't be dealing
with client networks.
> If I could get a network() function to return essentially
> host()::inet for CIDR's that would work.
There is a network function. It returns the network.
darcy=> select network('1.2.0.0/23'::cidr);
network
--------
1.2.0/23
(1 row)
A lot of work went into these types to make them correct. I don't think
we should be undermining that to allow people to work with incorrect
assumptions. If you want Micro$oft you know where to find it.
If you really must do this then store your blocks in the INET type. It
pretty much does what you want but doesn't try to pretend to be a CIDR.
Hmmm. I just noticed this.
darcy=> select '1.2.0.1/23'::cidr;
?column?
--------
1.2.0/23
(1 row)
Shouldn't that throw an error?
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M5271@hub.org Mon Jul 24 15:28:37 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id PAA11521
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 15:28:36 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OJSMh77820;
Mon, 24 Jul 2000 15:28:22 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OJQhh76867
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 15:26:43 -0400 (EDT)
Received: from lerdesk (ler-desk.iadfw.net [206.66.13.18])
by lerami.lerctr.org (8.10.1/8.10.1/20000715) with SMTP id e6OJQcc24312;
Mon, 24 Jul 2000 14:26:38 -0500 (CDT)
From: "Larry Rosenman" <ler@lerctr.org>
To: <pgsql-hackers@hub.org>, "Larry Rosenman" <ler@lerctr.org>
Subject: RE: [HACKERS] INET/CIDR types
Date: Mon, 24 Jul 2000 14:26:37 -0500
Message-ID: <NCBBKBDOOHHEJCJHLLPAMELAHIAA.ler@lerctr.org>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
X-Mimeole: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
In-Reply-To: <m13Gngs-000AXeC@druid.net>
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
The problem is NON-TECHNICAL people will be getting the output,
and they expect 4 octet output.
I really think that we should have a way to coerce a CIDR to
an INET, and then allow host().
Remember that I am dealing with $10/hour clerks.
I really don't get the hostility to changing the OUTPUT format...
Larry Rosenman
-----Original Message-----
From: D'Arcy J.M. Cain [mailto:darcy@druid.net]
Sent: Monday, July 24, 2000 2:15 PM
To: Larry Rosenman
Cc: pgsql-hackers@hub.org
Subject: Re: [HACKERS] INET/CIDR types
Thus spake Larry Rosenman
> The bad news is that I'm tracking CIDR blocks.
Then there is no host part. I would argue that if someone is getting
confused with the current output then perhaps they shouldn't be dealing
with client networks.
> If I could get a network() function to return essentially
> host()::inet for CIDR's that would work.
There is a network function. It returns the network.
darcy=> select network('1.2.0.0/23'::cidr);
network
--------
1.2.0/23
(1 row)
A lot of work went into these types to make them correct. I don't think
we should be undermining that to allow people to work with incorrect
assumptions. If you want Micro$oft you know where to find it.
If you really must do this then store your blocks in the INET type. It
pretty much does what you want but doesn't try to pretend to be a CIDR.
Hmmm. I just noticed this.
darcy=> select '1.2.0.1/23'::cidr;
?column?
--------
1.2.0/23
(1 row)
Shouldn't that throw an error?
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M5272@hub.org Mon Jul 24 15:35:28 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id PAA11554
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 15:35:28 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OJZFh80569;
Mon, 24 Jul 2000 15:35:16 -0400 (EDT)
Received: from smtp.pacifier.com (comet.pacifier.com [199.2.117.155])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OJXgh80113
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 15:33:42 -0400 (EDT)
Received: from desktop (dsl-dhogaza.pacifier.net [207.202.226.68])
by smtp.pacifier.com (8.9.3/8.9.3pop) with SMTP id MAA07579;
Mon, 24 Jul 2000 12:33:32 -0700 (PDT)
Message-Id: <3.0.1.32.20000724123008.01189db0@mail.pacifier.com>
X-Sender: dhogaza@mail.pacifier.com
X-Mailer: Windows Eudora Pro Version 3.0.1 (32)
Date: Mon, 24 Jul 2000 12:30:08 -0700
To: "Larry Rosenman" <ler@lerctr.org>, <pgsql-hackers@hub.org>,
"Larry Rosenman" <ler@lerctr.org>
From: Don Baccus <dhogaza@pacifier.com>
Subject: RE: [HACKERS] INET/CIDR types
In-Reply-To: <NCBBKBDOOHHEJCJHLLPAMELAHIAA.ler@lerctr.org>
References: <m13Gngs-000AXeC@druid.net>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
At 02:26 PM 7/24/00 -0500, Larry Rosenman wrote:
>The problem is NON-TECHNICAL people will be getting the output,
>and they expect 4 octet output.
>
>I really think that we should have a way to coerce a CIDR to
>an INET, and then allow host().
>
>Remember that I am dealing with $10/hour clerks.
>
>I really don't get the hostility to changing the OUTPUT format...
Are these $10/hour clerks typing in SQL to psql? Strange ...
If not, formatting issues like this can easily be broken (or fixed,
according to your POV) by your application client.
- Don Baccus, Portland OR <dhogaza@pacifier.com>
Nature photos, on-line guides, Pacific Northwest
Rare Bird Alert Service and other goodies at
http://donb.photo.net.
From pgsql-hackers-owner+M5273@hub.org Mon Jul 24 15:38:46 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id PAA11571
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 15:38:45 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OJcPh81593;
Mon, 24 Jul 2000 15:38:25 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OJanh80997
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 15:36:49 -0400 (EDT)
Received: from lerdesk (ler-desk.iadfw.net [206.66.13.18])
by lerami.lerctr.org (8.10.1/8.10.1/20000715) with SMTP id e6OJajc24698;
Mon, 24 Jul 2000 14:36:45 -0500 (CDT)
From: "Larry Rosenman" <ler@lerctr.org>
To: "Don Baccus" <dhogaza@pacifier.com>, "Larry Rosenman" <ler@lerctr.org>,
<pgsql-hackers@hub.org>, "Larry Rosenman" <ler@lerctr.org>
Subject: RE: [HACKERS] INET/CIDR types
Date: Mon, 24 Jul 2000 14:36:44 -0500
Message-ID: <NCBBKBDOOHHEJCJHLLPACELCHIAA.ler@lerctr.org>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
X-Mimeole: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
In-Reply-To: <3.0.1.32.20000724123008.01189db0@mail.pacifier.com>
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
I was hoping to have some niceties out of the SQL retrieve to print directly
in PHP, and not have to massage it.
Why is there such animosity to printing out all 4 octets in some function
somewhere for a CIDR block?
Larry
-----Original Message-----
From: Don Baccus [mailto:dhogaza@pacifier.com]
Sent: Monday, July 24, 2000 2:30 PM
To: Larry Rosenman; pgsql-hackers@hub.org; Larry Rosenman
Subject: RE: [HACKERS] INET/CIDR types
At 02:26 PM 7/24/00 -0500, Larry Rosenman wrote:
>The problem is NON-TECHNICAL people will be getting the output,
>and they expect 4 octet output.
>
>I really think that we should have a way to coerce a CIDR to
>an INET, and then allow host().
>
>Remember that I am dealing with $10/hour clerks.
>
>I really don't get the hostility to changing the OUTPUT format...
Are these $10/hour clerks typing in SQL to psql? Strange ...
If not, formatting issues like this can easily be broken (or fixed,
according to your POV) by your application client.
- Don Baccus, Portland OR <dhogaza@pacifier.com>
Nature photos, on-line guides, Pacific Northwest
Rare Bird Alert Service and other goodies at
http://donb.photo.net.
From pgsql-hackers-owner+M5274@hub.org Mon Jul 24 16:19:47 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id QAA11771
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 16:19:46 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OKJRh99659;
Mon, 24 Jul 2000 16:19:28 -0400 (EDT)
Received: from druid.net (root@druid.net [216.126.72.98])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OKHbh98841
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 16:17:37 -0400 (EDT)
Received: from localhost (1546 bytes) by druid.net
via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp
(sender: <darcy>) (ident <darcy> using unix)
id <m13GofQ-000AX1C@druid.net>
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 16:17:36 -0400 (EDT)
(Smail-3.2.0.109 1999-Oct-27 #3 built 2000-Jun-28)
Message-Id: <m13GofQ-000AX1C@druid.net>
From: darcy@druid.net (D'Arcy J.M. Cain)
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <NCBBKBDOOHHEJCJHLLPACELCHIAA.ler@lerctr.org> "from Larry Rosenman
at Jul 24, 2000 02:36:44 pm"
To: Larry Rosenman <ler@lerctr.org>
Date: Mon, 24 Jul 2000 16:17:36 -0400 (EDT)
CC: Don Baccus <dhogaza@pacifier.com>, pgsql-hackers@hub.org
Reply-To: pgsql-hackers@hub.org
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Thus spake Larry Rosenman
> I was hoping to have some niceties out of the SQL retrieve to print directly
> in PHP, and not have to massage it.
>
> Why is there such animosity to printing out all 4 octets in some function
> somewhere for a CIDR block?
You keep saying "hostility" as if we are ganging up against you. Believe
me, I have no animosity towards you and I am sure no one else has either.
We are resisting the change you want simply because it would violate the
RFC which we agreed to follow when we created the types.
If you think this is hostile, you will probably think that the original
discussions in the archives are nuclear war :-). If you would like to
look it over make sure to set aside a lot of time. We spent a long time
hashing this out.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M5275@hub.org Mon Jul 24 16:29:30 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id QAA11819
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 16:29:28 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OKT6h02534;
Mon, 24 Jul 2000 16:29:06 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OKRUh02012
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 16:27:30 -0400 (EDT)
Received: from lerdesk (ler-desk.iadfw.net [206.66.13.18])
by lerami.lerctr.org (8.10.1/8.10.1/20000715) with SMTP id e6OKRPc26861;
Mon, 24 Jul 2000 15:27:25 -0500 (CDT)
From: "Larry Rosenman" <ler@lerctr.org>
To: <pgsql-hackers@hub.org>, "Larry Rosenman" <ler@lerctr.org>
Cc: "Don Baccus" <dhogaza@pacifier.com>
Subject: RE: [HACKERS] INET/CIDR types
Date: Mon, 24 Jul 2000 15:27:24 -0500
Message-ID: <NCBBKBDOOHHEJCJHLLPAAELHHIAA.ler@lerctr.org>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
X-Mimeole: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
In-Reply-To: <m13GofQ-000AX1C@druid.net>
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
What RFC says you can't print all 4 octets of a CIDR Netnumber?
Why does network(cidr) return the whole cidr output just like
select cidr?
I'm just trying to figure out the logic here.
Here is what my Cisco Router that speaks BGP says:
big-bro#term ip netmask-format bit-count
big-bro#sh ip bg 206.66.0.0/20
BGP routing table entry for 206.66.0.0/20, version 150832
Paths: (5 available, best #4)
Advertised to non peer-group peers:
157.130.140.109 166.63.135.33 206.66.12.3 206.66.12.4 206.66.12.7
206.66.12.
8
Local, (aggregated by 4278 206.66.12.3), (received & used)
206.66.12.3 from 206.66.12.3 (206.66.12.3)
Origin IGP, localpref 0, valid, internal, atomic-aggregate
Local, (aggregated by 4278 206.66.12.7), (received & used)
206.66.12.7 from 206.66.12.7 (206.66.12.7)
Origin IGP, localpref 0, valid, internal, atomic-aggregate
Local, (aggregated by 4278 206.66.12.8), (received & used)
206.66.12.8 from 206.66.12.8 (206.66.12.8)
Origin IGP, localpref 0, valid, internal, atomic-aggregate
Local, (aggregated by 4278 206.66.12.1)
0.0.0.0 from 0.0.0.0 (206.66.12.1)
Origin IGP, localpref 100, weight 32768, valid, aggregated, local,
atomic-
aggregate, best
Local, (received & used)
206.66.12.4 from 206.66.12.4 (206.66.12.4)
Origin IGP, metric 0, localpref 100, valid, internal
big-bro#
I am just asking for the same type output.
Why is this so hard?
The info is in the type, and the print routine wouldn't be so hard.
I can probably write the function in less than 1 hour, but getting it
integrated is
my stumbling block.
-----Original Message-----
From: D'Arcy J.M. Cain [mailto:darcy@druid.net]
Sent: Monday, July 24, 2000 3:18 PM
To: Larry Rosenman
Cc: Don Baccus; pgsql-hackers@hub.org
Subject: Re: [HACKERS] INET/CIDR types
Thus spake Larry Rosenman
> I was hoping to have some niceties out of the SQL retrieve to print
directly
> in PHP, and not have to massage it.
>
> Why is there such animosity to printing out all 4 octets in some function
> somewhere for a CIDR block?
You keep saying "hostility" as if we are ganging up against you. Believe
me, I have no animosity towards you and I am sure no one else has either.
We are resisting the change you want simply because it would violate the
RFC which we agreed to follow when we created the types.
If you think this is hostile, you will probably think that the original
discussions in the archives are nuclear war :-). If you would like to
look it over make sure to set aside a lot of time. We spent a long time
hashing this out.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M5276@hub.org Mon Jul 24 16:54:14 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id QAA11929
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 16:54:13 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OKruh24719;
Mon, 24 Jul 2000 16:53:56 -0400 (EDT)
Received: from druid.net (root@druid.net [216.126.72.98])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OKrPh24294
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 16:53:25 -0400 (EDT)
Received: from localhost (1495 bytes) by druid.net
via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp
(sender: <darcy>) (ident <darcy> using unix)
id <m13GpE4-000AX0C@druid.net>
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 16:53:24 -0400 (EDT)
(Smail-3.2.0.109 1999-Oct-27 #3 built 2000-Jun-28)
Message-Id: <m13GpE4-000AX0C@druid.net>
From: darcy@druid.net (D'Arcy J.M. Cain)
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <NCBBKBDOOHHEJCJHLLPAAELHHIAA.ler@lerctr.org> "from Larry Rosenman
at Jul 24, 2000 03:27:24 pm"
To: Larry Rosenman <ler@lerctr.org>
Date: Mon, 24 Jul 2000 16:53:24 -0400 (EDT)
CC: pgsql-hackers@hub.org, Don Baccus <dhogaza@pacifier.com>
Reply-To: pgsql-hackers@hub.org
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Thus spake Larry Rosenman
> What RFC says you can't print all 4 octets of a CIDR Netnumber?
Can't recall. It was Paul Vixie who made the claim and since he was
probably the one who wrote it I tend to believe him.
In fact it may be that it suggested rather than required but someone
would have to dig out the RFC before we considered changing it I think.
> Why does network(cidr) return the whole cidr output just like
> select cidr?
Yah, it's redundant. "network(cidr)" is just a long way to say "cidr."
The only reason it is there is because of the way the code was written
for the two types. Not having it would have required a special test to
look for it and technically it is correct so we didn't bother.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M5277@hub.org Mon Jul 24 17:12:12 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id RAA12251
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 17:12:11 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OLBth32813;
Mon, 24 Jul 2000 17:11:55 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OLBah32716
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 17:11:36 -0400 (EDT)
Received: from lerdesk (ler-desk.iadfw.net [206.66.13.18])
by lerami.lerctr.org (8.10.1/8.10.1/20000715) with SMTP id e6OLBZc28924;
Mon, 24 Jul 2000 16:11:35 -0500 (CDT)
From: "Larry Rosenman" <ler@lerctr.org>
To: <pgsql-hackers@hub.org>, "Larry Rosenman" <ler@lerctr.org>
Cc: "Don Baccus" <dhogaza@pacifier.com>
Subject: RE: [HACKERS] INET/CIDR types
Date: Mon, 24 Jul 2000 16:11:34 -0500
Message-ID: <NCBBKBDOOHHEJCJHLLPAIELMHIAA.ler@lerctr.org>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
X-Mimeole: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
In-Reply-To: <m13GpE4-000AX0C@druid.net>
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Can we dig up the RFC?
Larry
-----Original Message-----
From: pgsql-hackers-owner@hub.org [mailto:pgsql-hackers-owner@hub.org]On
Behalf Of D'Arcy J.M. Cain
Sent: Monday, July 24, 2000 3:53 PM
To: Larry Rosenman
Cc: pgsql-hackers@hub.org; Don Baccus
Subject: Re: [HACKERS] INET/CIDR types
Thus spake Larry Rosenman
> What RFC says you can't print all 4 octets of a CIDR Netnumber?
Can't recall. It was Paul Vixie who made the claim and since he was
probably the one who wrote it I tend to believe him.
In fact it may be that it suggested rather than required but someone
would have to dig out the RFC before we considered changing it I think.
> Why does network(cidr) return the whole cidr output just like
> select cidr?
Yah, it's redundant. "network(cidr)" is just a long way to say "cidr."
The only reason it is there is because of the way the code was written
for the two types. Not having it would have required a special test to
look for it and technically it is correct so we didn't bother.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From pgsql-hackers-owner+M5278@hub.org Mon Jul 24 18:31:03 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id SAA12804
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 18:31:03 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OMUmh59689;
Mon, 24 Jul 2000 18:30:48 -0400 (EDT)
Received: from anubis (anubis.ip23.net [212.83.32.60])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OMTxh58656
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 18:29:59 -0400 (EDT)
Received: from ip23.net (umbriel [212.83.32.61]) by anubis (980427.SGI.8.8.8/980728.SGI.AUTOCF) via ESMTP id AAA96097; Tue, 25 Jul 2000 00:29:42 +0200 (CEST)
Message-ID: <397CC356.7C78A018@ip23.net>
Date: Tue, 25 Jul 2000 00:29:42 +0200
From: Sevo Stille <sevo@ip23.net>
Reply-To: sevo@ip23.net
Organization: IP23
X-Mailer: Mozilla 4.7 [en] (WinNT; U)
X-Accept-Language: en-GB,en,de,en-US
MIME-Version: 1.0
To: Larry Rosenman <ler@lerctr.org>
CC: pgsql-hackers@hub.org
Subject: Re: [HACKERS] INET/CIDR types
References: <NCBBKBDOOHHEJCJHLLPAMELAHIAA.ler@lerctr.org>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Larry Rosenman wrote:
>
> The problem is NON-TECHNICAL people will be getting the output,
> and they expect 4 octet output.
Well, but what are they going to do if they see, say, that 196.100.0.0
is already allocated? Any CIDR net starting off on the .0 will have
exactly the same 4 octet notation. That is, the above entry would only
tell that there is some indeterminable number of addresses starting off
196.100.0.0 allocated, which could be anything between a measly /31 and
a whopping big /16. To repeat: CIDR having no implicit netmask encoded
in the class, there is no way of figuring out your allocation if you
lose the explicit mask. Which presumably will cause considerable
problems in a network allocation and tracking application!
> I really think that we should have a way to coerce a CIDR to
> an INET, and then allow host().
There is no unique mapping of a CIDR network to a INET host address,
except for the special case of /32.
> Remember that I am dealing with $10/hour clerks.
Then given them a interface which makes the concept of CIDR obvious to
them. Faking a classed notation is no way to go! IP v.4 being what it
is, and registries being on the move to enforce CIDR more and more, they
will inevitably encounter CIDR sooner or later, probably in a business
critical way.
> I really don't get the hostility to changing the OUTPUT format...
Anything broken that is added will sooner or later be used by somebody.
Which means that it can't be fixed without breaking some applications.
That alone should be a good enough reason not to introduce any broken
notions intentionally.
Sevo
--
Sevo Stille
sevo@ip23.net
From pgsql-hackers-owner+M5279@hub.org Mon Jul 24 18:31:24 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id SAA12809
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 18:31:23 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OMVBh60018;
Mon, 24 Jul 2000 18:31:11 -0400 (EDT)
Received: from paprika.michvhf.com (paprika.michvhf.com [209.103.136.12])
by hub.org (8.10.1/8.10.1) with SMTP id e6OMUrh59759
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 18:30:53 -0400 (EDT)
Received: (qmail 39846 invoked by uid 1001); 24 Jul 2000 22:30:59 -0000
Date: Mon, 24 Jul 2000 18:30:59 -0400 (EDT)
From: Vince Vielhaber <vev@michvhf.com>
To: Larry Rosenman <ler@lerctr.org>
cc: pgsql-hackers@hub.org
Subject: RE: [HACKERS] INET/CIDR types
In-Reply-To: <NCBBKBDOOHHEJCJHLLPAIELMHIAA.ler@lerctr.org>
Message-ID: <Pine.BSF.4.21.0007241828230.36999-100000@paprika.michvhf.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
On Mon, 24 Jul 2000, Larry Rosenman wrote:
> Can we dig up the RFC?
Feel free. You can start your research with RFC1467 and look back at
what it touches on, then on to 1517, 1518 and 1519 then to 1817 and
then to 2317. If, after reading these, you don't understand why and/or
why not you can check with Paul himself at www.vix.com, 'cuze if you
don't understand then he's your only hope.
Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev@michvhf.com http://www.pop4.net
128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================
From pgsql-hackers-owner+M5280@hub.org Mon Jul 24 18:53:56 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id SAA12905
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 18:53:55 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6OMrjh74011;
Mon, 24 Jul 2000 18:53:45 -0400 (EDT)
Received: from anubis (anubis.ip23.net [212.83.32.60])
by hub.org (8.10.1/8.10.1) with ESMTP id e6OMrNh73763
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 18:53:24 -0400 (EDT)
Received: from ip23.net (umbriel [212.83.32.61]) by anubis (980427.SGI.8.8.8/980728.SGI.AUTOCF) via ESMTP id AAA95973; Tue, 25 Jul 2000 00:52:30 +0200 (CEST)
Message-ID: <397CC8AE.FC342360@ip23.net>
Date: Tue, 25 Jul 2000 00:52:30 +0200
From: Sevo Stille <sevo@ip23.net>
Reply-To: sevo@ip23.net
Organization: IP23
X-Mailer: Mozilla 4.7 [en] (WinNT; U)
X-Accept-Language: en-GB,en,de,en-US
MIME-Version: 1.0
To: Larry Rosenman <ler@lerctr.org>
CC: pgsql-hackers@hub.org, Don Baccus <dhogaza@pacifier.com>
Subject: Re: [HACKERS] INET/CIDR types
References: <NCBBKBDOOHHEJCJHLLPAAELHHIAA.ler@lerctr.org>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Larry Rosenman wrote:
>
> What RFC says you can't print all 4 octets of a CIDR Netnumber?
Implicitly in 1518, for example:
---------8<----------------------8<----------------------8<------------
For the purposes of this paper, an IP prefix is an IP address and
some indication of the leftmost contiguous significant bits within
this address.
---------8<----------------------8<----------------------8<------------
As I already explained, the use of variable-length masks implies that
they have to be explicitly stated. This was not neccessary in classed
networks, as the MSB's encoded the class (mask).
> Why does network(cidr) return the whole cidr output just like
> select cidr?
Because a cast to network is a cast to CIDR - casting to the same type
obviously won't change a thing.
> I'm just trying to figure out the logic here.
As a matter of fact, it is the side effect of the current
implementations shortcomings - we have common code for INET and CIDR,
otherwise, network would not have to be a valid operator for CIDR.
> Here is what my Cisco Router that speaks BGP says:
> big-bro#term ip netmask-format bit-count
> big-bro#sh ip bg 206.66.0.0/20
> BGP routing table entry for 206.66.0.0/20, version 150832
> Paths: (5 available, best #4)
> Advertised to non peer-group peers:
> 157.130.140.109 166.63.135.33 206.66.12.3 206.66.12.4 206.66.12.7
> 206.66.12.
> ...
> I am just asking for the same type output.
Huh? The only *network* I see in there IS in /bits notation.
Sevo
--
Sevo Stille
sevo@ip23.net
From pgsql-hackers-owner+M5282@hub.org Mon Jul 24 19:05:38 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id TAA13152
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 19:05:37 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6ON5Mh82281;
Mon, 24 Jul 2000 19:05:22 -0400 (EDT)
Received: from smtp.pacifier.com (comet.pacifier.com [199.2.117.155])
by hub.org (8.10.1/8.10.1) with ESMTP id e6ON4qh81966
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 19:04:52 -0400 (EDT)
Received: from desktop (dsl-dhogaza.pacifier.net [207.202.226.68])
by smtp.pacifier.com (8.9.3/8.9.3pop) with SMTP id QAA16750;
Mon, 24 Jul 2000 16:04:27 -0700 (PDT)
Message-Id: <3.0.1.32.20000724160016.01192100@mail.pacifier.com>
X-Sender: dhogaza@mail.pacifier.com
X-Mailer: Windows Eudora Pro Version 3.0.1 (32)
Date: Mon, 24 Jul 2000 16:00:16 -0700
To: Vince Vielhaber <vev@michvhf.com>, Larry Rosenman <ler@lerctr.org>
From: Don Baccus <dhogaza@pacifier.com>
Subject: RE: [HACKERS] INET/CIDR types
Cc: pgsql-hackers@hub.org
In-Reply-To: <Pine.BSF.4.21.0007241828230.36999-100000@paprika.michvhf.c
om>
References: <NCBBKBDOOHHEJCJHLLPAIELMHIAA.ler@lerctr.org>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
At 06:30 PM 7/24/00 -0400, Vince Vielhaber wrote:
>On Mon, 24 Jul 2000, Larry Rosenman wrote:
>
>> Can we dig up the RFC?
>
>Feel free. You can start your research with RFC1467 and look back at
>what it touches on, then on to 1517, 1518 and 1519 then to 1817 and
>then to 2317. If, after reading these, you don't understand why and/or
>why not you can check with Paul himself at www.vix.com, 'cuze if you
>don't understand then he's your only hope.
I bet just hacking your PHP script to format it in the way you want
would involve a heck of a lot less effort ...
- Don Baccus, Portland OR <dhogaza@pacifier.com>
Nature photos, on-line guides, Pacific Northwest
Rare Bird Alert Service and other goodies at
http://donb.photo.net.
From pgsql-hackers-owner+M5281@hub.org Mon Jul 24 19:01:25 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id TAA12969
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 19:01:25 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6ON1Dh79863;
Mon, 24 Jul 2000 19:01:13 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6ON0rh79630
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 19:00:53 -0400 (EDT)
Received: (from ler@localhost)
by lerami.lerctr.org (8.10.1/8.10.1/20000715) id e6ON0lO03554;
Mon, 24 Jul 2000 18:00:47 -0500 (CDT)
From: Larry Rosenman <ler@lerctr.org>
Message-Id: <200007242300.e6ON0lO03554@lerami.lerctr.org>
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <397CC8AE.FC342360@ip23.net> "from Sevo Stille at Jul 25, 2000 00:52:30
am"
To: sevo@ip23.net
Date: Mon, 24 Jul 2000 18:00:46 -0500 (CDT)
CC: Larry Rosenman <ler@lerctr.org>, pgsql-hackers@hub.org,
Don Baccus <dhogaza@pacifier.com>
X-Mailer: ELM [version 2.4ME+ PL79 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
> Larry Rosenman wrote:
> >
> > What RFC says you can't print all 4 octets of a CIDR Netnumber?
>
> Implicitly in 1518, for example:
> ---------8<----------------------8<----------------------8<------------
> For the purposes of this paper, an IP prefix is an IP address and
> some indication of the leftmost contiguous significant bits within
> this address.
> ---------8<----------------------8<----------------------8<------------
This doesn't prohibit listing all 4 octets, which is my argument...
>
> As I already explained, the use of variable-length masks implies that
> they have to be explicitly stated. This was not neccessary in classed
> networks, as the MSB's encoded the class (mask).
I know this...
>
> > Why does network(cidr) return the whole cidr output just like
> > select cidr?
>
> Because a cast to network is a cast to CIDR - casting to the same type
> obviously won't change a thing.
>
> > I'm just trying to figure out the logic here.
>
> As a matter of fact, it is the side effect of the current
> implementations shortcomings - we have common code for INET and CIDR,
> otherwise, network would not have to be a valid operator for CIDR.
I just want something equivalent to host(inet) that
prints all 4 octets of a CIDR type with no mask.
Is that hard?
>
> > Here is what my Cisco Router that speaks BGP says:
> > big-bro#term ip netmask-format bit-count
> > big-bro#sh ip bg 206.66.0.0/20
> > BGP routing table entry for 206.66.0.0/20, version 150832
> > Paths: (5 available, best #4)
> > Advertised to non peer-group peers:
> > 157.130.140.109 166.63.135.33 206.66.12.3 206.66.12.4 206.66.12.7
> > 206.66.12.
> > ...
> > I am just asking for the same type output.
>
> Huh? The only *network* I see in there IS in /bits notation.
Yes, but with all 4 octets, which is all I'm looking for....
>
> Sevo
>
> --
> Sevo Stille
> sevo@ip23.net
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 (voice) Internet: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
From pgsql-hackers-owner+M5285@hub.org Mon Jul 24 22:17:47 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id WAA22852
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 22:17:46 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6P2CVh51074;
Mon, 24 Jul 2000 22:12:31 -0400 (EDT)
Received: from spider.pilosoft.com (p55-222.acedsl.com [160.79.55.222])
by hub.org (8.10.1/8.10.1) with ESMTP id e6P2Boh50884
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 22:11:50 -0400 (EDT)
Received: from localhost (alexmail@localhost)
by spider.pilosoft.com (8.9.3/8.9.3) with ESMTP id WAA03783;
Mon, 24 Jul 2000 22:13:58 -0400 (EDT)
Date: Mon, 24 Jul 2000 22:13:57 -0400 (EDT)
From: Alex Pilosov <alex@pilosoft.com>
To: Sevo Stille <sevo@ip23.net>
cc: Larry Rosenman <ler@lerctr.org>, pgsql-hackers@hub.org
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <397CC356.7C78A018@ip23.net>
Message-ID: <Pine.BSO.4.10.10007242208480.4362-100000@spider.pilosoft.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
This whole discussion is quite silly guys.
It is quite reasonable to have ability to split CIDR net into two pieces:
the network and the bitshift. Second one is already possible, the first
one can be accomplished by having functions to convert a cidr/inet to int8
(not int4 because of sign thing), and back.
Its also very easy to implement ;)
This will actually come very useful for many applications. Something I'm
working on now (allocation of 'most appropriate' block) requires ability
to split a netblock into two, which could be most easily accomplished
using int8 math. (net::int8+2^(netmask(net)-1)).
Now, patch anyone? :)
-alex
On Tue, 25 Jul 2000, Sevo Stille wrote:
> Larry Rosenman wrote:
> >
> > The problem is NON-TECHNICAL people will be getting the output,
> > and they expect 4 octet output.
>
> Well, but what are they going to do if they see, say, that 196.100.0.0
> is already allocated? Any CIDR net starting off on the .0 will have
> exactly the same 4 octet notation. That is, the above entry would only
> tell that there is some indeterminable number of addresses starting off
> 196.100.0.0 allocated, which could be anything between a measly /31 and
> a whopping big /16. To repeat: CIDR having no implicit netmask encoded
> in the class, there is no way of figuring out your allocation if you
> lose the explicit mask. Which presumably will cause considerable
> problems in a network allocation and tracking application!
>
> > I really think that we should have a way to coerce a CIDR to
> > an INET, and then allow host().
>
> There is no unique mapping of a CIDR network to a INET host address,
> except for the special case of /32.
>
> > Remember that I am dealing with $10/hour clerks.
>
> Then given them a interface which makes the concept of CIDR obvious to
> them. Faking a classed notation is no way to go! IP v.4 being what it
> is, and registries being on the move to enforce CIDR more and more, they
> will inevitably encounter CIDR sooner or later, probably in a business
> critical way.
>
> > I really don't get the hostility to changing the OUTPUT format...
>
> Anything broken that is added will sooner or later be used by somebody.
> Which means that it can't be fixed without breaking some applications.
> That alone should be a good enough reason not to introduce any broken
> notions intentionally.
>
> Sevo
>
>
From pgsql-hackers-owner+M5287@hub.org Mon Jul 24 22:48:05 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id WAA23082
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 22:48:04 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6P2hrh58014;
Mon, 24 Jul 2000 22:43:53 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6P2hbh57922
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 22:43:37 -0400 (EDT)
Received: (from ler@localhost)
by lerami.lerctr.org (8.10.1/8.10.1/20000715) id e6P2eVl12604;
Mon, 24 Jul 2000 21:40:31 -0500 (CDT)
From: Larry Rosenman <ler@lerctr.org>
Message-Id: <200007250240.e6P2eVl12604@lerami.lerctr.org>
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <Pine.BSO.4.10.10007242208480.4362-100000@spider.pilosoft.com>
"from Alex Pilosov at Jul 24, 2000 10:13:57 pm"
To: Alex Pilosov <alex@pilosoft.com>
Date: Mon, 24 Jul 2000 21:40:31 -0500 (CDT)
CC: Sevo Stille <sevo@ip23.net>, Larry Rosenman <ler@lerctr.org>,
pgsql-hackers@hub.org
X-Mailer: ELM [version 2.4ME+ PL79 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
> This whole discussion is quite silly guys.
>
> It is quite reasonable to have ability to split CIDR net into two pieces:
> the network and the bitshift. Second one is already possible, the first
> one can be accomplished by having functions to convert a cidr/inet to int8
> (not int4 because of sign thing), and back.
>
> Its also very easy to implement ;)
>
> This will actually come very useful for many applications. Something I'm
> working on now (allocation of 'most appropriate' block) requires ability
> to split a netblock into two, which could be most easily accomplished
> using int8 math. (net::int8+2^(netmask(net)-1)).
All I'm looking for is to be able to print all 4 octets of an IP address
out so that joe user can take the 4 numbers and type it into the
4 boxes on a Windows 98 box, and use them.
Is that really that abhorrent?
They also need the 4 octet netmask which I can get now.
All we are missing is a way to print ALL 4 NUMBERS ALL THE TIME
for the output. It's not asking for classful, and for sure
we use CIDR all over the place, but for the final output that my
users see, why can't I have the database just print all 4 octets?
Why is this discussion so hard?
Larry
>
> Now, patch anyone? :)
> -alex
> On Tue, 25 Jul 2000, Sevo Stille wrote:
>
> > Larry Rosenman wrote:
> > >
> > > The problem is NON-TECHNICAL people will be getting the output,
> > > and they expect 4 octet output.
> >
> > Well, but what are they going to do if they see, say, that 196.100.0.0
> > is already allocated? Any CIDR net starting off on the .0 will have
> > exactly the same 4 octet notation. That is, the above entry would only
> > tell that there is some indeterminable number of addresses starting off
> > 196.100.0.0 allocated, which could be anything between a measly /31 and
> > a whopping big /16. To repeat: CIDR having no implicit netmask encoded
> > in the class, there is no way of figuring out your allocation if you
> > lose the explicit mask. Which presumably will cause considerable
> > problems in a network allocation and tracking application!
> >
> > > I really think that we should have a way to coerce a CIDR to
> > > an INET, and then allow host().
> >
> > There is no unique mapping of a CIDR network to a INET host address,
> > except for the special case of /32.
> >
> > > Remember that I am dealing with $10/hour clerks.
> >
> > Then given them a interface which makes the concept of CIDR obvious to
> > them. Faking a classed notation is no way to go! IP v.4 being what it
> > is, and registries being on the move to enforce CIDR more and more, they
> > will inevitably encounter CIDR sooner or later, probably in a business
> > critical way.
> >
> > > I really don't get the hostility to changing the OUTPUT format...
> >
> > Anything broken that is added will sooner or later be used by somebody.
> > Which means that it can't be fixed without breaking some applications.
> > That alone should be a good enough reason not to introduce any broken
> > notions intentionally.
> >
> > Sevo
> >
> >
>
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 (voice) Internet: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
From pgsql-hackers-owner+M5288@hub.org Mon Jul 24 22:51:31 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id WAA23098
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 22:51:30 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6P2omh59374;
Mon, 24 Jul 2000 22:50:48 -0400 (EDT)
Received: from spider.pilosoft.com (p55-222.acedsl.com [160.79.55.222])
by hub.org (8.10.1/8.10.1) with ESMTP id e6P2oah59301
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 22:50:36 -0400 (EDT)
Received: from localhost (alexmail@localhost)
by spider.pilosoft.com (8.9.3/8.9.3) with ESMTP id WAA03944;
Mon, 24 Jul 2000 22:53:20 -0400 (EDT)
Date: Mon, 24 Jul 2000 22:53:20 -0400 (EDT)
From: Alex Pilosov <alex@pilosoft.com>
To: Larry Rosenman <ler@lerctr.org>
cc: Sevo Stille <sevo@ip23.net>, pgsql-hackers@hub.org
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <200007250240.e6P2eVl12604@lerami.lerctr.org>
Message-ID: <Pine.BSO.4.10.10007242252290.4362-100000@spider.pilosoft.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
On Mon, 24 Jul 2000, Larry Rosenman wrote:
> > This whole discussion is quite silly guys.
> >
> > It is quite reasonable to have ability to split CIDR net into two pieces:
> > the network and the bitshift. Second one is already possible, the first
> > one can be accomplished by having functions to convert a cidr/inet to int8
> > (not int4 because of sign thing), and back.
> >
> > Its also very easy to implement ;)
> >
> > This will actually come very useful for many applications. Something I'm
> > working on now (allocation of 'most appropriate' block) requires ability
> > to split a netblock into two, which could be most easily accomplished
> > using int8 math. (net::int8+2^(netmask(net)-1)).
> All I'm looking for is to be able to print all 4 octets of an IP address
> out so that joe user can take the 4 numbers and type it into the
> 4 boxes on a Windows 98 box, and use them.
>
> Is that really that abhorrent?
>
> They also need the 4 octet netmask which I can get now.
>
> All we are missing is a way to print ALL 4 NUMBERS ALL THE TIME
> for the output. It's not asking for classful, and for sure
> we use CIDR all over the place, but for the final output that my
> users see, why can't I have the database just print all 4 octets?
Larry,
With my suggestion, you can do it as follows:
net::int8::inet
(net being of cidr type)
-alex
From pgsql-hackers-owner+M5290@hub.org Mon Jul 24 23:10:44 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id XAA23371
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 23:10:44 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6P3ATh64149;
Mon, 24 Jul 2000 23:10:29 -0400 (EDT)
Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11])
by hub.org (8.10.1/8.10.1) with ESMTP id e6P3AAh64000
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 23:10:10 -0400 (EDT)
Received: (from ler@localhost)
by lerami.lerctr.org (8.10.1/8.10.1/20000715) id e6P3A1v13825;
Mon, 24 Jul 2000 22:10:01 -0500 (CDT)
From: Larry Rosenman <ler@lerctr.org>
Message-Id: <200007250310.e6P3A1v13825@lerami.lerctr.org>
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <Pine.BSO.4.10.10007242252290.4362-100000@spider.pilosoft.com>
"from Alex Pilosov at Jul 24, 2000 10:53:20 pm"
To: Alex Pilosov <alex@pilosoft.com>
Date: Mon, 24 Jul 2000 22:10:01 -0500 (CDT)
CC: Larry Rosenman <ler@lerctr.org>, Sevo Stille <sevo@ip23.net>,
pgsql-hackers@hub.org
X-Mailer: ELM [version 2.4ME+ PL79 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
The bad news is it doesn't work now...
ler=# select host(netblock::int8::inet) from networks;
ERROR: Cannot cast type 'cidr' to 'int8'
ler=# \d networks
Table "networks"
Attribute | Type | Modifier
---------------+--------------+----------
netblock | cidr |
router | integer |
interface | varchar(64) |
dest_ip | inet |
net_name | varchar(64) |
owner | integer |
origin | varchar(256) |
assigned_date | date |
assigned_by | varchar(64) |
asn | smallint |
ler=#
> On Mon, 24 Jul 2000, Larry Rosenman wrote:
>
> > > This whole discussion is quite silly guys.
> > >
> > > It is quite reasonable to have ability to split CIDR net into two pieces:
> > > the network and the bitshift. Second one is already possible, the first
> > > one can be accomplished by having functions to convert a cidr/inet to int8
> > > (not int4 because of sign thing), and back.
> > >
> > > Its also very easy to implement ;)
> > >
> > > This will actually come very useful for many applications. Something I'm
> > > working on now (allocation of 'most appropriate' block) requires ability
> > > to split a netblock into two, which could be most easily accomplished
> > > using int8 math. (net::int8+2^(netmask(net)-1)).
> > All I'm looking for is to be able to print all 4 octets of an IP address
> > out so that joe user can take the 4 numbers and type it into the
> > 4 boxes on a Windows 98 box, and use them.
> >
> > Is that really that abhorrent?
> >
> > They also need the 4 octet netmask which I can get now.
> >
> > All we are missing is a way to print ALL 4 NUMBERS ALL THE TIME
> > for the output. It's not asking for classful, and for sure
> > we use CIDR all over the place, but for the final output that my
> > users see, why can't I have the database just print all 4 octets?
>
> Larry,
> With my suggestion, you can do it as follows:
>
> net::int8::inet
>
> (net being of cidr type)
> -alex
>
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 (voice) Internet: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
From pgsql-hackers-owner+M5291@hub.org Mon Jul 24 23:24:11 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id XAA23433
for <pgman@candle.pha.pa.us>; Mon, 24 Jul 2000 23:24:10 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6P3Nfh69885;
Mon, 24 Jul 2000 23:23:41 -0400 (EDT)
Received: from spider.pilosoft.com (p55-222.acedsl.com [160.79.55.222])
by hub.org (8.10.1/8.10.1) with ESMTP id e6P3Mvh69635
for <pgsql-hackers@hub.org>; Mon, 24 Jul 2000 23:22:57 -0400 (EDT)
Received: from localhost (alexmail@localhost)
by spider.pilosoft.com (8.9.3/8.9.3) with ESMTP id XAA27580;
Mon, 24 Jul 2000 23:25:41 -0400 (EDT)
Date: Mon, 24 Jul 2000 23:25:41 -0400 (EDT)
From: Alex Pilosov <alex@pilosoft.com>
To: Larry Rosenman <ler@lerctr.org>
cc: Sevo Stille <sevo@ip23.net>, pgsql-hackers@hub.org
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <200007250310.e6P3A1v13825@lerami.lerctr.org>
Message-ID: <Pine.BSO.4.10.10007242314200.4362-100000@spider.pilosoft.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Yes, I know.
I didn't say it existed, I proposed to create a simple conversion function
that would do that, which is why I asked for a patch.
I'd do it myself but it'll take some time. Should be really simple,
something to the effect of return a.s_addr (where a is struct in_addr),
however, I'm not sure what's POSIXly correct way to do that.
On Mon, 24 Jul 2000, Larry Rosenman wrote:
> The bad news is it doesn't work now...
>
>
> ler=# select host(netblock::int8::inet) from networks;
> ERROR: Cannot cast type 'cidr' to 'int8'
> ler=# \d networks
> Table "networks"
> Attribute | Type | Modifier
> ---------------+--------------+----------
> netblock | cidr |
> router | integer |
> interface | varchar(64) |
> dest_ip | inet |
> net_name | varchar(64) |
> owner | integer |
> origin | varchar(256) |
> assigned_date | date |
> assigned_by | varchar(64) |
> asn | smallint |
>
> ler=#
>
> > On Mon, 24 Jul 2000, Larry Rosenman wrote:
> >
> > > > This whole discussion is quite silly guys.
> > > >
> > > > It is quite reasonable to have ability to split CIDR net into two pieces:
> > > > the network and the bitshift. Second one is already possible, the first
> > > > one can be accomplished by having functions to convert a cidr/inet to int8
> > > > (not int4 because of sign thing), and back.
> > > >
> > > > Its also very easy to implement ;)
> > > >
> > > > This will actually come very useful for many applications. Something I'm
> > > > working on now (allocation of 'most appropriate' block) requires ability
> > > > to split a netblock into two, which could be most easily accomplished
> > > > using int8 math. (net::int8+2^(netmask(net)-1)).
> > > All I'm looking for is to be able to print all 4 octets of an IP address
> > > out so that joe user can take the 4 numbers and type it into the
> > > 4 boxes on a Windows 98 box, and use them.
> > >
> > > Is that really that abhorrent?
> > >
> > > They also need the 4 octet netmask which I can get now.
> > >
> > > All we are missing is a way to print ALL 4 NUMBERS ALL THE TIME
> > > for the output. It's not asking for classful, and for sure
> > > we use CIDR all over the place, but for the final output that my
> > > users see, why can't I have the database just print all 4 octets?
> >
> > Larry,
> > With my suggestion, you can do it as follows:
> >
> > net::int8::inet
> >
> > (net being of cidr type)
> > -alex
> >
>
>
>
From pgsql-hackers-owner+M5292@hub.org Tue Jul 25 01:27:56 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id BAA25020
for <pgman@candle.pha.pa.us>; Tue, 25 Jul 2000 01:27:56 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6P5RWh12976;
Tue, 25 Jul 2000 01:27:32 -0400 (EDT)
Received: from smtp.pacifier.com (comet.pacifier.com [199.2.117.155])
by hub.org (8.10.1/8.10.1) with ESMTP id e6P5PHh12429
for <pgsql-hackers@hub.org>; Tue, 25 Jul 2000 01:25:17 -0400 (EDT)
Received: from desktop (dsl-dhogaza.pacifier.net [207.202.226.68])
by smtp.pacifier.com (8.9.3/8.9.3pop) with SMTP id WAA04370;
Mon, 24 Jul 2000 22:25:00 -0700 (PDT)
Message-Id: <3.0.1.32.20000724221204.01198400@mail.pacifier.com>
X-Sender: dhogaza@mail.pacifier.com
X-Mailer: Windows Eudora Pro Version 3.0.1 (32)
Date: Mon, 24 Jul 2000 22:12:04 -0700
To: Larry Rosenman <ler@lerctr.org>, Alex Pilosov <alex@pilosoft.com>
From: Don Baccus <dhogaza@pacifier.com>
Subject: Re: [HACKERS] INET/CIDR types
Cc: Sevo Stille <sevo@ip23.net>, Larry Rosenman <ler@lerctr.org>,
pgsql-hackers@hub.org
In-Reply-To: <200007250240.e6P2eVl12604@lerami.lerctr.org>
References: <Pine.BSO.4.10.10007242208480.4362-100000@spider.pilosoft.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
At 09:40 PM 7/24/00 -0500, Larry Rosenman wrote:
>Why is this discussion so hard?
Because it's an output format you could easily solve yourself. Could've
solved yourself long ago.
If you care so much, change the sources and run your own custom version.
The beauty of open source, you get to break it in whatever manner you
choose.
Or hack your PHP script.
If you need help hacking your script you can probably get help, here. I'm
sure people are tired enough of this thread to write it for you, if that's
necessary.
Next I suppose you'll ask that Unix "ls" output switch "/" to
"\" so your $10 clerks can understand the output?
- Don Baccus, Portland OR <dhogaza@pacifier.com>
Nature photos, on-line guides, Pacific Northwest
Rare Bird Alert Service and other goodies at
http://donb.photo.net.
From pgsql-hackers-owner+M5321@hub.org Tue Jul 25 16:45:35 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id QAA19032
for <pgman@candle.pha.pa.us>; Tue, 25 Jul 2000 16:45:34 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6PKieh98955;
Tue, 25 Jul 2000 16:44:40 -0400 (EDT)
Received: from merganser.its.uu.se (merganser.its.uu.se [130.238.6.236])
by hub.org (8.10.1/8.10.1) with ESMTP id e6PKenh96652
for <pgsql-hackers@hub.org>; Tue, 25 Jul 2000 16:40:49 -0400 (EDT)
Received: from regulus.student.UU.SE ([130.238.5.2]:40690 "EHLO
regulus.its.uu.se") by merganser.its.uu.se with ESMTP
id <S291004AbQGYUkH>; Tue, 25 Jul 2000 22:40:07 +0200
Received: from peter (helo=localhost)
by regulus.its.uu.se with local-esmtp (Exim 3.02 #2)
id 13HBVx-0001cn-00; Tue, 25 Jul 2000 22:41:21 +0200
Date: Tue, 25 Jul 2000 22:41:21 +0200 (CEST)
From: Peter Eisentraut <peter_e@gmx.net>
To: pgsql-hackers@hub.org
cc: Larry Rosenman <ler@lerctr.org>
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <m13Gngs-000AXeC@druid.net>
Message-ID: <Pine.LNX.4.21.0007251905480.546-100000@localhost.localdomain>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
D'Arcy J.M. Cain writes:
> Hmmm. I just noticed this.
>
> darcy=> select '1.2.0.1/23'::cidr;
> ?column?
> --------
> 1.2.0/23
> (1 row)
>
> Shouldn't that throw an error?
Isn't that what I've been saying all along?
--
Peter Eisentraut Sernanders väg 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
From pgsql-hackers-owner+M5370@hub.org Thu Jul 27 06:17:36 2000
Received: from hub.org (root@hub.org [216.126.84.1])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id GAA24699
for <pgman@candle.pha.pa.us>; Thu, 27 Jul 2000 06:17:35 -0400 (EDT)
Received: from hub.org (majordom@localhost [127.0.0.1])
by hub.org (8.10.1/8.10.1) with SMTP id e6RAHRA44622;
Thu, 27 Jul 2000 06:17:27 -0400 (EDT)
Received: from druid.net (root@druid.net [216.126.72.98])
by hub.org (8.10.1/8.10.1) with ESMTP id e6RAH2A44416
for <pgsql-hackers@hub.org>; Thu, 27 Jul 2000 06:17:02 -0400 (EDT)
Received: from localhost (1387 bytes) by druid.net
via sendmail with P:stdio/R:bind_hosts/T:inet_zone_bind_smtp
(sender: <darcy>) (ident <darcy> using unix)
id <m13Hkik-000AX9C@druid.net>
for <pgsql-hackers@hub.org>; Thu, 27 Jul 2000 06:16:54 -0400 (EDT)
(Smail-3.2.0.109 1999-Oct-27 #3 built 2000-Jun-28)
Message-Id: <m13Hkik-000AX9C@druid.net>
From: darcy@druid.net (D'Arcy J.M. Cain)
Subject: Re: [HACKERS] INET/CIDR types
In-Reply-To: <Pine.LNX.4.21.0007251905480.546-100000@localhost.localdomain>
"from Peter Eisentraut at Jul 25, 2000 10:41:21 pm"
To: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 27 Jul 2000 06:16:54 -0400 (EDT)
CC: pgsql-hackers@hub.org, Larry Rosenman <ler@lerctr.org>
Reply-To: pgsql-hackers@hub.org
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII
X-Mailing-List: pgsql-hackers@postgresql.org
Precedence: bulk
Sender: pgsql-hackers-owner@hub.org
Status: OR
Thus spake Peter Eisentraut
> > Hmmm. I just noticed this.
> >
> > darcy=> select '1.2.0.1/23'::cidr;
> > ?column?
> > --------
> > 1.2.0/23
> > (1 row)
> >
> > Shouldn't that throw an error?
>
> Isn't that what I've been saying all along?
Well, yes but I thought that it was now and that you were arguing to keep
that behaviour. This seems to be the behaviour that I was suggesting
although you have half convinced me that this should throw an error.
So, it looks like the status quo is for inet::cidr to be a different
spelling for network(inet). Is this the way we want to keep it?
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
|