On 2015-05-07 11:16:12 -0700, Peter Geoghegan wrote:
> On Tue, May 5, 2015 at 8:52 AM, Heikki Linnakangas <hlinnaka@iki.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