Trigger with WHEN clause (WIP)
От | Itagaki Takahiro |
---|---|
Тема | Trigger with WHEN clause (WIP) |
Дата | |
Msg-id | 20091015182143.A2E2.52131E4D@oss.ntt.co.jp обсуждение исходный текст |
Ответы |
Re: Trigger with WHEN clause (WIP)
|
Список | pgsql-hackers |
I'm working on WHEN clause support in triggers. I heard that the feature is in the SQL standard. We can rewrite triggers that uses suppress_redundant_updates_trigger http://www.postgresql.org/docs/8.4/static/functions-trigger.html with WHEN clause: CREATE TRIGGER modified_any BEFORE UPDATE ON tbl FOR EACH ROW WHEN (OLD.* IS DISTINCT FROM NEW.*) EXECUTE PROCEDURE trigger_func(); I think there is a benefit to provide WHEN cluase at least for compatibility with other DBMSs, even through we can move the expressions into the body of trigger functions. WIP-patch attached. It adds 'tgqual' text field into pg_trigger. It works at first glance, but surely needs some adjustments especially in the usage of TupleTableSlot in TriggerEnabled(). I have a question about executing qualification expression. I used ecxt_innertuple for old tuples and ecxt_outertuple for new tuples, but I'm not sure it is the right way. Comments and suggestions welcome. James Pye <lists@jwp.name> wrote: > Well, looks like WHEN is, or is going to be standard: > > <triggered action> ::= > [ FOREACH { ROW | STATEMENT } ] > [ WHEN<left paren><search condition> <right paren> ] > <triggered SQL statement> > > (page 653 from 5CD2-02-Foundation-2006-01) David Fetter <david@fetter.org> wrote: > Page 674 of 6WD_02_Foundation_2007-12 has a similar thing: > > <triggered action> ::= > [ FOR EACH { ROW | STATEMENT } ] > [ <triggered when clause> ] > <triggered SQL statement> > > <triggered when clause> ::= > WHEN <left paren> <search condition> <right paren> Regards, --- ITAGAKI Takahiro NTT Open Source Software Center
Вложения
В списке pgsql-hackers по дате отправления: