compare integer to inet - Mailing list pgsql-admin

From Bill MacArthur
Subject compare integer to inet
Date
Msg-id 4E4EE29F.2070209@dhs-club.com
Whole thread Raw
Responses Re: compare integer to inet
Re: compare integer to inet
List 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 by date:

Previous
From: Marko Kreen
Date:
Subject: Re: Londiste won't start with dual IP addresses
Next
From: Scott Ribe
Date:
Subject: Re: compare integer to inet