Re: inet to bigint?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: inet to bigint?
Дата
Msg-id 20051206080512.GA77133@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: inet to bigint?  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Ответы Re: inet to bigint?  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Re: inet to bigint?  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-hackers
On Tue, Dec 06, 2005 at 03:51:17PM +0800, Christopher Kings-Lynne wrote:
> PL/SQL or PL/PGSQL...

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;

-- 
Michael Fuhr


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: inet to bigint?
Следующее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: inet to bigint?