aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_relation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser/parse_relation.c')
-rw-r--r--src/backend/parser/parse_relation.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 713ec0e521d..4193a03ebba 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -2658,12 +2658,17 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
Assert(varattno == te->resno);
/*
- * In scenarios where columns have been added to a view
- * since the outer query was originally parsed, there can
- * be more items in the subquery tlist than the outer
- * query expects. We should ignore such extra column(s)
- * --- compare the behavior for composite-returning
- * functions, in the RTE_FUNCTION case below.
+ * In a just-parsed subquery RTE, rte->eref->colnames
+ * should always have exactly as many entries as the
+ * subquery has non-junk output columns. However, if the
+ * subquery RTE was created by expansion of a view,
+ * perhaps the subquery tlist could now have more entries
+ * than existed when the outer query was parsed. Such
+ * cases should now be prevented because ApplyRetrieveRule
+ * will extend the colnames list to match. But out of
+ * caution, we'll keep the code like this in the back
+ * branches: just ignore any columns that lack colnames
+ * entries.
*/
if (!aliasp_item)
break;