Re: inet to bigint?

From: hubert depesz lubaczewski <depesz(at)gmail(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: inet to bigint?
Date: 2005-12-06 07:48:53
Message-ID: 9e4684ce0512052348h7f9d71aax379498ba62cfe995@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/6/05, Michael Fuhr <mike(at)fuhr(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2005-12-06 07:51:17 Re: inet to bigint?
Previous Message Michael Fuhr 2005-12-06 07:44:28 Re: inet to bigint?