Re: inet to bigint?

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: inet to bigint?
Date: 2005-12-06 08:10:22
Message-ID: 4395476E.7020701@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Sheesh, arbitrary restrictions ;-) Something like this then:
>
> CREATE FUNCTION inet2num(inet) RETURNS numeric AS $$
> DECLARE
> a text[] := string_to_array(host($1), '.');
> BEGIN
> RETURN a[1]::numeric * 16777216 +
> a[2]::numeric * 65536 +
> a[3]::numeric * 256 +
> a[4]::numeric;
> END;
> $$ LANGUAGE plpgsql IMMUTABLE STRICT;

Cool, and now the reverse? :D

(I'll credit you in the MySQL Compat Library code btw) If you're
interested, you'd be welcome to join the project btw...

Chris

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Fuhr 2005-12-06 08:15:08 Re: inet to bigint?
Previous Message Michael Fuhr 2005-12-06 08:09:01 Re: inet to bigint?