pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
cidr question
2+ messages / 2 participants
[nested] [flat]

* cidr question
@ 2001-12-13 01:38 Mir S Islam <mislam@mindspring.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Mir S Islam @ 2001-12-13 01:38 UTC (permalink / raw)
  To: pgsql-sql

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.

I suppose I could rewrite the above sql as
delete from ip_space where ip >='11.0.1.0/24'::cidr and ip
<='11.0.2.0/24'::cidr;
Then it works. But I should not have to do that. Right ?

Thanks in advance. Please email and post here.

Mir








^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: cidr question
@ 2001-12-14 15:03 D'Arcy J.M. Cain <darcy@druid.net>
  0 siblings, 0 replies; 2+ messages in thread

From: darcy@druid.net @ 2001-12-14 15:03 UTC (permalink / raw)
  To: mislam@mindspring.com; +Cc: 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@{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.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-12-14 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-12-13 01:38 cidr question Mir S Islam <mislam@mindspring.com>
2001-12-14 15:03 Re: cidr question D'Arcy J.M. Cain <darcy@druid.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox