Dept of second thoughts: keep aliasp_item in sync with tlistitem.
authorTom Lane <[email protected]>
Fri, 27 Oct 2017 22:16:25 +0000 (18:16 -0400)
committerTom Lane <[email protected]>
Fri, 27 Oct 2017 22:16:25 +0000 (18:16 -0400)
Commit d5b760ecb wasn't quite right, on second thought: if the
caller didn't ask for column names then it would happily emit
more Vars than if the caller did ask for column names.  This
is surely not a good idea.  Advance the aliasp_item whether or
not we're preparing a colnames list.

src/backend/parser/parse_relation.c

index b8307d5cf51f2f2b1b108b227a894ae759b7133d..ae425d3679a321faef70d002da404ae8c2f09500 100644 (file)
@@ -1619,7 +1619,6 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
                        char       *label = strVal(lfirst(aliasp_item));
 
                        *colnames = lappend(*colnames, makeString(pstrdup(label)));
-                       aliasp_item = lnext(aliasp_item);
                    }
 
                    if (colvars)
@@ -1635,6 +1634,8 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
 
                        *colvars = lappend(*colvars, varnode);
                    }
+
+                   aliasp_item = lnext(aliasp_item);
                }
            }
            break;