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

From hubert depesz lubaczewski
Subject Re: inet to bigint?
Date
Msg-id 9e4684ce0512052348h7f9d71aax379498ba62cfe995@mail.gmail.com
Whole thread Raw
In response to Re: inet to bigint?  (Michael Fuhr <mike@fuhr.org>)
List pgsql-hackers
On 12/6/05, Michael Fuhr <mike@fuhr.org> wrote:
How about:
CREATE FUNCTION inet2num(inet) RETURNS numeric AS $$
use Socket;
return unpack("N", inet_aton($_[0]));
$$ LANGUAGE plperlu IMMUTABLE STRICT;

you can use this one:
... AS $$
return unpack("N", pack("C4", split(/\./, $_[0])));
$$ language plperl IMMUTABLE STRICT;

to avoid the need to use untrusted languages.
it is less readable thought :(

depesz

pgsql-hackers by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: inet to bigint?
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: inet to bigint?