Re: INSERT ... ON CONFLICT error messages

From: Andres Freund <andres(at)anarazel(dot)de>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: hlinnaka <hlinnaka(at)iki(dot)fi>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Subject: Re: INSERT ... ON CONFLICT error messages
Date: 2015-05-07 18:32:18
Message-ID: 20150507183218.GH12950@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-05-07 11:16:12 -0700, Peter Geoghegan wrote:
> On Tue, May 5, 2015 at 8:52 AM, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
> > postgres=# create table foo (id int4);
> > CREATE TABLE
> > postgres=# create unique index foo_y on foo (id) where id > 0;
> > CREATE INDEX
> > postgres=# insert into foo values (-1) on conflict (id) where id > 0 do
> > nothing;
> > ERROR: inferred arbiter partial unique index's predicate does not cover
> > tuple proposed for insertion
> > DETAIL: ON CONFLICT inference clause implies that the tuple proposed for
> > insertion must be covered by the predicate of partial index "foo_y".
> >
> > I'm surprised. If the inserted value doesn't match the WHERE clause of the
> > constraint, there is clearly no conflict, so I would assume the above to
> > work without error.
>
> I'm not particularly attached to that behavior. I could revert it.

Hm. I don't really see a point in allowing it - it seems more likely to
be a mistake by the user, expecting that the insertion now works
conflict free. But I don't really care much.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-05-07 18:34:37 Re: PATCH: pgbench allow '=' in \set
Previous Message Pavel Stehule 2015-05-07 18:25:07 Re: PATCH: pgbench allow '=' in \set