Skip to content

Commit fb30ac5

Browse files
committed
Thinking further, it seems we had better also copy down resorigtbl/resorigcol
to ensure that SubqueryScan elimination doesn't change the behavior of reporting of original column sources.
1 parent abf293e commit fb30ac5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/backend/optimizer/plan/setrefs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.116 2005/11/03 17:34:03 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.117 2005/11/03 17:45:29 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -382,16 +382,19 @@ set_subqueryscan_references(SubqueryScan *plan, List *rtable)
382382
result->initPlan);
383383

384384
/*
385-
* we also have to transfer the SubqueryScan's result-column names
385+
* We also have to transfer the SubqueryScan's result-column names
386386
* into the subplan, else columns sent to client will be improperly
387-
* labeled if this is the topmost plan level.
387+
* labeled if this is the topmost plan level. Copy the "source
388+
* column" information too.
388389
*/
389390
forboth(lp, plan->scan.plan.targetlist, lc, result->targetlist)
390391
{
391392
TargetEntry *ptle = (TargetEntry *) lfirst(lp);
392393
TargetEntry *ctle = (TargetEntry *) lfirst(lc);
393394

394395
ctle->resname = ptle->resname;
396+
ctle->resorigtbl = ptle->resorigtbl;
397+
ctle->resorigcol = ptle->resorigcol;
395398
}
396399
}
397400
else

0 commit comments

Comments
 (0)