Difference between inet and cidr
Difference between inet and cidr
От:
Yan Cheng CHEOK <yccheok@yahoo.com>
Дата:
May I know what is the difference among cidr and inet? I read through Network Address Type (http://www.postgresql.org/docs/8.3/static/datatype-net-types.html) """ The essential difference between inet and cidr data types is that inet accepts values with nonzero bits to the right of the netmask, whereas cidr does not. """ I understand what is Subnet Mask from http://en.wikipedia.org/wiki/Subnetwork. But, what does it mean by "nonzero bits to the right of the netmask"? Is there any example to show the difference among the 2? If I provide the following input 1.2.3.4, this is what I am getting if I view through pgAdmin. inet = 1.2.3.4 cidr = 1.2.3.4/32 |
Re: Difference between inet and cidr
От:
Marti Raudsepp <marti@juffo.org>
Дата:
Hi, On Tue, Jul 5, 2011 at 09:50, Yan Cheng CHEOK wrote: > The essential difference between inet and cidr data types is that inet accepts values with nonzero bits to the right of the netmask, whereas cidr does not. Say, if you have a /8 netmask, the 'cidr' type requires that all the 24 rightmost bits are zero. inet does not have this requirement. E.g: db=# select '255.0.0.0/8'::cidr; 255.0.0.0/8 db=# select '255.1.0.0/8'::cidr; ERROR: invalid cidr value: "255.1.0.0/8" DETAIL: Value has bits set to right of mask. And inet allows this: db=# select '255.1.0.0/8'::inet; 255.1.0.0/8 Hope that helps. Regards, Marti
Re: Difference between inet and cidr
От:
Harald Fuchs <hari.fuchs@gmail.com>
Дата:
In article , Marti Raudsepp writes: > Hi, > On Tue, Jul 5, 2011 at 09:50, Yan Cheng CHEOK wrote: >> The essential difference between inet and cidr data types is that inet accepts values with nonzero bits to the right of the netmask, whereas cidr does not. > Say, if you have a /8 netmask, the 'cidr' type requires that all the > 24 rightmost bits are zero. inet does not have this requirement. > E.g: > db=# select '255.0.0.0/8'::cidr; > 255.0.0.0/8 > db=# select '255.1.0.0/8'::cidr; > ERROR: invalid cidr value: "255.1.0.0/8" > DETAIL: Value has bits set to right of mask. > And inet allows this: > db=# select '255.1.0.0/8'::inet; > 255.1.0.0/8 > Hope that helps. Do the inet/cidr types have any advantage over the ip4r contrib module?