IP address, subnet query behaves wrong for /32

From: "Richard RK(dot) Klingler" <richard(at)klingler(dot)net>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: IP address, subnet query behaves wrong for /32
Date: 2015-08-06 16:47:49
Message-ID: 1FC8E571-8456-4085-B59B-016ECD365768@klingler.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

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

thanks in advance
richard

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2015-08-06 17:01:27 Re: IP address, subnet query behaves wrong for /32
Previous Message Richard RK. Klingler 2015-08-06 16:16:33 Sales report by month and item category