Re: TRIGGER with WHEN clause

Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>

From: Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: KaiGai Kohei <kaigai@ak.jp.nec.com>, KaiGai Kohei <kaigai@kaigai.gr.jp>, pgsql-hackers@postgresql.org
Date: 2009-11-24T00:42:57Z
Lists: pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> > [ TRIGGER WHEN patch ]
> Applied with assorted revisions.  AFAICT the system column issue is only
> a problem for NEW references in BEFORE triggers --- those columns do
> read correctly in OLD, and all the time in AFTER triggers.  I revised
> the parsing logic to enforce that.  The patch also missed establishing
> dependencies for stuff referenced in the WHEN expression, and there were
> a few other minor problems.

Thanks for your fix.

>> * Keep the expression in nodeToString string form within the TriggerDesc
>> structure; then it's just one more pfree in FreeTriggerDesc.  The main
>> disadvantage of this is that we'd have to repeat stringToNode every time
>> the trigger is used.

I read your fix for the repeated compiling issue is to cache compiled
expressions in ResultRelInfo->ri_TrigWhenExprs. So, we can reuse the
result of stringToNode when we modify multiple rows in a query.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center