[BUGS] ON CONFLICT with constraint name doesn't work - Mailing list pgsql-bugs

From Nikolay Samokhvalov
Subject [BUGS] ON CONFLICT with constraint name doesn't work
Date
Msg-id CANNMO++7+uVMj+ZPGKB_zuRpKE0sNthy2Z-_oKSS=oE3_rN7QA@mail.gmail.com
Whole thread Raw
Responses Re: [BUGS] ON CONFLICT with constraint name doesn't work
Re: [BUGS] ON CONFLICT with constraint name doesn't work
List pgsql-bugs
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@test=# create table constr(id serial, msg text);
CREATE TABLE

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

[local]:5432 nikolay@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@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@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.

pgsql-bugs by date:

Previous
From: alessandro.grassi@2ndquadrant.it
Date:
Subject: [BUGS] BUG #14591: WALs differ on a standby node,from streaming to archive_command
Next
From: Andres Freund
Date:
Subject: Re: [BUGS] ON CONFLICT with constraint name doesn't work