pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Nikolay Samokhvalov <samokhvalov@gmail.com>
To: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: ON CONFLICT with constraint name doesn't work
Date: Thu, 16 Mar 2017 21:42:04 +0200
Message-ID: <20920c13-784f-05b5-6f86-dac31dc1d970@iki.fi> (raw)
In-Reply-To: <CANNMO++7+uVMj+ZPGKB_zuRpKE0sNthy2Z-_oKSS=oE3_rN7QA@mail.gmail.com>
References: <CANNMO++7+uVMj+ZPGKB_zuRpKE0sNthy2Z-_oKSS=oE3_rN7QA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 03/16/2017 09:34 PM, Nikolay Samokhvalov wrote:
> 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.

This is by design. The docs on conflict_target says:

"Specifies which conflicts ON CONFLICT takes the alternative action on 
by choosing arbiter indexes. Either performs unique index inference, or 
names a *constraint* explicitly." (emphasis mine)

As it says, you can name a constraint explicitly. A unique index is not 
a constraint.

We debated this for a long time when the ON CONFLICT feature was being 
developed. In the end, we settled on this behavior, on the grounds that 
a constraint is a logical concept, while an index is a physical 
implementation detail. Note that the SQL standard also doesn't say 
anything about indexes, but constraints are in the standard.

- Heikki



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



view thread (12+ messages)  latest in thread

Message-ID: <20920c13-784f-05b5-6f86-dac31dc1d970@iki.fi>
Permalink:  ../20920c13-784f-05b5-6f86-dac31dc1d970@iki.fi/
Also on:    postgresql.org/message-id/20920c13-784f-05b5-6f86-dac31dc1d970@iki.fi

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: hlinnaka@iki.fi, samokhvalov@gmail.com
  Subject: Re: ON CONFLICT with constraint name doesn't work
  In-Reply-To: <20920c13-784f-05b5-6f86-dac31dc1d970@iki.fi>
  References: <CANNMO++7+uVMj+ZPGKB_zuRpKE0sNthy2Z-_oKSS=oE3_rN7QA@mail.gmail.com> <20920c13-784f-05b5-6f86-dac31dc1d970@iki.fi>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox