]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix EXPLAIN output for subplans in MERGE.
authorDean Rasheed <dean.a.rasheed@gmail.com>
Sun, 17 Mar 2024 10:20:20 +0000 (10:20 +0000)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Sun, 17 Mar 2024 10:20:20 +0000 (10:20 +0000)
commit89ee14a2f22b2353a6cf9d193c54504b4d3131f5
treea6b173934f14fcf6b7052a5a1b631a114974fc81
parent7c61d23422afece255ed47c84876fb062f40d451
Fix EXPLAIN output for subplans in MERGE.

Given a subplan in a MERGE query, EXPLAIN would sometimes fail to
properly display expressions involving Params referencing variables in
other parts of the plan tree.

This would affect subplans outside the topmost join plan node, for
which expansion of Params would go via the top-level ModifyTable plan
node.  The problem was that "inner_tlist" for the ModifyTable node's
deparse_namespace was set to the join node's targetlist, but
"inner_plan" was set to the ModifyTable node itself, rather than the
join node, leading to incorrect results when descending to the
referenced variable.

Fix and backpatch to v15, where MERGE was introduced.

Discussion: https://postgr.es/m/CAEZATCWAv-sZuH%2BwG5xJ-%2BGt7qGNGX8wUQd3XYydMFDKgRB9nw%40mail.gmail.com
src/backend/utils/adt/ruleutils.c
src/test/regress/expected/merge.out
src/test/regress/sql/merge.sql