public inbox for [email protected]help / color / mirror / Atom feed
pgsql: Fix replace_property_refs() ignoring the root of expression tree 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix replace_property_refs() ignoring the root of expression tree @ 2026-07-08 08:08 Peter Eisentraut <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Peter Eisentraut @ 2026-07-08 08:08 UTC (permalink / raw) To: [email protected] Fix replace_property_refs() ignoring the root of expression tree replace_property_refs() called expression_tree_mutator() with the root of the expression tree as the input node. But expression_tree_mutator() does not call the mutator function on the root node, so the root node remains unchanged. If the root node is a property reference or a lateral reference -- the two node kinds that replace_property_refs_mutator() rewrites -- it is returned unchanged. Modules after the rewriter do not know about property reference nodes, resulting in "ERROR: unrecognized node type: 63". Since varlevelsup of lateral references is not incremented, they are not resolved correctly in the planner, leading to many different symptoms. Fix this by calling replace_property_refs_mutator() directly from replace_property_refs(), similar to how other mutator functions do. The only case when a property reference or a lateral reference can be the root of a GRAPH_TABLE expression tree is when it is a bare property reference or a bare lateral reference in the WHERE clause. The COLUMNS clause is passed to replace_property_refs() as a targetlist. Every other expression has at least one expression node covering the property reference or a lateral reference in the expression tree. That explains why this bug was not seen so far. Author: Ashutosh Bapat <[email protected]> Reported-by: Noah Misch <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/20260630173053.51.noahmisch%40microsoft.com Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7883ea13ffdc6c657923031d80b2505d08f51e33 Modified Files -------------- src/backend/rewrite/rewriteGraphTable.c | 2 +- src/test/regress/expected/graph_table.out | 38 +++++++++++++++++++++++-------- src/test/regress/sql/graph_table.sql | 17 +++++++++----- 3 files changed, 41 insertions(+), 16 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix replace_property_refs() ignoring the root of expression tree @ 2026-07-08 08:08 Peter Eisentraut <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Peter Eisentraut @ 2026-07-08 08:08 UTC (permalink / raw) To: [email protected] Fix replace_property_refs() ignoring the root of expression tree replace_property_refs() called expression_tree_mutator() with the root of the expression tree as the input node. But expression_tree_mutator() does not call the mutator function on the root node, so the root node remains unchanged. If the root node is a property reference or a lateral reference -- the two node kinds that replace_property_refs_mutator() rewrites -- it is returned unchanged. Modules after the rewriter do not know about property reference nodes, resulting in "ERROR: unrecognized node type: 63". Since varlevelsup of lateral references is not incremented, they are not resolved correctly in the planner, leading to many different symptoms. Fix this by calling replace_property_refs_mutator() directly from replace_property_refs(), similar to how other mutator functions do. The only case when a property reference or a lateral reference can be the root of a GRAPH_TABLE expression tree is when it is a bare property reference or a bare lateral reference in the WHERE clause. The COLUMNS clause is passed to replace_property_refs() as a targetlist. Every other expression has at least one expression node covering the property reference or a lateral reference in the expression tree. That explains why this bug was not seen so far. Author: Ashutosh Bapat <[email protected]> Reported-by: Noah Misch <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/20260630173053.51.noahmisch%40microsoft.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/16a4b3ef8eebd2f3da44c17523fef23d2de80679 Modified Files -------------- src/backend/rewrite/rewriteGraphTable.c | 2 +- src/test/regress/expected/graph_table.out | 38 +++++++++++++++++++++++-------- src/test/regress/sql/graph_table.sql | 17 +++++++++----- 3 files changed, 41 insertions(+), 16 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-07-08 08:08 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-07-08 08:08 pgsql: Fix replace_property_refs() ignoring the root of expression tree Peter Eisentraut <[email protected]> 2026-07-08 08:08 pgsql: Fix replace_property_refs() ignoring the root of expression tree Peter Eisentraut <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox