Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zlogm-0003xw-2t for pgsql-bugs@arkaria.postgresql.org; Tue, 13 Oct 2015 01:47:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zlogk-0008Cx-Ne for pgsql-bugs@arkaria.postgresql.org; Tue, 13 Oct 2015 01:47:38 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zlogj-0008Cg-Vc for pgsql-bugs@postgresql.org; Tue, 13 Oct 2015 01:47:38 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Zlogg-0007kF-Qv for pgsql-bugs@postgresql.org; Tue, 13 Oct 2015 01:47:36 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 6472C860003; Tue, 13 Oct 2015 03:47:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p54895CFC.dip0.t-ipconnect.de [84.137.92.252]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 6349D860001; Tue, 13 Oct 2015 03:47:30 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id E870A10317A; Tue, 13 Oct 2015 03:47:29 +0200 (CEST) Date: Tue, 13 Oct 2015 03:47:29 +0200 From: Andres Freund To: nmgjinan@126.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13675: Problem =?utf-8?Q?s?= =?utf-8?Q?tatement_=E2=80=9CINSERT?= ON CONFLICT WHERE" Message-ID: <20151013014729.GC20675@awork2.anarazel.de> References: <20151013014209.2784.48073@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151013014209.2784.48073@wrigleys.postgresql.org> X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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