Re: cidr question

From: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
To: mislam(at)mindspring(dot)com (Mir S Islam)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: cidr question
Date: 2001-12-14 15:03:39
Message-ID: 20011214150339.D39761A69@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thus spake Mir S Islam
> maybe I am not understanding it right. Here is my problem.
>
> I have a table like this
>
> Attribute | Type | Modifier
> --------------+--------------------------+----------
> ip | cidr | not null
>
> with following rows
> ip
> ---------------
> 10.0.0.1/32
> 10.0.0.50/32
> 10.0.0.255/32
> 11.0.0.0/32
> 11.0.1.200/32
> 11.0.1.20/32
> (6 rows)
>
> should not the command
> DELETE from ip_space where ip = '11.0.1.0/24'::cidr
> delete last two rows ? But it does not delete anything. Basically I would
> like to be able to delete a whole range or block of ip/network addresses.

What you want is the "Contained within" operator. Note the different outputs
from these two queries.

select '11.0.1.200/32'::cidr << '11.0.1.0/24'::cidr;
select '11.0.1.200/32'::cidr << '11.1.1.0/24'::cidr;

--
D'Arcy J.M. Cain <darcy(at){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.

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-12-14 16:03:33 Re: [NOVICE] Storing number '001' ?
Previous Message Stephan Szabo 2001-12-14 14:44:47 Re: performance tuning in large function / transaction