From: Andres Freund <andres@anarazel.de>
To: nmgjinan@126.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #13675: Problem statement “INSERT ON CONFLICT WHERE"
Date: Tue, 13 Oct 2015 03:47:29 +0200
Message-ID: <20151013014729.GC20675@awork2.anarazel.de> (raw)
In-Reply-To: <20151013014209.2784.48073@wrigleys.postgresql.org>
References: <20151013014209.2784.48073@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: andres@anarazel.de, nmgjinan@126.com
Subject: Re: BUG #13675: Problem statement “INSERT ON CONFLICT WHERE"
In-Reply-To: <20151013014729.GC20675@awork2.anarazel.de>
References: <20151013014209.2784.48073@wrigleys.postgresql.org> <20151013014729.GC20675@awork2.anarazel.de>
* 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