Output clause for Upsert aka INSERT...ON CONFLICT

From: Anand Sowmithiran <anandsowmi2(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Output clause for Upsert aka INSERT...ON CONFLICT
Date: 2022-01-27 04:54:14
Message-ID: CAKbQ4s6v+Zj8WXgjNtBnmTDNHQsiGC5eeH+oRPG9ufG=Vv+tvw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 ?
Or is there a way this enhancement can be requested in future PG versions ?

thanks,
Anand.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next 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?
Previous Message Kyotaro Horiguchi 2022-01-27 04:27:36 Re: Two noncritical bugs of pg_waldump