Re: Difference between inet and cidr

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Difference between inet and cidr
Date: 2011-07-05 13:32:23
Message-ID: 861uy4etug.fsf@mgm.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <CABRT9RAr2bFrxdx93H_aEQsKmuchMwurSfENP8itSpExsWsF7g(at)mail(dot)gmail(dot)com>,
Marti Raudsepp <marti(at)juffo(dot)org> writes:

> Hi,
> On Tue, Jul 5, 2011 at 09:50, Yan Cheng CHEOK <yccheok(at)yahoo(dot)com> 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?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Brinkman 2011-07-05 14:47:27 Re: cannot "make USE_PGXS=1" b/c no pgxs.mk exists
Previous Message Marti Raudsepp 2011-07-05 13:09:21 Re: Difference between inet and cidr