Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries - Mailing list pgsql-bugs

From Richard Guo
Subject Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries
Date
Msg-id CAMbWs48UNYFE7tAGNX1LGb6WjmFyp_Y-sVwfAPgWxFUbGAuQCg@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries  (David Rowley <dgrowleyml@gmail.com>)
List 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

pgsql-bugs by date:

Previous
From: walther@technowledgy.de
Date:
Subject: Re: Regression tests fail with musl libc because libpq.so can't be loaded
Next
From: walther@technowledgy.de
Date:
Subject: Re: Regression tests fail with musl libc because libpq.so can't be loaded