From: Tom Lane <tgl@sss.pgh.pa.us>
To: michel@albert.lu
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #11734: The "<<=" operator on "inet" values does not return the expected result.
Date: Tue, 21 Oct 2014 13:55:33 -0400
Message-ID: <7717.1413914133@sss.pgh.pa.us> (raw)
In-Reply-To: <20141021114040.2674.45532@wrigleys.postgresql.org>
References: <20141021114040.2674.45532@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
michel@albert.lu writes:
> The best way to explain this is with a quick example script:
> CREATE TABLE inettest (
> value inet UNIQUE
> );
> INSERT INTO inettest VALUES
> ('1.2.1.0/24'),
> ('1.2.1.1/24'),
> ('1.2.1.2/24'),
> ('1.2.2.0/24'),
> ('1.2.3.0/24'),
> ('1.2.3.1/24'),
> ('1.2.3.2/24'),
> ('1.2.3.3/24'),
> ('1.2.3.4/24')
> ;
> SELECT * FROM inettest WHERE value <<= '1.2.3.1/24'::inet;
> I would expect that the above select would only return *one* row. The one
> with the host '1.2.3.1/24'. Instead, it returns *all* rows of the
> '1.2.3.0/24' network.
The PG documentation is pretty clear on this point:
The operators <<, <<=, >>, >>=, and && test for subnet inclusion. They
consider only the network parts of the two addresses (ignoring any host
part) and determine whether one network is identical to or a subnet of
the other.
[ first para in "Network Address Functions and Operators" ]
So <<= should return true for any two of the addresses you cite here.
Personally I'd use CIDR, not INET, for anything I was thinking of as a
network ID rather than a single host's ID.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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, michel@albert.lu
Subject: Re: BUG #11734: The "<<=" operator on "inet" values does not return the expected result.
In-Reply-To: <7717.1413914133@sss.pgh.pa.us>
References: <20141021114040.2674.45532@wrigleys.postgresql.org> <7717.1413914133@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