aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-10-11 11:56:52 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-10-11 11:56:52 -0400
commit2c25db32eedb9696c4b900c70ebef03683babf24 (patch)
tree49c93492b08cec716f7c560c2b2ff6cae8a8d0a6 /src/backend/utils/adt/ruleutils.c
parent2051fd30a4fa3b62cdb244f5b9748c1cb3b39845 (diff)
downloadpostgresql-2c25db32eedb9696c4b900c70ebef03683babf24.tar.gz
postgresql-2c25db32eedb9696c4b900c70ebef03683babf24.zip
Fix EXPLAIN of SEARCH BREADTH FIRST queries some more.
Commit 3f50b8263 had an oversight: formerly, to deparse expressions attached to a plan node, it was only necessary to update the deparse_namespace ancestors list alongside calling set_deparse_plan. Now it's necessary to update the ancestors list *first*, because set_deparse_plan consults it, and one call site got that wrong. This error was masked in most cases because explain.c uses just one List object for the ancestors list, updating it in-place as the plan is scanned, so that we accidentally had the right List assigned to dpns->ancestors before it was needed. It would fail only if a WorkTableScan node were the first one that we tried to deparse a subexpression of. Per report from Markus Winand. Like the previous patch, back-patch to v14. Discussion: https://postgr.es/m/648B0505-AA57-42C2-A2DA-E551DE46FA15@winand.at
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 871f3edc923..589c8ed87cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -3681,8 +3681,8 @@ set_deparse_context_plan(List *dpcontext, Plan *plan, List *ancestors)
dpns = (deparse_namespace *) linitial(dpcontext);
/* Set our attention on the specific plan node passed in */
- set_deparse_plan(dpns, plan);
dpns->ancestors = ancestors;
+ set_deparse_plan(dpns, plan);
return dpcontext;
}
@@ -4836,7 +4836,7 @@ get_rtable_name(int rtindex, deparse_context *context)
* of a given Plan node
*
* This sets the plan, outer_plan, inner_plan, outer_tlist, inner_tlist,
- * and index_tlist fields. Caller is responsible for adjusting the ancestors
+ * and index_tlist fields. Caller must already have adjusted the ancestors
* list if necessary. Note that the rtable, subplans, and ctes fields do
* not need to change when shifting attention to different plan nodes in a
* single plan tree.