Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iaOV0-0002Id-NR for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Nov 2019 18:26:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iaOUz-00072m-AV for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Nov 2019 18:26:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iaOUy-00072P-Us for pgsql-bugs@lists.postgresql.org; Thu, 28 Nov 2019 18:26:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iaOUv-0002j6-RE for pgsql-bugs@lists.postgresql.org; Thu, 28 Nov 2019 18:26:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id xASIQXJ5024979; Thu, 28 Nov 2019 13:26:33 -0500 From: Tom Lane To: bryan.dicarlo@gmail.com cc: pgsql-bugs@lists.postgresql.org, Peter Geoghegan Subject: Re: BUG #16140: View with INSERT, DO INSTEAD, and ON CONFLICT causes an error In-reply-to: <16140-4d29cf5390118372@postgresql.org> References: <16140-4d29cf5390118372@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 27 Nov 2019 23:00:02 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24977.1574965593.1@sss.pgh.pa.us> Date: Thu, 28 Nov 2019 13:26:33 -0500 Message-ID: <24978.1574965593@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > When creating an updatable "complex" view, if an ON CONFLICT clause is > provided, an INSERT SELECT to that view will cause "ERROR: variable not > found in subplan target lists". Removing the ON CONFLICT clause eliminates > the error message. I believe the problem is that you wrote the ON CONFLICT clause incorrectly: > ON CONFLICT (slo_id, time_window, tags) DO UPDATE SET value = NEW.value You should have written "EXCLUDED.value" not "NEW.value". There is a bug here, but it's that the parser accepted this rule. I'm guessing that the parsing logic for ON CONFLICT didn't consider the possibility that NEW and OLD for a rule would already be in the range table. regards, tom lane