Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mNfsl-0003mA-B8 for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Sep 2021 18:31:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mNfsk-0005Gs-AO for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Sep 2021 18:31:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mNfsk-0005Gk-38 for pgsql-hackers@lists.postgresql.org; Tue, 07 Sep 2021 18:31:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mNfsh-0004c3-O2 for pgsql-hackers@postgresql.org; Tue, 07 Sep 2021 18:31:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 187IVX2O3208200; Tue, 7 Sep 2021 14:31:33 -0400 From: Tom Lane To: torikoshia cc: Pgsql Hackers , Peter Eisentraut Subject: Re: EXPLAIN(VERBOSE) to CTE with SEARCH BREADTH FIRST fails In-reply-to: <5bafa66ad529e11860339565c9e7c166@oss.nttdata.com> References: <5bafa66ad529e11860339565c9e7c166@oss.nttdata.com> Comments: In-reply-to torikoshia message dated "Tue, 07 Sep 2021 12:41:02 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3208198.1631039493.1@sss.pgh.pa.us> Date: Tue, 07 Sep 2021 14:31:33 -0400 Message-ID: <3208199.1631039493@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk torikoshia writes: > While working on [1], we found that EXPLAIN(VERBOSE) to CTE with SEARCH > BREADTH FIRST ends up ERROR. Yeah. It's failing here: * We're deparsing a Plan tree so we don't have a CTE * list. But the only place we'd see a Var directly * referencing a CTE RTE is in a CteScan plan node, and we * can look into the subplan's tlist instead. if (!dpns->inner_plan) elog(ERROR, "failed to find plan for CTE %s", rte->eref->aliasname); The problematic Var is *not* in a CteScan plan node; it's in a WorkTableScan node. It's not clear to me whether this is a bug in the planner's handling of SEARCH BREADTH FIRST, or if the plan is as-intended and ruleutils.c is failing to cope. Either way, this deserves an open item... regards, tom lane