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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: torikoshia <torikoshia@oss.nttdata.com>
Cc: Pgsql Hackers <pgsql-hackers@postgresql.org>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Date: 2021-09-07T18:31:33Z
Lists: pgsql-hackers
torikoshia <torikoshia@oss.nttdata.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



Commits

  1. Fix EXPLAIN of SEARCH BREADTH FIRST queries some more.

  2. Fix EXPLAIN to handle SEARCH BREADTH FIRST queries.

  3. Message style improvements