Re: Support for on conflict ignore returning - Mailing list pgsql-novice

From David G. Johnston
Subject Re: Support for on conflict ignore returning
Date
Msg-id CAKFQuwbJ9YdZz=UPdyoJnzCj9MkBPb7DLs+ziDAUz0Yz5YN1-Q@mail.gmail.com
Whole thread Raw
In response to Support for on conflict ignore returning  (Brian McMahon <brianmcmahon135@gmail.com>)
Responses Re: Support for on conflict ignore returning
List pgsql-novice
On Tue, Jul 30, 2024 at 8:54 AM Brian McMahon <brianmcmahon135@gmail.com> wrote:

Is there a recommended way to achieve a ON CONFLICT DO NOTHING RETURNING <column> so that conflicting columns still have information returned? Currently it seems like the only simple way to achieve this is with a NOOP update, so instead doing something like ON CONFLICT UPDATE SET name = EXCLUDED.name RETURNING <column>.

This is requested frequently.  As of now I'm not aware of anyone working on a patch to make it work.

For the described "chained DML" use case my typical advice is to not rely upon the "default" clause to produce your surrogate keys but to produce them yourself.  Also, this is one of the few areas that iterating row-by-row and doing one set of multi-table DML per transaction (or maybe savepoint...) works out reasonably well.

David J.

pgsql-novice by date:

Previous
From: Brian McMahon
Date:
Subject: Support for on conflict ignore returning
Next
From: Brian McMahon
Date:
Subject: Re: Support for on conflict ignore returning