compare integer to inet

Поиск
Список
Период
Сортировка
От Bill MacArthur
Тема compare integer to inet
Дата
Msg-id 4E4EE29F.2070209@dhs-club.com
обсуждение исходный текст
Ответы Re: compare integer to inet
Re: compare integer to inet
Список pgsql-admin
Greetings,

Considering that this can be done:

network=# SELECT '0.0.0.0'::inet + 702545920;
   ?column?
------------
  41.224.0.0
(1 row)

How can I perform an operation similar to this that works?

network=# select case when '41.224.0.0'::inet = 702545920 then true else false end;
ERROR:  operator does not exist: inet = integer
LINE 1: select case when '41.224.0.0'::inet = 702545920 then true el...
                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

network=# select case when '41.224.0.0'::inet = 702545920::inet then true else false end;
ERROR:  cannot cast type integer to inet
LINE 1: select case when '41.224.0.0'::inet = 702545920::inet then t...

I'm guessing that there is some internal postgres function that performs the integer to IP address conversion in the
firstexample, but I am at a loss to identify it. 

The reason I ask for this is that we have a dataset that contains ranges of IP addresses, associated with countries,
wherethe addresses are represented as integers (bigints). 

Thanks for the pointer.

Bill MacArthur

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

Предыдущее
От: Marko Kreen
Дата:
Сообщение: Re: Londiste won't start with dual IP addresses
Следующее
От: Scott Ribe
Дата:
Сообщение: Re: compare integer to inet