public inbox for [email protected]  
help / color / mirror / Atom feed
From: PALAYRET Jacques <[email protected]>
To: Laurenz Albe <[email protected]>
To: Tom Lane <[email protected]>
To: Dominique Devienne <[email protected]>
Cc: [email protected]
Subject: Re: PostgreSQL  trigger how to detect a column value explicitely modified
Date: Wed, 5 Nov 2025 09:24:50 +0000 (GMT)
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>

Hello,

I think you knew that I don't really want to create a function in language C to handle and test the values of the columns in the SQL query. For me, it is much easier to use the solution of the trigger " BEFORE|AFTER UPDATE OF col ".
Joke aside, I hadn't thought of that ; it is an excellent idea (simple solution).
I tested it ; it works as expected.

Thanks to people who replied.
Regards.

----- Mail original -----
De: "Laurenz Albe" <[email protected]>
À: "PALAYRET Jacques" <[email protected]>, [email protected]
Envoyé: Mardi 4 Novembre 2025 18:29:05
Objet: Re: PostgreSQL  trigger how to detect a column value explicitely modified

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






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: PostgreSQL  trigger how to detect a column value explicitely modified
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox