From: Tom Lane Date: Fri, 27 Oct 2017 22:16:25 +0000 (-0400) Subject: Dept of second thoughts: keep aliasp_item in sync with tlistitem. X-Git-Tag: REL9_4_15~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d01d97c25cf425acc097520bc1c6af57dff51c44;p=postgresql Dept of second thoughts: keep aliasp_item in sync with tlistitem. 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. --- diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index ea62cbb41a..ee0e0f81d8 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -1844,7 +1844,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) @@ -1860,6 +1859,8 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, *colvars = lappend(*colvars, varnode); } + + aliasp_item = lnext(aliasp_item); } } break;