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

Commitc8851e7

Browse files
committed
improve function replace_tlist_varnos()
1 parent2729986 commitc8851e7

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

‎src/nodes_common.c

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include"access/sysattr.h"
1616
#include"optimizer/restrictinfo.h"
1717
#include"optimizer/var.h"
18+
#include"rewrite/rewriteManip.h"
1819
#include"utils/memutils.h"
1920

2021

@@ -112,31 +113,19 @@ select_required_plans(HTAB *children_table, Oid *parts, int nparts, int *nres)
112113
returnresult;
113114
}
114115

115-
/* ReplaceVars' varnoswith thevalue provided by 'parent' */
116+
/* Replace'varno' of child's Varswith the'append_rel_rti' */
116117
staticList*
117-
replace_tlist_varnos(List*child_tlist,RelOptInfo*parent)
118+
replace_tlist_varnos(List*tlist,Indexold_varno,Indexnew_varno)
118119
{
119-
ListCell*lc;
120-
List*result=NIL;
121-
inti=1;/* resnos begin with 1 */
122-
123-
foreach (lc,child_tlist)
124-
{
125-
Var*var= (Var*) ((TargetEntry*)lfirst(lc))->expr;
126-
Var*newvar= (Var*)palloc(sizeof(Var));
120+
List*temp_tlist;
127121

128-
Assert(IsA(var,Var));
122+
AssertArg(old_varno!=0);
123+
AssertArg(new_varno!=0);
129124

130-
*newvar=*var;
131-
newvar->varno=parent->relid;
132-
newvar->varnoold=parent->relid;
125+
temp_tlist=copyObject(tlist);
126+
ChangeVarNodes((Node*)temp_tlist,old_varno,new_varno,0);
133127

134-
result=lappend(result,makeTargetEntry((Expr*)newvar,
135-
i++,/* item's index */
136-
NULL, false));
137-
}
138-
139-
returnresult;
128+
returntemp_tlist;
140129
}
141130

142131
/* Append partition attribute in case it's not present in target list */
@@ -421,7 +410,9 @@ create_append_plan_common(PlannerInfo *root, RelOptInfo *rel,
421410

422411
/* Replace rel's tlist with a matching one */
423412
if (!cscan->scan.plan.targetlist)
424-
tlist=replace_tlist_varnos(child_plan->targetlist,rel);
413+
tlist=replace_tlist_varnos(child_plan->targetlist,
414+
child_rel->relid,
415+
rel->relid);
425416

426417
/* Add partition attribute if necessary (for ExecQual()) */
427418
child_plan->targetlist=append_part_attr_to_tlist(child_plan->targetlist,
@@ -431,7 +422,8 @@ create_append_plan_common(PlannerInfo *root, RelOptInfo *rel,
431422
/* Now make custom_scan_tlist match child plans' targetlists */
432423
if (!cscan->custom_scan_tlist)
433424
cscan->custom_scan_tlist=replace_tlist_varnos(child_plan->targetlist,
434-
rel);
425+
child_rel->relid,
426+
rel->relid);
435427
}
436428
}
437429

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp