Re: Triggers on columns

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Triggers on columns
Date: 2009-09-03 12:15:36
Message-ID: 4A9FB368.4010402@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas wrote:
> On Wed, Sep 2, 2009 at 9:52 PM, Itagaki
> Takahiro<itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> wrote:
>
>> Here is a patch to implement "Support triggers on columns" in our ToDo list.
>>
>> The syntax is:
>> CREATE TRIGGER name
>> BEFORE UPDATE OF col1, col12, ...
>> ON tbl FOR EACH ROW EXECUTE PROCEDURE func();
>>
>> I consulted the previous work following:
>> Column-level triggers (From: Greg Sabino Mullane, Date: 2005-07-04)
>> http://archives.postgresql.org/pgsql-patches/2005-07/msg00107.php
>> and completed some under-construction parts.
>>
>> It's still arguable that we should add dependencies from column
>> triggers to referenced columns. In the present patch, dropeed
>> columns are just ignored and always considered as not-modified.
>> Please grep with "TODO: (TRIGGER)" to check the issue.
>>
>> Comments welcome.
>>
>
> Wow, so I wouldn't have to do this any more?
>
> IF (TG_OP = 'UPDATE') THEN
> IF (OLD.foo IS NOT DISTINCT FROM NEW.foo AND OLD.bar IS NOT
> DISTINCT FROM NEW.bar
> AND OLD.baz IS NOT DISTINCT FROM NEW.baz) THEN
> RETURN NULL;
> END IF;
> END IF;
>
> Apart from any possible gain in efficiency, the sheer savings in
> typing sound quite awesome.
>
>
>

You could make it nicer with something like:

row(new.foo,new.bar,new.baz) is distinct from
row(old.foo,old.bar,old.baz)

couldn't you?

I'm actually having trouble thinking of a case where I'd find this
feature very useful.

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Boszormenyi Zoltan 2009-09-03 13:20:42 ECPG patchset
Previous Message Robert Haas 2009-09-03 11:57:09 Re: Triggers on columns