Re: TRIGGER with WHEN clause
От | Itagaki Takahiro |
---|---|
Тема | Re: TRIGGER with WHEN clause |
Дата | |
Msg-id | 20091116170447.7D80.52131E4D@oss.ntt.co.jp обсуждение исходный текст |
Ответ на | Re: TRIGGER with WHEN clause (KaiGai Kohei <kaigai@kaigai.gr.jp>) |
Ответы |
Re: TRIGGER with WHEN clause
|
Список | pgsql-hackers |
Thank for your reviewing! KaiGai Kohei <kaigai@kaigai.gr.jp> wrote: > However, I could find a few matters in this patch, as follows: > > * It does not prevent set up a conditional "statement" trigger. I fixed the bug and two other bugs: * Crash in AFTER TRIGGER + WHEN clause. * Incorrect behavior when multiple tuples are modified. Also regression tests for it are added. > I'm uncertain how Oracle handles the condition on the statement > triggers. But it seems to me WHEN clause on the statement triggers > are nonsense. I am also not sure about Oracle, but I think there are usage of statement trigger with WHEN cluase something like: =# CREATE TRIGGER log_trig BEFORE UPDATE ON tbl WHEN (is_superuser()) EXECUTE PROCEDURE log_current_stmt(); > * the documentation seems to me misleading. > It saids, NEW and OLD are only available and ... > o INSERT can refer NEW > o UPDATE can refer NEW, OLD > o DELETE can refer OLD > But, it may actually incorrect, if user gives several events on a certain > trigger. For example, when a new trigger is invoked for each row on INSERT > or UPDATE statement, the function cannot refer the OLD. They are bitwise-AND flags. INSERT-OR-DELETE trigger cannot refer to both OLD and NEW tuples. It is possible to use a dummy tuple (filled with NULLs?) in the cases, but I want to just throw an error as of now. I'll fix documentation to reflect the code. Ideas for better descriptions welcome. | Note that if a trigger has multiple events, it can refer only tuples | that can be referred in all of the events. For example, | INSERT OR DELETE trigger cannot refer neither NEW nor OLD tuples. > * A minor coding style > Is it unnecessary to set InvalidOid on the values[Anum_pg_trigger_tgqual - 1]? Strange. There was something wrong with me. > * doc/src/sgml/catalogs.sgml is not updated > Could you add a short description about pg_trigger.tgqual system catalog? Added. Regards, --- ITAGAKI Takahiro NTT Open Source Software Center
Вложения
В списке pgsql-hackers по дате отправления: