From: Richard Guo <guofenglinux@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: makhmutov@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17709: Regression in PG15 with window functions - "WindowFunc not found in subplan target lists"
Date: Fri, 9 Dec 2022 22:01:21 +0800
Message-ID: <CAMbWs4-4L6Emr4e-npde9h5M56wUFt6GwrPykAM9GD+W9cDfTA@mail.gmail.com> (raw)
In-Reply-To: <CAApHDvqCT4E0A1pt86sbGwWLRhdiWcuUHx8oAq1T+LqpOMskQg@mail.gmail.com>
References: <17709-4f557160e3e8ee9a@postgresql.org>
<CAMbWs48=JwUZdGRBdfSPVgovyqq=QTH8qQXoaDsfQymT3xwBNQ@mail.gmail.com>
<CAApHDvqCT4E0A1pt86sbGwWLRhdiWcuUHx8oAq1T+LqpOMskQg@mail.gmail.com>
On Fri, Dec 9, 2022 at 7:53 PM David Rowley <dgrowleyml@gmail.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'm now wondering if WindowClause.runCondition should be of type Node
> * instead of List *. I'd have imagined I should be passing the type of
> EXPRKIND_QUAL to preprocess_expression's type, but canonicalize_qual()
> does not like Lists.
I'm not sure about this. From how the runCondition is constructed in
find_window_run_conditions, it seems there is no need to canonicalize
it.
Thanks
Richard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: guofenglinux@gmail.com, dgrowleyml@gmail.com, makhmutov@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17709: Regression in PG15 with window functions - "WindowFunc not found in subplan target lists"
In-Reply-To: <CAMbWs4-4L6Emr4e-npde9h5M56wUFt6GwrPykAM9GD+W9cDfTA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox