Re: BUG #5894: Rules' behaviour when SERIAL data types are used

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #5894: Rules' behaviour when SERIAL data types are used
Дата
Msg-id 11536.1298053272@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #5894: Rules' behaviour when SERIAL data types are used  ("Piergiorgio Buongiovanni" <piergiorgio.buongiovanni@netspa.it>)
Список pgsql-bugs
"Piergiorgio Buongiovanni" <piergiorgio.buongiovanni@netspa.it> writes:
> We are experiencing a problem on using rules and serial data types with
> PostgreSQL.
> We are trying to align two tables in two different schemas through rules and
> the main table has a column of data type SERIAL.
> ...
> Now we create a rule in order to align l10n.prova when a row is inserted in
> business.prova:

> CREATE OR REPLACE RULE _Prova_Ins AS ON INSERT
>   TO business.Prova
>   DO ALSO INSERT INTO l10n.Prova VALUES (NEW.iSId, NEW.cName);


By and large, rules don't work very well with commands involving
volatile functions like nextval().  That's because a rule is a macro
and the macro expansion can result in multiple calls of the volatile
function.

Best advice is to use a trigger, not a rule, for propagating changes
from one table to another.

            regards, tom lane

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

Предыдущее
От: "Piergiorgio Buongiovanni"
Дата:
Сообщение: BUG #5894: Rules' behaviour when SERIAL data types are used
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #5878: BTREE_BUILD_STATS causes 'make check' to fail