pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix self-join removal to update bare Var references in join clau 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix self-join removal to update bare Var references in join clau @ 2026-03-20 13:46 Alexander Korotkov <akorotkov@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Alexander Korotkov @ 2026-03-20 13:46 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix self-join removal to update bare Var references in join clauses Self-join removal failed to update Var nodes when the join clause was a bare Var (e.g., ON t1.bool_col) rather than an expression containing Vars. ChangeVarNodesWalkExpression() used expression_tree_walker(), which descends into child nodes but does not process the top-level node itself. When a bare Var referencing the removed relation appeared as the clause, its varno was left unchanged, leading to "no relation entry for relid N" errors. Fix by calling ChangeVarNodes_walker() directly instead of expression_tree_walker(), so the top-level node is also processed. Bug: #19435 Reported-by: Hang Ammmkilo <ammmkilo@163.com> Author: Andrei Lepikhov <lepihov@gmail.com> Co-authored-by: Tender Wang <tndrwang@gmail.com> Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/19435-3cc1a87f291129f1%40postgresql.org Backpatch-through: 18 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/07b7a964d368e0618e1e1c788f3b998b4e571427 Modified Files -------------- src/backend/rewrite/rewriteManip.c | 4 +--- src/test/regress/expected/join.out | 16 ++++++++++++++++ src/test/regress/sql/join.sql | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix self-join removal to update bare Var references in join clau @ 2026-03-20 13:47 Alexander Korotkov <akorotkov@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Alexander Korotkov @ 2026-03-20 13:47 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix self-join removal to update bare Var references in join clauses Self-join removal failed to update Var nodes when the join clause was a bare Var (e.g., ON t1.bool_col) rather than an expression containing Vars. ChangeVarNodesWalkExpression() used expression_tree_walker(), which descends into child nodes but does not process the top-level node itself. When a bare Var referencing the removed relation appeared as the clause, its varno was left unchanged, leading to "no relation entry for relid N" errors. Fix by calling ChangeVarNodes_walker() directly instead of expression_tree_walker(), so the top-level node is also processed. Bug: #19435 Reported-by: Hang Ammmkilo <ammmkilo@163.com> Author: Andrei Lepikhov <lepihov@gmail.com> Co-authored-by: Tender Wang <tndrwang@gmail.com> Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/19435-3cc1a87f291129f1%40postgresql.org Backpatch-through: 18 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e8b9d6497469dadb3c2f3765dfeed7432af77704 Modified Files -------------- src/backend/rewrite/rewriteManip.c | 4 +--- src/test/regress/expected/join.out | 16 ++++++++++++++++ src/test/regress/sql/join.sql | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-03-20 13:47 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-03-20 13:46 pgsql: Fix self-join removal to update bare Var references in join clau Alexander Korotkov <akorotkov@postgresql.org> 2026-03-20 13:47 pgsql: Fix self-join removal to update bare Var references in join clau Alexander Korotkov <akorotkov@postgresql.org>
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