Re: BUG #13675: Problem statement “INSERT ON CONFLICT WHERE" - Mailing list pgsql-bugs

From Andres Freund
Subject Re: BUG #13675: Problem statement “INSERT ON CONFLICT WHERE"
Date
Msg-id 20151013014729.GC20675@awork2.anarazel.de
Whole thread Raw
In response to BUG #13675: Problem statement “INSERT ON CONFLICT WHERE"  (nmgjinan@126.com)
List pgsql-bugs
On 2015-10-13 01:42:09 +0000, nmgjinan@126.com wrote:
> postgres=# insert into distributors values (1,'hgdb')
> postgres-# on conflict (did) where is_active do update set
> dname=EXCLUDED.dname;
> INSERT 0 1
> postgres=# select * from distributors ;
>  did | dname | is_active
> -----+-------+-----------
>    2 | bbb   | t
>    1 | hgdb  | f
> (2 rows)
>
> postgres=#
>
> Why, when the where condition is true or false, the fields are change?

The WHERE above is parsed as parsed as the ON CONFLICT clause - where
it's just for specifying partial indexes and such. Put the WHERE after
the DO UPDATE and you'll be good.

Greetings,

Andres Freund



pgsql-bugs by date:

Previous
From: nmgjinan@126.com
Date:
Subject: BUG #13675: Problem statement “INSERT ON CONFLICT WHERE"
Next
From: postgresql@zr40.nl
Date:
Subject: BUG #13674: psql: \i from a script run through \e misparses SQL as \i arguments