pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Determining if two subnets intersect
3+ messages / 2 participants
[nested] [flat]

* Determining if two subnets intersect
@ 2001-07-23 16:56 Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>
  2001-07-25 06:49 ` Re: Determining if two subnets intersect Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Florian Weimer @ 2001-07-23 16:56 UTC (permalink / raw)
  To: pgsql-sql

Is there some efficient PostgreSQL expression which is true if and
only if two subnets (given as values of type cidr) have non-empty
intersection (even if the intersection is not a CIDR network)?

-- 
Florian Weimer 	                  Florian.Weimer@RUS.Uni-Stuttgart.DE
University of Stuttgart           http://cert.uni-stuttgart.de/
RUS-CERT                          +49-711-685-5973/fax +49-711-685-5898



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

* Re: Determining if two subnets intersect
  2001-07-23 16:56 Determining if two subnets intersect Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>
@ 2001-07-25 06:49 ` Tom Lane <tgl@sss.pgh.pa.us>
  2001-07-25 07:17   ` Re: Determining if two subnets intersect Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2001-07-25 06:49 UTC (permalink / raw)
  To: Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>; +Cc: pgsql-sql

Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE> writes:
> Is there some efficient PostgreSQL expression which is true if and
> only if two subnets (given as values of type cidr) have non-empty
> intersection (even if the intersection is not a CIDR network)?

Maybe I'm missing something, but ISTM it's only possible for two
CIDR subnets to overlap if one contains the other.  So you could
check with

		A <<= B OR B <<= A

			regards, tom lane



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

* Re: Determining if two subnets intersect
  2001-07-23 16:56 Determining if two subnets intersect Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>
  2001-07-25 06:49 ` Re: Determining if two subnets intersect Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-07-25 07:17   ` Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>
  0 siblings, 0 replies; 3+ messages in thread

From: Florian Weimer @ 2001-07-25 07:17 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql

Tom Lane <tgl@sss.pgh.pa.us> writes:

> Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE> writes:
> > Is there some efficient PostgreSQL expression which is true if and
> > only if two subnets (given as values of type cidr) have non-empty
> > intersection (even if the intersection is not a CIDR network)?
> 
> Maybe I'm missing something, but ISTM it's only possible for two
> CIDR subnets to overlap if one contains the other.  So you could
> check with
> 
> 		A <<= B OR B <<= A

Oh, I think you are right; I haven't paid attention.  Thanks.

-- 
Florian Weimer 	                  Florian.Weimer@RUS.Uni-Stuttgart.DE
University of Stuttgart           http://cert.uni-stuttgart.de/
RUS-CERT                          +49-711-685-5973/fax +49-711-685-5898



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


end of thread, other threads:[~2001-07-25 07:17 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-07-23 16:56 Determining if two subnets intersect Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>
2001-07-25 06:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-07-25 07:17   ` Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>

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