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
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/18/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/18/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.