Re: possible bug using combination of 'serial' and rule

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: possible bug using combination of 'serial' and rule
Дата
Msg-id 20041101151249.GB18231@winnie.fuhr.org
обсуждение исходный текст
Ответ на possible bug using combination of 'serial' and rule  (Ralph Heinkel <ralph@strubi.ox.ac.uk>)
Список pgsql-bugs
On Sun, Oct 31, 2004 at 03:37:26PM +0000, Ralph Heinkel wrote:
>
> I think this is a bug (I hope not a feature).

It's a feature.

> For each insert into table 'tmp' the serial counter is increased
> twice, once to create the entry in 'tmp', once for 'log'. The problem
> is that the rule does not see the correct 'storage_id'!!!

Rules are macros, so when you refer to NEW.storage_id in the rule
then the default expression "nextval('tmp_storage_id_seq')" is
evaluated again.  If you don't want that to happen then use a
trigger.

This comes up often -- maybe somebody could add it to the FAQ.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: possible bug using combination of 'serial' and rule
Следующее
От: Gaetano Mendola
Дата:
Сообщение: Re: Not a real bug, but an error