Re: PostgreSQL trigger how to detect a column value explicitely modified - Mailing list pgsql-general

From Tom Lane
Subject Re: PostgreSQL trigger how to detect a column value explicitely modified
Date
Msg-id 518934.1762268889@sss.pgh.pa.us
Whole thread Raw
In response to PostgreSQL trigger how to detect a column value explicitely modified  (PALAYRET Jacques <jacques.palayret@meteo.fr>)
List pgsql-general
PALAYRET Jacques <jacques.palayret@meteo.fr> writes:
> In a trigger body, is there a simple way to know if a column value has been explicitely modified ?
> Explicitely modified ; in others words, typically indicated in the SET clause of the UPDATE.

I believe that an ON UPDATE trigger coded in C can access a bitmapset
that shows which column(s) are targeted in the SET clause; but we've
not exposed that to PL/pgSQL or other higher-level languages.

There are of course a bunch of definitional issues.  Should
"UPDATE ... SET x = x" count as an update?  What if some earlier
(... or later ...) BEFORE trigger changes a column?  We don't
provide any help for those cases either.

I think most people settle for testing "OLD.col IS DISTINCT FROM
NEW.col", which you could argue is a good operational definition
of whether the column changed.

            regards, tom lane



pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: Re: PostgreSQL trigger how to detect a column value explicitely modified
Next
From: "Clay Jackson (cjackson)"
Date:
Subject: RE: Enquiry about TDE with PgSQL