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

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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 05:38:15
Message-ID: CAApHDvoT4CWqzhU8i1R51i+Kmot6xS7iffU0neg73HW-1ACovA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, 26 May 2022 at 16:34, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> On Thu, May 26, 2022 at 12:13 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
>>
>>
>> On Thu, May 26, 2022 at 11:47 AM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>>>
>>> The problem is that the qual pushdown stuff all happens in
>>> set_subquery_pathlist() before we call subquery_planner() for the
>>> subquery. We don't yet have a PlannerInfo made for the subquery when
>>> we call check_and_push_window_quals(). We don't really have any other
>>> means to communicate to subquery_planner() what the run conditions are
>>> for the given Query object. Plus, we *do* really need to know what the
>>> runConditions are before we call subquery_planner() so that those
>>> conditions can be properly tagged onto WindowAggPaths. I don't really
>>> think it would be right to pluck those from the PlannerInfo when we
>>> later call create_plan(). That wouldn't leave us any opportunity to do
>>> any costing related stuff with run conditions if we decide to do that
>>> later.
>>
>>
>> The remove_unused_subquery_outputs() also happens before we call
>> subquery_planner() for the subquery. Cann't we just store the attnos
>> used in window quals that are pushed down to runConditions in the
>> PlannerInfo of the upper query?
>
>
> Ah, your point is to move runConditions also out of WindowClause and
> store them in PlannerInfo, right? That's indeed not an easy job.

Yeah, I was aiming for a way to have it so the planner didn't
vandalise WindowClause.

I've attached a patch which fixes the bug and does not require any
further modifications to WindowClause.

David

Attachment Content-Type Size
dont_remove_subquery_columns_used_by_wclause_runconditions_v2.patch text/plain 7.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Noah Misch 2022-05-26 05:50:47 Re: Extension pg_trgm, permissions and pg_dump order
Previous Message Петър Славов 2022-05-26 05:29:11 Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY