Re: [BUGS] bug in RULE insert
От | Tom Lane |
---|---|
Тема | Re: [BUGS] bug in RULE insert |
Дата | |
Msg-id | 16622.1481297137@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | [BUGS] bug in RULE insert (Александр <alexander_8901@mail.ru>) |
Список | pgsql-bugs |
Александр <alexander_8901@mail.ru> writes: > Strange the rule works for an insertion This is expected behavior, because the rule works like a macro, and you have a volatile argument (that is, the nextval() call for the serial column's default) being passed to it and thereby being executed twice. IOW, what you wrote is equivalent to insert into test(id, name) values (nextval('test_id_seq'), '1'), (nextval('test_id_seq'), '2'), (nextval('test_id_seq'), '3'); and that executes, then the rule causes this to also be executed: insert into v_test (v_id, v_name) values (nextval('test_id_seq'), '1'), (nextval('test_id_seq'), '2'), (nextval('test_id_seq'), '3'); What you seem to want would be much more reliably done with a trigger. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs
В списке pgsql-bugs по дате отправления: