From fb30ac54e6c5d816f72d2bfff17c487b30e0ba79 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 3 Nov 2005 17:45:29 +0000 Subject: [PATCH] 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. --- src/backend/optimizer/plan/setrefs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 9f078924c2..e6f97fa081 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.116 2005/11/03 17:34:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.117 2005/11/03 17:45:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -382,9 +382,10 @@ set_subqueryscan_references(SubqueryScan *plan, List *rtable) result->initPlan); /* - * we also have to transfer the SubqueryScan's result-column names + * 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. + * labeled if this is the topmost plan level. Copy the "source + * column" information too. */ forboth(lp, plan->scan.plan.targetlist, lc, result->targetlist) { @@ -392,6 +393,8 @@ set_subqueryscan_references(SubqueryScan *plan, List *rtable) TargetEntry *ctle = (TargetEntry *) lfirst(lc); ctle->resname = ptle->resname; + ctle->resorigtbl = ptle->resorigtbl; + ctle->resorigcol = ptle->resorigcol; } } else -- 2.40.0