[BUGS] BUG #14526: no unique or exclusion constraint matching the ON CONFLICT - Mailing list pgsql-bugs

From tiago.babo@gmail.com
Subject [BUGS] BUG #14526: no unique or exclusion constraint matching the ON CONFLICT
Date
Msg-id 20170202140701.1401.31196@wrigleys.postgresql.org
Whole thread Raw
Responses Re: [BUGS] BUG #14526: no unique or exclusion constraint matching theON CONFLICT  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      14526
Logged by:          Tiago Babo
Email address:      tiago.babo@gmail.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?


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: [BUGS] BUG #14525: select .* takes extremely long time
Next
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #14525: select .* takes extremely long time