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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [BUGS] BUG #14526: no unique or exclusion constraint matching the ON CONFLICT
Дата
Msg-id 14575.1486493671@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [BUGS] BUG #14526: no unique or exclusion constraint matching theON CONFLICT  (Tiago Babo <tiago.babo@gmail.com>)
Ответы Re: [BUGS] BUG #14526: no unique or exclusion constraint matching theON CONFLICT  (Peter Geoghegan <pg@bowt.ie>)
Re: [BUGS] BUG #14526: no unique or exclusion constraint matching theON CONFLICT  (Tiago Babo <tiago.babo@gmail.com>)
Список pgsql-bugs
Tiago Babo <tiago.babo@gmail.com> writes:
> 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)

So according to that, you *don't* have a unique index over (type, person_id).
(A sufficiently clever person might realize that the partial index on
person_id would serve in this instance, but I do not expect that Postgres
would figure that out.)

That makes the question less about why it fails and more about why it
seems to sometimes work.  It shouldn't, at least not with this set of
indexes and this query.

            regards, tom lane


--
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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [BUGS] BUG #14534: renaming table error
Следующее
От: Andres Freund
Дата:
Сообщение: Re: [BUGS] backend_flush_after bytes/pages