Skip to content

Commit b1a70f7

Browse files
committed
add sorted paths to custom_paths list
1 parent f1e59a1 commit b1a70f7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pickyappend.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ create_pickyappend_path(PlannerInfo *root,
8282

8383
/* Set 'partitioned column'-related clauses */
8484
result->cpath.custom_private = joinclauses;
85+
result->cpath.custom_paths = NIL;
8586

8687
Assert(inner_entry->relid != 0);
8788
result->relid = inner_entry->relid;
@@ -98,14 +99,19 @@ create_pickyappend_path(PlannerInfo *root,
9899
child->content_type = CHILD_PATH;
99100
child->content.path = path;
100101
child->relid = root->simple_rte_array[relindex]->relid;
101-
102102
Assert(child->relid != InvalidOid);
103103

104104
result->children[i++] = child;
105105
}
106+
106107
qsort(result->children, result->nchildren,
107108
sizeof(ChildScanCommon), cmp_child_scan_common);
108109

110+
/* Fill 'custom_paths' with paths in sort order */
111+
for (i = 0; i < result->nchildren; i++)
112+
result->cpath.custom_paths = lappend(result->cpath.custom_paths,
113+
result->children[i]->content.path);
114+
109115
return &result->cpath.path;
110116
}
111117

@@ -177,14 +183,10 @@ save_pickyappend_private(CustomScan *cscan, PickyAppendPath *path, PlannerInfo *
177183
List *custom_oids = NIL;
178184
int i;
179185

180-
cscan->custom_plans = NIL;
181-
182186
for (i = 0; i < nchildren; i++)
183187
{
188+
/* We've already filled 'custom_paths' in create_pickyappend_path */
184189
custom_oids = lappend_oid(custom_oids, children[i]->relid);
185-
cscan->custom_plans = lappend(cscan->custom_plans,
186-
create_plan(root, children[i]->content.path));
187-
188190
pfree(children[i]);
189191
}
190192

@@ -233,7 +235,6 @@ create_pickyappend_plan(PlannerInfo *root, RelOptInfo *rel,
233235
cscan->scan.scanrelid = 0;
234236

235237
cscan->custom_exprs = gpath->cpath.custom_private;
236-
//cscan->custom_exprs = NIL; /* TODO: fix */
237238

238239
cscan->methods = &pickyappend_plan_methods;
239240

@@ -299,9 +300,9 @@ pickyappend_rescan(CustomScanState *node)
299300

300301
foreach (lc, ranges)
301302
{
302-
/*elog(LOG, "lower: %d, upper: %d",
303+
elog(LOG, "lower: %d, upper: %d",
303304
irange_lower(lfirst_irange(lc)),
304-
irange_upper(lfirst_irange(lc)));*/
305+
irange_upper(lfirst_irange(lc)));
305306
}
306307
}
307308

0 commit comments

Comments
 (0)