agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Richard RK. Klingler <richard@klingler.net>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: IP address, subnet query behaves wrong for /32
Date: Thu, 6 Aug 2015 10:02:24 -0700
Message-ID: <55C39320.4010905@aklaver.com> (raw)
In-Reply-To: <1FC8E571-8456-4085-B59B-016ECD365768@klingler.net>
References: <1FC8E571-8456-4085-B59B-016ECD365768@klingler.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On 08/06/2015 09:47 AM, Richard RK. Klingler wrote:
> Evenin'
>
> What I discovered just lately is a nice feature from pgsql that I can test
> if a specific IP address falls within a supplied subnet:
>
> myserver=# select inet '192.168.0.1' << '192.168.0.0/24'::inet as ip;
>
>   ip
>
> ----
>
>   t
>
> (1 row)
>
>
>
> But what I don't understand is why pgsql doesn't behave correctly when
> testing for a /32 subnet:
> (it works for /31 correctly though)
>
> myserver=# select inet '192.168.0.1' << '192.168.0.1/32'::inet as ip;
>
>   ip
>
> ----
>
>   f
>
>
>  From a network engineering point of view this should also return "true"
> and not false.

http://www.postgresql.org/docs/9.2/interactive/functions-net.html

"The operators <<, <<=, >>, and >>= test for subnet inclusion."

http://www.postgresql.org/docs/9.2/interactive/datatype-net-types.html#DATATYPE-INET

" If the netmask is 32 and the address is IPv4, then the value does not 
indicate a subnet, only a single host."

So it is behaving as documented.

>
> Has this been fixed in recent versions? I'm using 9.2.8 right now….
>
>
>
> thanks in advance
> richard
>
>


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (9+ messages)  latest in thread

Message-ID: <55C39320.4010905@aklaver.com>
Permalink:  ../55C39320.4010905@aklaver.com/
Also on:    postgresql.org/message-id/55C39320.4010905@aklaver.com

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@aklaver.com, richard@klingler.net
  Subject: Re: IP address, subnet query behaves wrong for /32
  In-Reply-To: <55C39320.4010905@aklaver.com>

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

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