Re: EXPLAIN(VERBOSE) to CTE with SEARCH BREADTH FIRST fails

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Subject: Re: EXPLAIN(VERBOSE) to CTE with SEARCH BREADTH FIRST fails
Date: 2021-09-07 18:31:33
Message-ID: 3208199.1631039493@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

torikoshia <torikoshia(at)oss(dot)nttdata(dot)com> 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2021-09-07 18:40:24 Re: .ready and .done files considered harmful
Previous Message Robert Haas 2021-09-07 18:30:23 Re: .ready and .done files considered harmful