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 1icfyC-0007lN-MN for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Dec 2019 01:30:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icfyB-0002eK-5z for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Dec 2019 01:30:15 +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 1icfyA-0002eD-Qe for pgsql-bugs@lists.postgresql.org; Thu, 05 Dec 2019 01:30:14 +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 1icfy8-0006Rd-BJ for pgsql-bugs@lists.postgresql.org; Thu, 05 Dec 2019 01:30:13 +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 xB51U8u7011971; Wed, 4 Dec 2019 20:30:08 -0500 From: Tom Lane To: Peter Geoghegan cc: bryan.dicarlo@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #16140: View with INSERT, DO INSTEAD, and ON CONFLICT causes an error In-reply-to: References: <16140-4d29cf5390118372@postgresql.org> <24978.1574965593@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Wed, 04 Dec 2019 17:10:20 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11969.1575509408.1@sss.pgh.pa.us> Date: Wed, 04 Dec 2019 20:30:08 -0500 Message-ID: <11970.1575509408@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Geoghegan writes: > On Thu, Nov 28, 2019 at 10:26 AM Tom Lane wrote: >> 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. > I must admit that I have zero recollection of this aspect of the ON > CONFLICT work. Do you think that this would be difficult to fix? Probably not terribly so, but I haven't looked at the code. Partly it'd depend on how good an error message we want (e.g., whether there's to be an error cursor). The likely-simplest fix would involve making sure the rangetable has only the two useful entries, so you'd get some sort of "unknown table name" error for mistakes of this sort. It'd be more useful to say something like "only and EXCLUDED can be referenced in ON CONFLICT"; but getting to that might be more trouble than it's worth. regards, tom lane