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>
Re: double insert on inherited table with where constraint based on sequence Tom Lane <tgl@sss.pgh.pa.us>
"Andrew Hammond"  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
Дата:
От: Thiago Silva
Дата:
Сообщение: XML2 module: odd query results
FAQ