Re: inet to bigint? - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: inet to bigint?
Date
Msg-id 439542F5.7000703@familyhealth.com.au
Whole thread Raw
In response to Re: inet to bigint?  (Michael Fuhr <mike@fuhr.org>)
Responses Re: inet to bigint?
List pgsql-hackers
PL/SQL or PL/PGSQL...

Chris

Michael Fuhr wrote:
> On Tue, Dec 06, 2005 at 03:31:59PM +0800, Christopher Kings-Lynne wrote:
> 
>>OK, I give up - how do I convert an INET type to a NUMERIC 
>>representation of its network address?
> 
> 
> How about:
> 
> CREATE FUNCTION inet2num(inet) RETURNS numeric AS $$
> use Socket;
> return unpack("N", inet_aton($_[0]));
> $$ LANGUAGE plperlu IMMUTABLE STRICT;
> 
> SELECT inet2num('127.0.0.1');
>   inet2num  
> ------------
>  2130706433
> (1 row)
> 



pgsql-hackers by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: inet to bigint?
Next
From: Michael Fuhr
Date:
Subject: Re: inet to bigint?