Re: pgsql: Fix incorrect handling of join clauses pushed into parameterized

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers <pgsql-committers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: Fix incorrect handling of join clauses pushed into parameterized
Date: 2018-04-19 22:30:09
Message-ID: CAA8=A78B1=X0HtGiUquTNQZ26PW_xuiZ4qSuxfQ=udkA2Fry2w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Thu, Apr 19, 2018 at 3:49 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Fix incorrect handling of join clauses pushed into parameterized paths.
>
> In some cases a clause attached to an outer join can be pushed down into
> the outer join's RHS even though the clause is not degenerate --- this
> can happen if we choose to make a parameterized path for the RHS. If
> the clause ends up attached to a lower outer join, we'd misclassify it
> as being a "join filter" not a plain "filter" condition at that node,
> leading to wrong query results.
>
> To fix, teach extract_actual_join_clauses to examine each join clause's
> required_relids, not just its is_pushed_down flag. (The latter now
> seems vestigial, or at least in need of rethinking, but we won't do
> anything so invasive as redefining it in a bug-fix patch.)
>
> This has been wrong since we introduced parameterized paths in 9.2,
> though it's evidently hard to hit given the lack of previous reports.
> The test case used here involves a lateral function call, and I think
> that a lateral reference may be required to get the planner to select
> a broken plan; though I wouldn't swear to that. In any case, even if
> LATERAL is needed to trigger the bug, it still affects all supported
> branches, so back-patch to all.
>
> Per report from Andreas Karlsson. Thanks to Andrew Gierth for
> preliminary investigation.
>
> Discussion: https://postgr.es/m/f8128b11-c5bf-3539-48cd-234178b2314d@proxel.se
>
> Branch
> ------
> REL9_6_STABLE
>

Seems to have broken the buildfarm on 9.6.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-04-20 19:19:43 pgsql: Change more places to be less trusting of RestrictInfo.is_pushed
Previous Message Tom Lane 2018-04-19 22:29:44 pgsql: Fix broken extract_actual_join_clauses call in 9.6 postgres_fdw.