Re: BUG #17495: Regression in 15beta1 when filtering subquery including row_number window function

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, jeremyevans0(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17495: Regression in 15beta1 when filtering subquery including row_number window function
Date: 2022-05-26 03:07:27
Message-ID: CAMbWs49M0a-OXAwhNMeJPxv6RQfjsYTsaKfDr+7Cf3uMa4TDVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, May 26, 2022 at 6:33 AM David Rowley <dgrowleyml(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2022-05-26 03:17:33 Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY
Previous Message jam paydavousi 2022-05-25 22:59:27 Re: BUG #17498: Receive Failed: (error code 1) when importing any csv file from pgAdmin with no explanations