Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitabf293e

Browse files
committed
Fix the recently-added code that eliminates unnecessary SubqueryScan nodes
from a finished plan tree. We have to copy the output column names(resname fields) from the SubqueryScan down to its child plan node;else, if this is the topmost level of the plan, the wrong column nameswill be delivered to the client. Per bug #2017 reported by Jolly Chen.
1 parent902377c commitabf293e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎src/backend/optimizer/plan/setrefs.c

Lines changed: 16 additions & 1 deletion
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.115 2005/10/15 02:49:20 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.116 2005/11/03 17:34:03 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -359,6 +359,8 @@ set_subqueryscan_references(SubqueryScan *plan, List *rtable)
359359
*/
360360
intrtoffset=list_length(rtable);
361361
List*sub_rtable;
362+
ListCell*lp,
363+
*lc;
362364

363365
sub_rtable=copyObject(rte->subquery->rtable);
364366
range_table_walker(sub_rtable,
@@ -378,6 +380,19 @@ set_subqueryscan_references(SubqueryScan *plan, List *rtable)
378380

379381
result->initPlan=list_concat(plan->scan.plan.initPlan,
380382
result->initPlan);
383+
384+
/*
385+
* we also have to transfer the SubqueryScan's result-column names
386+
* into the subplan, else columns sent to client will be improperly
387+
* labeled if this is the topmost plan level.
388+
*/
389+
forboth(lp,plan->scan.plan.targetlist,lc,result->targetlist)
390+
{
391+
TargetEntry*ptle= (TargetEntry*)lfirst(lp);
392+
TargetEntry*ctle= (TargetEntry*)lfirst(lc);
393+
394+
ctle->resname=ptle->resname;
395+
}
381396
}
382397
else
383398
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp