Re: BUG #14343: UPSERT (ON CONFLICT) doesn't check ON CONFLICT constraint first

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Reyes(dot)R(dot)Ponce(at)gmail(dot)com
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14343: UPSERT (ON CONFLICT) doesn't check ON CONFLICT constraint first
Date: 2016-10-01 12:21:38
Message-ID: CAM3SWZTycxbGykykgiKSgREVVGDYdmrWmWpjfMiniiqA30ryaA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Sep 30, 2016 at 8:19 PM, Reyes Ponce <reyes(dot)r(dot)ponce(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Francisco Olarte 2016-10-01 15:57:00 Re: vacuumdb parallel has a deadlock detected in 9.5.4
Previous Message Michael Herold 2016-09-30 19:46:07 Re: COMMENT ON INDEX silently fails