ON CONFLICT with constraint name doesn't work

From: Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: ON CONFLICT with constraint name doesn't work
Date: 2017-03-16 19:34:49
Message-ID: CANNMO++7+uVMj+ZPGKB_zuRpKE0sNthy2Z-_oKSS=oE3_rN7QA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi,

I'm trying to explicitly use the constraint name of my UNIQUE INDEX but it
doesn't work (Postgres 9.6.2):

[local]:5432 nikolay(at)test=# create table constr(id serial, msg text);
CREATE TABLE

[local]:5432 nikolay(at)test=# create unique index i_constr_msg on constr
using btree(md5(msg));
CREATE INDEX

[local]:5432 nikolay(at)test=# insert into constr (msg) values ('hoho') on
conflict on constraint i_constr_msg do nothing;
ERROR: constraint "i_constr_msg" for table "constr" does not exist

[local]:5432 nikolay(at)test=# \d constr
Table "public.constr"
Column | Type | Modifiers
--------+---------+-----------------------------------------------------
id | integer | not null default nextval('constr_id_seq'::regclass)
msg | text |
Indexes:
"i_constr_msg" UNIQUE, btree (md5(msg))

This works:
[local]:5432 nikolay(at)test=# insert into constr (msg) values ('hoho') on
conflict (md5(msg)) do nothing;
INSERT 0 1

I don't see anything in the current docs
https://www.postgresql.org/docs/9.6/static/sql-insert.html saying that I
cannot use the unique index' name here. So it definitely looks like a bug.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2017-03-16 19:40:50 Re: ON CONFLICT with constraint name doesn't work
Previous Message alessandro.grassi 2017-03-16 17:05:13 BUG #14591: WALs differ on a standby node, from streaming to archive_command

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-03-16 19:40:50 Re: ON CONFLICT with constraint name doesn't work
Previous Message Joshua D. Drake 2017-03-16 19:18:32 temp_buffers vs temp vs local and explain