pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix generation of EC join conditions at the wrong plan level.
4+ messages / 1 participants
[nested] [flat]

* pgsql: Fix generation of EC join conditions at the wrong plan level.
@ 2024-04-16 15:23  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-04-16 15:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix generation of EC join conditions at the wrong plan level.

get_baserel_parampathinfo previously assumed without checking that
the results of generate_join_implied_equalities "necessarily satisfy
join_clause_is_movable_into".  This turns out to be wrong in the
presence of outer joins, because the generated clauses could include
Vars that mustn't be evaluated below a relevant outer join.  That
led to applying clauses at the wrong plan level and possibly getting
incorrect query results.  We must check each clause's nullable_relids,
and really the right thing to do is test join_clause_is_movable_into.

However, trying to fix it that way exposes an oversight in
equivclass.c: it wasn't careful about marking join clauses for
appendrel children with the correct clause_relids.  That caused the
modified get_baserel_parampathinfo code to reject some clauses it
still needs to accept.  (See parallel commit for HEAD/v16 for more
commentary about that.)

Per bug #18429 from Benoît Ryder.  This misbehavior existed for
a long time before commit 2489d76c4, so patch v12-v15 this way.

Discussion: https://postgr.es/m/18429-8982d4a348cc86c6@postgresql.org

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5aacfa64e5dae1a26a5ad5192877683695de2e77

Modified Files
--------------
src/backend/optimizer/path/equivclass.c | 15 +++++++++++++++
src/backend/optimizer/util/relnode.c    | 25 ++++++++++++++++++-------
src/test/regress/expected/join.out      | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql           | 19 +++++++++++++++++++
4 files changed, 83 insertions(+), 7 deletions(-)



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

* pgsql: Fix generation of EC join conditions at the wrong plan level.
@ 2024-04-16 15:23  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-04-16 15:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix generation of EC join conditions at the wrong plan level.

get_baserel_parampathinfo previously assumed without checking that
the results of generate_join_implied_equalities "necessarily satisfy
join_clause_is_movable_into".  This turns out to be wrong in the
presence of outer joins, because the generated clauses could include
Vars that mustn't be evaluated below a relevant outer join.  That
led to applying clauses at the wrong plan level and possibly getting
incorrect query results.  We must check each clause's nullable_relids,
and really the right thing to do is test join_clause_is_movable_into.

However, trying to fix it that way exposes an oversight in
equivclass.c: it wasn't careful about marking join clauses for
appendrel children with the correct clause_relids.  That caused the
modified get_baserel_parampathinfo code to reject some clauses it
still needs to accept.  (See parallel commit for HEAD/v16 for more
commentary about that.)

Per bug #18429 from Benoît Ryder.  This misbehavior existed for
a long time before commit 2489d76c4, so patch v12-v15 this way.

Discussion: https://postgr.es/m/18429-8982d4a348cc86c6@postgresql.org

Branch
------
REL_13_STABLE

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

Modified Files
--------------
src/backend/optimizer/path/equivclass.c | 15 +++++++++++++++
src/backend/optimizer/util/relnode.c    | 25 ++++++++++++++++++-------
src/test/regress/expected/join.out      | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql           | 19 +++++++++++++++++++
4 files changed, 83 insertions(+), 7 deletions(-)



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

* pgsql: Fix generation of EC join conditions at the wrong plan level.
@ 2024-04-16 15:23  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-04-16 15:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix generation of EC join conditions at the wrong plan level.

get_baserel_parampathinfo previously assumed without checking that
the results of generate_join_implied_equalities "necessarily satisfy
join_clause_is_movable_into".  This turns out to be wrong in the
presence of outer joins, because the generated clauses could include
Vars that mustn't be evaluated below a relevant outer join.  That
led to applying clauses at the wrong plan level and possibly getting
incorrect query results.  We must check each clause's nullable_relids,
and really the right thing to do is test join_clause_is_movable_into.

However, trying to fix it that way exposes an oversight in
equivclass.c: it wasn't careful about marking join clauses for
appendrel children with the correct clause_relids.  That caused the
modified get_baserel_parampathinfo code to reject some clauses it
still needs to accept.  (See parallel commit for HEAD/v16 for more
commentary about that.)

Per bug #18429 from Benoît Ryder.  This misbehavior existed for
a long time before commit 2489d76c4, so patch v12-v15 this way.

Discussion: https://postgr.es/m/18429-8982d4a348cc86c6@postgresql.org

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/backend/optimizer/path/equivclass.c | 15 +++++++++++++++
src/backend/optimizer/util/relnode.c    | 25 ++++++++++++++++++-------
src/test/regress/expected/join.out      | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql           | 19 +++++++++++++++++++
4 files changed, 83 insertions(+), 7 deletions(-)



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

* pgsql: Fix generation of EC join conditions at the wrong plan level.
@ 2024-04-16 15:23  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-04-16 15:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix generation of EC join conditions at the wrong plan level.

get_baserel_parampathinfo previously assumed without checking that
the results of generate_join_implied_equalities "necessarily satisfy
join_clause_is_movable_into".  This turns out to be wrong in the
presence of outer joins, because the generated clauses could include
Vars that mustn't be evaluated below a relevant outer join.  That
led to applying clauses at the wrong plan level and possibly getting
incorrect query results.  We must check each clause's nullable_relids,
and really the right thing to do is test join_clause_is_movable_into.

However, trying to fix it that way exposes an oversight in
equivclass.c: it wasn't careful about marking join clauses for
appendrel children with the correct clause_relids.  That caused the
modified get_baserel_parampathinfo code to reject some clauses it
still needs to accept.  (See parallel commit for HEAD/v16 for more
commentary about that.)

Per bug #18429 from Benoît Ryder.  This misbehavior existed for
a long time before commit 2489d76c4, so patch v12-v15 this way.

Discussion: https://postgr.es/m/18429-8982d4a348cc86c6@postgresql.org

Branch
------
REL_12_STABLE

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

Modified Files
--------------
src/backend/optimizer/path/equivclass.c | 15 +++++++++++++++
src/backend/optimizer/util/relnode.c    | 25 ++++++++++++++++++-------
src/test/regress/expected/join.out      | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql           | 19 +++++++++++++++++++
4 files changed, 83 insertions(+), 7 deletions(-)



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


end of thread, other threads:[~2024-04-16 15:23 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 15:23 pgsql: Fix generation of EC join conditions at the wrong plan level. Tom Lane <tgl@sss.pgh.pa.us>
2024-04-16 15:23 pgsql: Fix generation of EC join conditions at the wrong plan level. Tom Lane <tgl@sss.pgh.pa.us>
2024-04-16 15:23 pgsql: Fix generation of EC join conditions at the wrong plan level. Tom Lane <tgl@sss.pgh.pa.us>
2024-04-16 15:23 pgsql: Fix generation of EC join conditions at the wrong plan level. 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