Re: BUG #17495: Regression in 15beta1 when filtering subquery including row_number window function - Mailing list pgsql-bugs

From Richard Guo
Subject Re: BUG #17495: Regression in 15beta1 when filtering subquery including row_number window function
Date
Msg-id CAMbWs49M0a-OXAwhNMeJPxv6RQfjsYTsaKfDr+7Cf3uMa4TDVw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #17495: Regression in 15beta1 when filtering subquery including row_number window function  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-bugs

On Thu, May 26, 2022 at 6:33 AM David Rowley <dgrowleyml@gmail.com> wrote:
I think the correct fix is to change remove_unused_subquery_outputs()
so it also checks the WindowClause runConditions in addition to the
rel targetlist and baserestrictinfo.

Yes, concur with that. Yesterday I played around with a similar patch
which leverages find_window_functions() to locate all the WindowFunc
nodes in runCondition expressions and then check if each WindowFunc
target entry of the subquery is contained there.
 
Maybe a better fix is to add a new Bitmapset field to WindowClause and
have find_window_run_conditions() record the attno in that field when
it appends the new runCondition to the runCondition field.
remove_unused_subquery_outputs() can just bms_add_members that field
to attrs_used.  This just means having to add a field to WindowClause
post-beta.  Is that going to be a problem?

This is even better if we can keep the attnos somewhere for the window
quals that are pushed down to runConditions. Like Tom proposed, maybe
PlannerInfo is a more proper place.

Thanks
Richard

pgsql-bugs by date:

Previous
From: jam paydavousi
Date:
Subject: Re: BUG #17498: Receive Failed: (error code 1) when importing any csv file from pgAdmin with no explanations
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY