diff options
Diffstat (limited to 'src/backend/optimizer/prep')
| -rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 7 | 
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 0c68ec011be..8eaa734916d 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -324,7 +324,7 @@ recurse_set_operations(Node *setOp, PlannerInfo *root,  		 * anyway; otherwise do statistical estimation.  		 *  		 * XXX you don't really want to know about this: we do the estimation -		 * using the subquery's original targetlist expressions, not the +		 * using the subroot->parse's original targetlist expressions, not the  		 * subroot->processed_tlist which might seem more appropriate.  The  		 * reason is that if the subquery is itself a setop, it may return a  		 * processed_tlist containing "varno 0" Vars generated by @@ -332,6 +332,9 @@ recurse_set_operations(Node *setOp, PlannerInfo *root,  		 * mightily.  We ought to get rid of the "varno 0" hack, but that  		 * requires a redesign of the parsetree representation of setops, so  		 * that there can be an RTE corresponding to each setop's output. +		 * Note, we use this not subquery's targetlist but subroot->parse's +		 * targetlist, because it was revised by self-join removal. subquery's +		 * targetlist might contain the references to the removed relids.  		 */  		if (pNumGroups)  		{ @@ -341,7 +344,7 @@ recurse_set_operations(Node *setOp, PlannerInfo *root,  				*pNumGroups = subpath->rows;  			else  				*pNumGroups = estimate_num_groups(subroot, -												  get_tlist_exprs(subquery->targetList, false), +												  get_tlist_exprs(subroot->parse->targetList, false),  												  subpath->rows,  												  NULL,  												  NULL);  | 
