Re: Upsert with a partial unique index constraint violation

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Tim Dawborn <tim(dot)dawborn(at)gmail(dot)com>
Cc: "Psql_General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Upsert with a partial unique index constraint violation
Date: 2016-07-12 03:43:31
Message-ID: CAH2-Wzn_=rKu4Hhf-j85qZAajmmqtZ41abKugwqKTygj6Rn-UA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 11, 2016 at 12:06 AM, Tim Dawborn <tim(dot)dawborn(at)gmail(dot)com> wrote:
> tmp=# INSERT INTO foo (a, b, c, d) VALUES (1, 2, 'four', true)
> tmp-# ON CONFLICT (a, b) WHERE d = true
> tmp-# DO UPDATE SET c = 'four' WHERE foo.a = 1 AND foo.b = 2 AND foo.d =
> true;
> ERROR: there is no unique or exclusion constraint matching the ON CONFLICT
> specification
>
> If anyone knows what I'm doing wrong and how to get this to work, or knows
> that this is not possible to achieve, I'm all ears.

That should work. Are you sure you haven't spelled it "... WHERE d IS TRUE"?

--
Peter Geoghegan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tim Dawborn 2016-07-12 03:52:36 Re: Upsert with a partial unique index constraint violation
Previous Message Adrian Klaver 2016-07-11 14:41:55 Re: error when upgrading 9.4 to 9.5 manually