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: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14526: no unique or exclusion constraint matching the ON CONFLICT
Date: 2017-02-07 17:25:43
Message-ID: 166D0A9D-162D-4216-9490-3163533166C1@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Here it goes:

Table "public.accounts"
Column | Type | Modifiers | Storage | Stats target | Description
----------------------------------+-----------------------------+-------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('accounts_id_seq'::regclass) | plain | |
type | character varying | | extended | |
identifier | character varying | | extended | |
person_id | integer | | plain | |
business_id | integer | | plain | |
Indexes:
"accounts_pkey" PRIMARY KEY, btree (id)
"index_accounts_on_type_and_identifier" UNIQUE, btree (type, identifier)
"uniq_bank_accounts" UNIQUE, btree (type, identifier) WHERE type::text = 'BankAccount'::text
"uniq_business_accounts" UNIQUE, btree (type, business_id) WHERE type::text = 'BusinessAccount'::text
"uniq_person_accounts" UNIQUE, btree (person_id) WHERE type::text = 'PersonAccount'::text
"index_accounts_on_business_id" btree (business_id)
"index_accounts_on_person_id" btree (person_id)
Foreign-key constraints:
"fk_rails_156241f05a" FOREIGN KEY (business_id) REFERENCES businesses(id)
"fk_rails_777d10a224" FOREIGN KEY (person_id) REFERENCES persons(id)

> On 7 Feb 2017, at 09:03, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
>
> On Thu, Feb 2, 2017 at 6:07 AM, <tiago(dot)babo(at)gmail(dot)com> wrote:
>> 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);
>
> Can you show the table definition? From psql, "\d+ accounts"
>
>
> --
> Peter Geoghegan

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Дилян Палаузов 2017-02-07 18:40:45 backend_flush_after bytes/pages
Previous Message Tom Lane 2017-02-07 16:40:01 Re: BUG #14524: Commands compare with nested subquery expressions fail with "should not reference subplan var"