Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Guo <guofenglinux@gmail.com>, zuming.jiang@inf.ethz.ch, pgsql-bugs@lists.postgresql.org
Date: 2024-04-29T21:39:46Z
Lists: pgsql-bugs

Attachments

On Fri, 26 Apr 2024 at 03:39, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> It'd be easier to review this if you presented it as two independent
> patches, one for HEAD and one for the back branches.

The attached v2 is the same patch as earlier and is intended for <= v16.

> The fact that you had to use a cheesy "eval_const_expressions(NULL,
> ..." call in 0001 demonstrates that it was a mistake to not include
> PlannerInfo in SupportRequestWFuncMonotonic, as every other planner-
> invoked support request has.  I realize that we can't change that
> in back branches, and that it's no longer immediately necessary
> in HEAD either after 0002.  But let's learn from experience and
> add it to the struct while we're here.

The correct PlannerInfo to set here would be the one that the
WindowFunc belongs to.  The problem is that this code is called from
set_subquery_pathlist before the rel->subroot = subquery_planner. i.e
we've no PlannerInfo to set.  Maybe it's worth doing this for
SupportRequestOptimizeWindowClause as a separate patch.

> catversion bumps are not a problem at this stage

The attached v3 is a separate patch for v17 only.

David

Commits

  1. Fix query pullup issue with WindowClause runCondition

  2. Make documentation builds reproducible

  3. Teach planner about more monotonic window functions