Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b4wtM-0004Zv-MT for pgsql-hackers@arkaria.postgresql.org; Mon, 23 May 2016 20:56:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b4wtM-00082A-99 for pgsql-hackers@arkaria.postgresql.org; Mon, 23 May 2016 20:56:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b4wtK-00081T-Iz for pgsql-hackers@postgresql.org; Mon, 23 May 2016 20:55:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b4wtH-0006PQ-86 for pgsql-hackers@postgresql.org; Mon, 23 May 2016 20:55:57 +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 u4NKtnKD022867; Mon, 23 May 2016 16:55:49 -0400 From: Tom Lane To: Peter Geoghegan cc: Thomas Alton , Pg Hackers Subject: Re: Re: [BUGS] BUG #14153: Unrecognized node type error when upsert is present in recursive CTE In-reply-to: References: <20160521232802.22598.13537@wrigleys.postgresql.org> <18383.1464031327@sss.pgh.pa.us> <20096.1464032918@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Mon, 23 May 2016 13:43:49 -0700" Date: Mon, 23 May 2016 16:55:49 -0400 Message-ID: <22866.1464036949@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Peter Geoghegan writes: > On Mon, May 23, 2016 at 12:48 PM, Tom Lane wrote: >> Also, related to this complaint though not this patch, it's disturbing >> that this oversight wasn't detected long ago. My first thought was to add >> some conditionally-compiled debugging code that just performs a no-op >> traverse of every raw parse tree produced by the grammar. However that >> doesn't work because raw_expression_tree_walker doesn't promise to support >> everything, only DML statements. Thoughts? > Why couldn't the debug code be executed conditionally, too? Since > raw_expression_tree_walker() promises to work for "SelectStmt and > everything that could appear under it", I don't think it would be > difficult to find a choke point for that. Perhaps there is some > subtlety I've missed, since what I propose seems too obvious. FWIW, I > don't think it would much matter if this debug code was not reliably > executed for every possible SelectStmt. Just limiting it to top-level > SelectStmts would have easily caught this bug. Um, I think not --- you need the case cited by the OP, namely an INSERT ON CONFLICT in a CTE in a SelectStmt. If we'd had any of those in the regression tests, we'd have found the bug, but we don't; and it's not an obvious combination to try. We would have found it if there were a reason to run raw_expression_tree_walker() on bare InsertStmts, but currently there is not. Possibly we could get adequate coverage by inserting the debug code into the first four switch cases in transformStmt(). If that sounds like a plausible choke-point, the next question is what to use to enable the debug test. I propose "#ifdef COPY_PARSE_PLAN_TREES" since that enables similar sanity checking for other parts of backend/nodes/, and we do have at least one buildfarm member using it. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers