pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix incorrect handling of join clauses pushed into parameterized
7+ messages / 2 participants
[nested] [flat]

* pgsql: Fix incorrect handling of join clauses pushed into parameterized
@ 2018-04-19 19:49 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2018-04-19 19:49 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e5d83995e9f88426b325a7ea8ce0770926dc64de

Modified Files
--------------
src/backend/optimizer/plan/createplan.c   |  3 +++
src/backend/optimizer/util/restrictinfo.c | 11 ++++++++++-
src/include/optimizer/restrictinfo.h      |  1 +
src/test/regress/expected/join.out        | 27 +++++++++++++++++++++++++++
src/test/regress/sql/join.sql             | 11 +++++++++++
5 files changed, 52 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix incorrect handling of join clauses pushed into parameterized
@ 2018-04-19 19:49 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2018-04-19 19:49 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/68fab04f7c2a07c5308e3d2957198ccd7a80ebc5

Modified Files
--------------
src/backend/optimizer/plan/createplan.c   |  3 +++
src/backend/optimizer/util/restrictinfo.c | 11 ++++++++++-
src/include/optimizer/restrictinfo.h      |  1 +
src/test/regress/expected/join.out        | 27 +++++++++++++++++++++++++++
src/test/regress/sql/join.sql             | 11 +++++++++++
5 files changed, 52 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix incorrect handling of join clauses pushed into parameterized
@ 2018-04-19 19:49 Tom Lane <tgl@sss.pgh.pa.us>
  2018-04-19 22:30 ` Re: pgsql: Fix incorrect handling of join clauses pushed into parameterized Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2018-04-19 19:49 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Details
-------
https://git.postgresql.org/pg/commitdiff/0c141fcaa7dd806752986401b25de8f665ceb3fe

Modified Files
--------------
src/backend/optimizer/plan/createplan.c   |  3 +++
src/backend/optimizer/util/restrictinfo.c | 11 ++++++++++-
src/include/optimizer/restrictinfo.h      |  1 +
src/test/regress/expected/join.out        | 27 +++++++++++++++++++++++++++
src/test/regress/sql/join.sql             | 11 +++++++++++
5 files changed, 52 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Fix incorrect handling of join clauses pushed into parameterized
  2018-04-19 19:49 pgsql: Fix incorrect handling of join clauses pushed into parameterized Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-04-19 22:30 ` Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Andrew Dunstan @ 2018-04-19 22:30 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>

On Thu, Apr 19, 2018 at 3:49 PM, Tom Lane <tgl@sss.pgh.pa.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




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix incorrect handling of join clauses pushed into parameterized
@ 2018-04-19 19:49 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2018-04-19 19:49 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e4e43a16b250abd9c4d3431d4824f7150ee74bec

Modified Files
--------------
src/backend/optimizer/plan/createplan.c   |  3 +++
src/backend/optimizer/util/restrictinfo.c | 11 ++++++++++-
src/include/optimizer/restrictinfo.h      |  1 +
src/test/regress/expected/join.out        | 27 +++++++++++++++++++++++++++
src/test/regress/sql/join.sql             | 11 +++++++++++
5 files changed, 52 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix incorrect handling of join clauses pushed into parameterized
@ 2018-04-19 19:49 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2018-04-19 19:49 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a347d5210ef0330b911e31c6249e4318d933b27b

Modified Files
--------------
src/backend/optimizer/plan/createplan.c   |  3 +++
src/backend/optimizer/util/restrictinfo.c | 11 ++++++++++-
src/include/optimizer/restrictinfo.h      |  1 +
src/test/regress/expected/join.out        | 27 +++++++++++++++++++++++++++
src/test/regress/sql/join.sql             | 11 +++++++++++
5 files changed, 52 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix incorrect handling of join clauses pushed into parameterized
@ 2018-04-19 19:49 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2018-04-19 19:49 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_3_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e1d4398c0a5bdb4a3ccbbb667a5d8c583288ac55

Modified Files
--------------
src/backend/optimizer/plan/createplan.c   |  3 +++
src/backend/optimizer/util/restrictinfo.c | 11 ++++++++++-
src/include/optimizer/restrictinfo.h      |  1 +
src/test/regress/expected/join.out        | 27 +++++++++++++++++++++++++++
src/test/regress/sql/join.sql             | 11 +++++++++++
5 files changed, 52 insertions(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2018-04-19 22:30 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19 19:49 pgsql: Fix incorrect handling of join clauses pushed into parameterized Tom Lane <tgl@sss.pgh.pa.us>
2018-04-19 19:49 pgsql: Fix incorrect handling of join clauses pushed into parameterized Tom Lane <tgl@sss.pgh.pa.us>
2018-04-19 19:49 pgsql: Fix incorrect handling of join clauses pushed into parameterized Tom Lane <tgl@sss.pgh.pa.us>
2018-04-19 22:30 ` Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
2018-04-19 19:49 pgsql: Fix incorrect handling of join clauses pushed into parameterized Tom Lane <tgl@sss.pgh.pa.us>
2018-04-19 19:49 pgsql: Fix incorrect handling of join clauses pushed into parameterized Tom Lane <tgl@sss.pgh.pa.us>
2018-04-19 19:49 pgsql: Fix incorrect handling of join clauses pushed into parameterized Tom Lane <tgl@sss.pgh.pa.us>

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