From: | Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> |
---|---|
To: | KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: TRIGGER with WHEN clause |
Date: | 2009-11-16 08:04:47 |
Message-ID: | 20091116170447.7D80.52131E4D@oss.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-rrreviewers |
Thank for your reviewing!
KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)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
Attachment | Content-Type | Size |
---|---|---|
trigger-when_20091116.patch | application/octet-stream | 53.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2009-11-16 08:05:00 | Re: Patch committers |
Previous Message | Magnus Hagander | 2009-11-16 08:02:54 | Re: Patch committers |
From | Date | Subject | |
---|---|---|---|
Next Message | Bernd Helmle | 2009-11-16 09:12:50 | Re: CommitFest 2009-11: Initial assignments |
Previous Message | Greg Smith | 2009-11-15 21:43:23 | Re: CommitFest 2009-11: Initial assignments |