Re: BUG #14343: UPSERT (ON CONFLICT) doesn't check ON CONFLICT constraint first - Mailing list pgsql-bugs

From Peter Geoghegan
Subject Re: BUG #14343: UPSERT (ON CONFLICT) doesn't check ON CONFLICT constraint first
Date
Msg-id CAM3SWZTycxbGykykgiKSgREVVGDYdmrWmWpjfMiniiqA30ryaA@mail.gmail.com
Whole thread Raw
In response to Re: BUG #14343: UPSERT (ON CONFLICT) doesn't check ON CONFLICT constraint first  (Reyes Ponce <reyes.r.ponce@gmail.com>)
Responses Re: BUG #14343: UPSERT (ON CONFLICT) doesn't check ON CONFLICT constraint first
List pgsql-bugs
On Fri, Sep 30, 2016 at 8:19 PM, Reyes Ponce <reyes.r.ponce@gmail.com> wrote:
> Any chance you guys will do a
>
> UPDATE ... ON MISSING... DO INSERT...
>
> version as I expect in that case it would be implemented closer to the
> functionality you get implementing upsert with a CTE (and how upsert in
> most NoSql DB works (i.e. doesn't impose more restrictions than update
> in the update case)) which would cover far more use cases than the
> current design of INSERT... ON CONFLICT... DO UPDATE...?

I don't think that that makes sense. If you know ahead of time that
the INSERT path will definitely throw an error, you're either relying
on that path never being taken, in which case you should just use a
plain UPDATE, or you have a bug in your application code, in which
case you should be glad to have it surfaced sooner rather than later.

--
Peter Geoghegan

pgsql-bugs by date:

Previous
From: Michael Herold
Date:
Subject: Re: COMMENT ON INDEX silently fails
Next
From: Francisco Olarte
Date:
Subject: Re: vacuumdb parallel has a deadlock detected in 9.5.4