Re: Output clause for Upsert aka INSERT...ON CONFLICT - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Output clause for Upsert aka INSERT...ON CONFLICT
Date
Msg-id CAKFQuwZTwQSkV543G4ZmNZUmeF_eNwqAkjWvm1U_wnviLsp0xA@mail.gmail.com
Whole thread Raw
In response to Output clause for Upsert aka INSERT...ON CONFLICT  (Anand Sowmithiran <anandsowmi2@gmail.com>)
List pgsql-hackers
On Wednesday, January 26, 2022, Anand Sowmithiran <anandsowmi2@gmail.com> wrote:
The INSERT...ON CONFLICT is used for doing upserts in one of our app. 
Our app works with both MS SQL and Postgresql, based on customer needs.

Unlike the MS SQL MERGE command's OUTPUT clause that gives the $action [INSERT / UPDATE  /DELETE] that was done during the upsert, the RETURNING clause of the pgsql does not return the action done. 
We need this so that the application can use that for auditing and UI purposes.
 
Is there any workaround to get this info ?

There is not.  But I’d presume the correct trigger is fired for whichever DML is ultimately applied so maybe you have a way through that.
 
Or is there a way this enhancement can be requested in future PG versions ?


You just did.  There is nothing formal.  But presently there isn’t anyone championing improvements to this feature (just my unresearched impression, searching our public mailing lists and commitfest would let you form a researched impression).
 
David J.

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?
Next
From: vignesh C
Date:
Subject: Re: Printing backtrace of postgres processes