summaryrefslogtreecommitdiff
path: root/src/backend/optimizer
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r--src/backend/optimizer/plan/setrefs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index e5786455704..86d29ecede3 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -438,6 +438,15 @@ add_rte_to_flat_rtable(PlannerGlobal *glob, RangeTblEntry *rte)
newrte->colcollations = NIL;
newrte->securityQuals = NIL;
+ /*
+ * Also, if it's a subquery RTE, lose the relid that may have been kept to
+ * signal that it had been a view. We don't want that to escape the
+ * planner, mainly because doing so breaks -DWRITE_READ_PARSE_PLAN_TREES
+ * testing thanks to outfuncs/readfuncs not preserving it.
+ */
+ if (newrte->rtekind == RTE_SUBQUERY)
+ newrte->relid = InvalidOid;
+
glob->finalrtable = lappend(glob->finalrtable, newrte);
/*