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

From Laurenz Albe
Subject Re: PostgreSQL trigger how to detect a column value explicitely modified
Date
Msg-id 425c6f01eecaf7ef85989b775fe9e3fd200f65f7.camel@cybertec.at
Whole thread Raw
In response to PostgreSQL trigger how to detect a column value explicitely modified  (PALAYRET Jacques <jacques.palayret@meteo.fr>)
Responses Re: PostgreSQL trigger how to detect a column value explicitely modified
List pgsql-general
On Tue, 2025-11-04 at 12:48 +0000, PALAYRET Jacques wrote:
> 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.
> A simple way ; I mean without analysing the SQL statement which can be very difficult according to the statement.

Unless you want to write a C trigger function you can use

  CREATE TRIGGER ... BEFORE|AFTER UPDATE OF col ON tab FOR EACH ROW ...

Then the trigger function will only be called if the SET clause of UPDATE
contains the column "col".

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: "Clay Jackson (cjackson)"
Date:
Subject: RE: Enquiry about TDE with PgSQL
Next
From: Bala M
Date:
Subject: Re: Index corruption issue after migration from RHEL 7 to RHEL 9 (PostgreSQL 11 streaming replication)