Thread: Conflict detection in ON CONFLICT

Conflict detection in ON CONFLICT

From
Nicolas ALBEZA
Date:
Hello,

Is there any way for a client to know if a conflict happened in an ON CONFLICT DO UPDATE query ?

Thanks !

--
Nicolas "Pause" ALBEZA

Re: Conflict detection in ON CONFLICT

From
Jeff Janes
Date:
On Wed, Jan 6, 2016 at 10:48 AM, Nicolas ALBEZA <n.albeza@gmail.com> wrote:
> Hello,
>
> Is there any way for a client to know if a conflict happened in an ON
> CONFLICT DO UPDATE query ?

Here is one way:

create table foo (x int primary key, y text);

insert into foo values (3,'insert') on conflict (x) do update set
y='update' returning y;

I don't know how to do it without leaving an extra column of cruft
behind in the table.

Cheers,

Jeff