Re: Triggers on columns

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Triggers on columns
Date: 2009-09-08 21:22:09
Message-ID: 603c8f070909081422t7cd4f9cet9c2ef4662472be46@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 7, 2009 at 6:53 AM, Itagaki
Takahiro<itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> wrote:
>
> Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>
>> Therefore, it cannot be completely unexpected if column triggers are
>> called even if the column was not actually changed in a semantically
>> significant way.
>
> Ok, the attached patch implements standard-compliant version of
> column trigger.
>
> Retrieving modified columns is not so difficult as I expected.
> It is in:
>  rt_fetch(relinfo->ri_RangeTableIndex, estate->es_range_table)->modifiedCols
> and the information are passed from caller to trigger routines.
>
>
> However, to be honest, I think standard-compliant column trigger is
> useless... I'm thinking additional extension for triggers -- if we
> want to check modifications of actual values, it could be defined as:
>
>    CREATE TRIGGER trig BEFORE UPDATE ON tbl FOR EACH ROW
>        WHEN (NEW.col <> OLD.col) EXECUTE PROCEDURE trigger_func();

It might be better to use WHERE than WHEN. Unfortunately this still
has all the wordiness of doing it in the trigger function. How about
some more trivial syntax modification, like:

CREATE TRIGGER name
BEFORE UPDATE MODIFYING col1, col12, ...
ON tbl FOR EACH ROW EXECUTE PROCEDURE func();

...Robert

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Creager 2009-09-08 21:29:29 Any interest in buildfarm a member using Apple's llvm-gcc-4.2 or clang?
Previous Message James Pye 2009-09-08 21:02:40 Re: Triggers on columns