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

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, zuming(dot)jiang(at)inf(dot)ethz(dot)ch, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries
Date: 2024-03-22 08:55:47
Message-ID: CAMbWs48UNYFE7tAGNX1LGb6WjmFyp_Y-sVwfAPgWxFUbGAuQCg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Jan 26, 2024 at 8:02 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:

> On Thu, 25 Jan 2024 at 18:14, David Rowley <dgrowleyml(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message walther 2024-03-22 09:41:39 Re: Regression tests fail with musl libc because libpq.so can't be loaded
Previous Message walther 2024-03-22 08:33:38 Re: Regression tests fail with musl libc because libpq.so can't be loaded