pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: mr.dash.four@googlemail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #7575: "between" does not work properly with inet/cidr addresses
Date: Sun, 30 Sep 2012 01:26:02 -0400
Message-ID: <15990.1348982762@sss.pgh.pa.us> (raw)
In-Reply-To: <E1THijW-00022e-9T@wrigleys.postgresql.org>
References: <E1THijW-00022e-9T@wrigleys.postgresql.org>

mr.dash.four@googlemail.com writes:
> 1. select '10.1.1.0/24'::inet between '10.1.1.0'::inet and
> '10.1.1.255'::inet gives me FALSE.

> Am I missing something obvious?

10.1.1.0/24 is different from, and sorts before, 10.1.1.0/32
(which is what '10.1.1.0'::inet is an abbreviation for).

You might find that the net address inclusion operators (<< and friends)
provide the semantics you're looking for.  BETWEEN only knows about
btree sort ordering, which is fundamentally a brick or two shy of a
load when considering two-dimensional quantities such as netmasks.

			regards, tom lane




view thread (5+ messages)  latest in thread

Message-ID: <15990.1348982762@sss.pgh.pa.us>
Permalink:  ../15990.1348982762@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15990.1348982762@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mr.dash.four@googlemail.com
  Subject: Re: BUG #7575: "between" does not work properly with inet/cidr addresses
  In-Reply-To: <15990.1348982762@sss.pgh.pa.us>
  References: <E1THijW-00022e-9T@wrigleys.postgresql.org> <15990.1348982762@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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