*/
int rtoffset = list_length(rtable);
List *sub_rtable;
+ ListCell *lp,
+ *lc;
sub_rtable = copyObject(rte->subquery->rtable);
range_table_walker(sub_rtable,
result->initPlan = list_concat(plan->scan.plan.initPlan,
result->initPlan);
+
+ /*
+ * we also have to transfer the SubqueryScan's result-column names
+ * into the subplan, else columns sent to client will be improperly
+ * labeled if this is the topmost plan level.
+ */
+ forboth(lp, plan->scan.plan.targetlist, lc, result->targetlist)
+ {
+ TargetEntry *ptle = (TargetEntry *) lfirst(lp);
+ TargetEntry *ctle = (TargetEntry *) lfirst(lc);
+
+ ctle->resname = ptle->resname;
+ }
}
else
{