Re: sequences and RULEs

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: sequences and RULEs
Дата
Msg-id 4A291E58.3040406@archonet.com
обсуждение исходный текст
Ответ на sequences and RULEs  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Ответы Re: sequences and RULEs  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Список pgsql-general
Rafal Pietrak wrote:
> Now I'd like to write a RULE, that automatically updates references
> between EVENTLOG and STATUS:

> The NEW tuple of the table EVENTLOG, in its ID field at the moment of
> RULE execution has a value of 5! But after everything is finished, the
> actual value deposited in that record is 4.

A rule rewrites the query, so you can end up with parts being evaluated
twice. For functions with side-effects like nextval() that causes
problems. There are other issues too.

> So comes my questions:
> 1. Is this a feature or a bug, that such inconsistent NEW tuple show up
> during RULE execution?

It's a (confusing) feature.

> 2. It looks like I'd have to use TRIGGER FOR EACH ROW in this case. But
> may be there is some othar way, that I could achieve this with the RULE
> system?

Triggers for keeping count of things. See the mailing list archives for
details.

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Radcon Entec
Дата:
Сообщение: Re: Using a multi-valued function in a view
Следующее
От: Rafal Pietrak
Дата:
Сообщение: Re: sequences and RULEs