Re: [HACKERS] cidr - Mailing list pgsql-hackers
From | darcy@druid.net (D'Arcy J.M. Cain) |
---|---|
Subject | Re: [HACKERS] cidr |
Date | |
Msg-id | m0yzgN1-00006FC@druid.net Whole thread Raw |
In response to | Re: [HACKERS] cidr (Bruce Momjian <maillist@candle.pha.pa.us>) |
Responses |
Re: [HACKERS] cidr
|
List | pgsql-hackers |
Thus spake Bruce Momjian > > > 192.0.0.3:255.255.0.0 host/netmask > > Converted internally to 192.0.0.3:/16 > > This is a problem. Suppose you have: > > 192.0.0.0:255.255.255.0 > > This is a host with netmask, while: > > 192.0.0.0/24 > > is a network address. Paul? I believe that these two representations refer to the same thing. Whether that thing is a network or an address depends on the application. Either the column is being used to store networks or hosts. That's what I was getting at with my previous analogy with int types. An int could hold ordinal numbers like IDs or it could hold quantities. We don't need the data type to store which. The application knows and we don't store ID codes and counts in the same column. The same with IP numbers. We decide in any particular application whether a column is a list of hosts or a list of networks and we then populate it. I do like the idea of using attypmod to define the form of the type. I assume we can use that to determine the output format, that is, use it to effectively apply one of the functions to it. That makes for a clean use of the type. > > > 192.0.0.3/32:255.255.255.0 host?/netmask > > But 192.0.0.3/24 or 192.0.0.3:255.255.255.0 gives all the information > > that you need. > > See example above. You use the 3 here to know it is a host, because the > IP address extens past the netmask, but what if they are zeros? Technically, 192.0.0.0/24 is a valid host on 192.0.0 although most people avoid it because some older equipment doesn't handle it very well. > > You mean printing netmasks? As I said, it seems to me that netmasks will > > always be paired with a host or network but perhaps we can set up the > > function table so that netmask on an integer type converts to a netmask > > in the form you suggest. That would be the truly oo way to do it. > > Certainly we could, but it seems nice to have one type just for ip-type > stuff. I agree. I'm just saying that we can add the netmask function to integer as well. That gives someone the flexibility to store it either way. However, I don't think I am going to speak to this point again until someone can give me a single example of a requirement for storing netmasks independent of any hosts or networks. :-) I just thought of another useful function. broadcast('192.3.4.5/24::cidr') == 192.3.4.255 -- 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 424 2871 (DoD#0082) (eNTP) | what's for dinner.
pgsql-hackers by date: