Re: double insert on inherited table with where constraint based on sequence

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: double insert on inherited table with where constraint based on sequence
Дата
Msg-id 15218.1153336921@sss.pgh.pa.us
обсуждение исходный текст
Ответ на double insert on inherited table with where constraint based on sequence  ("Andrew Hammond" <andrew.george.hammond@gmail.com>)
Список pgsql-bugs
"Andrew Hammond" <andrew.george.hammond@gmail.com> writes:
> Rules:
>     t2_part AS
>     ON INSERT TO t2
>    WHERE new.id > 10 DO INSTEAD  INSERT INTO t2_child (id, name)
>   VALUES (new.id, new.name)

"new.id" is replaced by "nextval('t2_id_seq'::regclass)" each time it
appears ... which will be four separate times, viz the two evaluations
of the WHERE clause and the two VALUES clauses.

Basically, volatile functions and rules do not mix.  Consider using
a trigger on t2 instead to redirect the insert somewhere else.

            regards, tom lane

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

Предыдущее
От: "Marius Žalinauskas"
Дата:
Сообщение: BUG #2535: Unicode on Windows: aogonek is not distinguished from agrave
Следующее
От: Thiago Silva
Дата:
Сообщение: XML2 module: odd query results