| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | PALAYRET Jacques <jacques(dot)palayret(at)meteo(dot)fr> |
| Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: PostgreSQL trigger how to detect a column value explicitely modified |
| Date: | 2025-11-04 15:08:09 |
| Message-ID: | 518934.1762268889@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
PALAYRET Jacques <jacques(dot)palayret(at)meteo(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Clay Jackson (cjackson) | 2025-11-04 15:15:31 | RE: Enquiry about TDE with PgSQL |
| Previous Message | Dominique Devienne | 2025-11-04 15:00:42 | Re: PostgreSQL trigger how to detect a column value explicitely modified |