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

From: tiago(dot)babo(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14526: no unique or exclusion constraint matching the ON CONFLICT
Date: 2017-02-02 14:07:01
Message-ID: 20170202140701.1401.31196@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14526
Logged by: Tiago Babo
Email address: tiago(dot)babo(at)gmail(dot)com
PostgreSQL version: 9.5.5
Operating system: Ubuntu 14.04.2 LTS
Description:

I'm getting the following error when doing the following type of insert:

Errpr:
SQL execution failed (Reason: ERROR: there is no unique or exclusion
constraint matching the ON CONFLICT specification)

Query:
INSERT INTO accounts (type, person_id) VALUES ('PersonAccount', 1) ON
CONFLICT (type, person_id) WHERE type = 'PersonAccount' DO UPDATE SET
updated_at = EXCLUDED.updated_at RETURNING *

I also have an unique INDEX:

CREATE UNIQUE INDEX uniq_person_accounts ON accounts USING btree (type,
person_id) WHERE ((type)::text = 'PersonAccount'::text);

The thing is that sometimes it works, but not every time. I "randomly" get
that exception, which is really strange. It seems that it can't access that
INDEX or it doesn't know it exists.

Any suggestion?

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-02-02 14:27:32 Re: BUG #14525: select <function>.* takes extremely long time
Previous Message Pavel Stehule 2017-02-02 12:13:10 Re: BUG #14525: select <function>.* takes extremely long time