Re: BUG #14526: no unique or exclusion constraint matching the ON CONFLICT

From: Tiago Babo <tiago(dot)babo(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14526: no unique or exclusion constraint matching the ON CONFLICT
Date: 2017-02-07 23:21:39
Message-ID: D7999A4B-2BF0-4BDD-8C42-09F635897C13@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The only difference (so it seems), is that when it crashes, the person was created in the seconds before creating the account. When it previously exists in the persons table, it never gives the error.

Working example:

INSERT INTO accounts (type, person_id, created_at, updated_at)
VALUES (‘PersonAccount', 137842, '2017-02-07 23:17:37.61', '2017-02-07 23:17:37.61')
ON CONFLICT (type, person_id) WHERE type = ‘PersonAccount' DO UPDATE SET updated_at = EXCLUDED.updated_at RETURNING *

> On 7 Feb 2017, at 22:17, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
>
> On Tue, Feb 7, 2017 at 2:15 PM, Tiago Babo <tiago(dot)babo(at)gmail(dot)com> wrote:
>> Here is an example where it gives the error (I excluded the created_at and
>> updated_at columns in the last e-mail, but they do exist in the table):
>>
>> INSERT INTO accounts (type, person_id) VALUES ('PersonAccount', 69559,
>> '2017-02-03 12:09:27.259', '2017-02-03 12:09:27.259') ON CONFLICT (type,
>> person_id) WHERE type = 'PersonAccount' DO UPDATE SET updated_at =
>> EXCLUDED.updated_at RETURNING *
>
> Can you give an example of where it does actually work? Is there any
> discernible pattern to what each case looks like?
>
>
> --
> Peter Geoghegan

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2017-02-07 23:36:30 Re: BUG #14526: no unique or exclusion constraint matching the ON CONFLICT
Previous Message Peter Geoghegan 2017-02-07 22:17:21 Re: BUG #14526: no unique or exclusion constraint matching the ON CONFLICT