Re: Output clause for Upsert aka INSERT...ON CONFLICT

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Anand Sowmithiran <anandsowmi2(at)gmail(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Output clause for Upsert aka INSERT...ON CONFLICT
Date: 2022-01-27 05:07:54
Message-ID: CAKFQuwZTwQSkV543G4ZmNZUmeF_eNwqAkjWvm1U_wnviLsp0xA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday, January 26, 2022, Anand Sowmithiran <anandsowmi2(at)gmail(dot)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
> <https://docs.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql?view=sql-server-ver15#output_clause>
> [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.

In response to

Browse pgsql-hackers by date

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