Re: How to notice column changes in trigger

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Andreas Pflug <Andreas(dot)Pflug(at)web(dot)de>, pgsql-sql(at)postgresql(dot)org
Subject: Re: How to notice column changes in trigger
Date: 2003-03-31 15:49:13
Message-ID: 3E886379.618F6AE6@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Josh Berkus wrote:
>
> Andreas,
>
> > 1) update test set a=0 -> trigger does its work
> > 2) update test set a=0, b=1, c=2 -> trigger does nothing
> > 3) update test set a=0, b=b, c=c -> trigger does nothing, but content of
> > a and b dont change either although touched
>
> > IF OLD.b=NEW.b will not work, case 3) will falsely execute the trigger
> > code.
>
> I still don't get why you'd want to do this. Can you provide are real-world
> example where there is a difference between setting B=B and not updating B?

Setting b=b and not updating it is indeed identical ... at least after
the targetlist completion in PostgreSQL. But it is different from
b=<b's-old-value>, and the fact that we cannot distinguish between these
two (inside the trigger) prevents us from skipping foreign key checks if
your fk-values haven't been touched.

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2003-03-31 17:00:32 Re: Off topic : world database
Previous Message cio198 2003-03-31 10:47:04 create view with numeric data