Re: BUG #17709: Regression in PG15 with window functions - "WindowFunc not found in subplan target lists"

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: makhmutov(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17709: Regression in PG15 with window functions - "WindowFunc not found in subplan target lists"
Date: 2022-12-10 06:29:33
Message-ID: CAApHDvqmsWC55anRE8HZMJ95qJDEDY3zZsjup07N-5OShCK2mA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sat, 10 Dec 2022 at 03:01, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
>
>
> On Fri, Dec 9, 2022 at 7:53 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>>
>> The additional thing that seems to cause the reported error is that
>> once the subquery is pulled up, the run condition also needs a round
>> of constant folding done. See subquery_planner() around line 827. The
>> problem is that the target list's WindowFunc ends up with count(1)
>> over .., but the run condition's one is left as count(case 1 when 1
>> then 1 else null end), which preprocess_expression() will fold into
>> the same as what's in the target list.
>
>
> Yes exactly. That's what we also have to do. I was debugging with a
> simplified version of the query with the WindowFunc as count(t1.a) over
> (...) and did not realize constant folding is also needed for the
> runCondition.

I made a few small minor adjustments and pushed the patch.

Thanks for the report Alexey and to Richard for looking into this.

David

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2022-12-11 13:36:15 BUG #17711: Login failed
Previous Message Tom Lane 2022-12-10 02:13:09 Re: BUG #17710: Slow queries (100% CPU) after auto-vacuum