Re: IP address, subnet query behaves wrong for /32

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: IP address, subnet query behaves wrong for /32
Дата
Msg-id CAKFQuwZWonEKVn6FAE_UAh4UiJ6fE0pQWcZn21gvhZg5UR2fzQ@mail.gmail.com
обсуждение исходный текст
Ответ на IP address, subnet query behaves wrong for /32  ("Richard RK. Klingler" <richard@klingler.net>)
Список pgsql-sql
On Thu, Aug 6, 2015 at 9:47 AM, Richard RK. Klingler <richard@klingler.net> 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.


​select inet '192.168.0.1' <<= '192.168.0.1/32'::inet as ip;
ip
---
t
​My best explanation is that since there is no network part on a /32 address there is no concept of "contained within the network" to match against.  The added equality check allows for that condition to be matched.

David J.​

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Richard RK. Klingler"
Дата:
Сообщение: IP address, subnet query behaves wrong for /32
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: IP address, subnet query behaves wrong for /32