Re: inet increment w/ int8

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: inet increment w/ int8
Дата
Msg-id 877jiyk7st.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Re: inet increment w/ int8  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: inet increment w/ int8  ("Ilya A. Kovalenko" <shadow@oganer.net>)
Список pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:

> > Ie, 
> > 
> > 10.0.0.0/24   + 1 = 10.0.0.1/24
> > 10.0.0.255/24 + 1 => overflow
> > 
> > Or
> > 
> > 10.1/16 + 1      = 10.1.0.1/16
> > 10.1/16 + 16384  = 10.1.64.0/16
> > 10.1/16 + 65536  => overflow
> 
> So, do not overflow?  

You mean not doing modulus arithemtic? Yes. Overflow instead.

I see a use case for of generating addresses based on a sequence or some
primary key from the database.

Something like

CREATE SEQUENCE hosts_ip_seq MAXVALUE 65536;
ALTER TABLE hosts ALTER ip SET DEFAULT '10.0.0.0/16'::inet + nextval(hosts_ip_seq')

Using the primary key or some foreign key in the table would require a trigger
which would take too much work to cons up an example for.

-- 
greg



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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Problem with PITR recovery
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Problem with PITR recovery