Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, zuming.jiang@inf.ethz.ch, pgsql-bugs@lists.postgresql.org
Date: 2024-03-22T08:55:47Z
Lists: pgsql-bugs
On Fri, Jan 26, 2024 at 8:02 PM David Rowley <dgrowleyml@gmail.com> wrote: > On Thu, 25 Jan 2024 at 18:14, David Rowley <dgrowleyml@gmail.com> wrote: > > If WindowFunc allowed a list of a new struct called WindowRunCondition > > with fields "otherarg", "opno", "collation", "wfunc_left" then we > > could construct the OpExpr later either in createplan.c or setrefs.c. > > The EXPLAIN version of that OpExpr could have the WindowFunc and the > > non-EXPLAIN version would have the Var. > > Just to assist the discussion here I've drafted a patch along the > lines of the above. See attached > > If you think this idea has merit I can try and turn it into something > committable for master. This idea seems reasonable to me. Now the runCondition is constructed in create_one_window_path(), where the subquery has been through preprocessing and therefore the WindowFunc's arg has been replaced with a Param due to the pullup of the lower subquery and the expansion of SubLinks to SubPlans. This fixes the problem reported here. Thanks Richard
Commits
-
Fix query pullup issue with WindowClause runCondition
- 7d2c7f08d9c5 17.0 landed
-
Make documentation builds reproducible
- b0f0a9432d0b 17.0 cited
-
Teach planner about more monotonic window functions
- 456fa635a909 16.0 cited