@@ -82,6 +82,7 @@ create_pickyappend_path(PlannerInfo *root,
8282
8383/* Set 'partitioned column'-related clauses */
8484result -> cpath .custom_private = joinclauses ;
85+ result -> cpath .custom_paths = NIL ;
8586
8687Assert (inner_entry -> relid != 0 );
8788result -> relid = inner_entry -> relid ;
@@ -98,14 +99,19 @@ create_pickyappend_path(PlannerInfo *root,
9899child -> content_type = CHILD_PATH ;
99100child -> content .path = path ;
100101child -> relid = root -> simple_rte_array [relindex ]-> relid ;
101-
102102Assert (child -> relid != InvalidOid );
103103
104104result -> children [i ++ ]= child ;
105105}
106+
106107qsort (result -> children ,result -> nchildren ,
107108sizeof (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+
109115return & result -> cpath .path ;
110116}
111117
@@ -177,14 +183,10 @@ save_pickyappend_private(CustomScan *cscan, PickyAppendPath *path, PlannerInfo *
177183List * custom_oids = NIL ;
178184int i ;
179185
180- cscan -> custom_plans = NIL ;
181-
182186for (i = 0 ;i < nchildren ;i ++ )
183187{
188+ /* We've already filled 'custom_paths' in create_pickyappend_path */
184189custom_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-
188190pfree (children [i ]);
189191}
190192
@@ -233,7 +235,6 @@ create_pickyappend_plan(PlannerInfo *root, RelOptInfo *rel,
233235cscan -> scan .scanrelid = 0 ;
234236
235237cscan -> custom_exprs = gpath -> cpath .custom_private ;
236- //cscan->custom_exprs = NIL; /* TODO: fix */
237238
238239cscan -> methods = & pickyappend_plan_methods ;
239240
@@ -299,9 +300,9 @@ pickyappend_rescan(CustomScanState *node)
299300
300301foreach (lc ,ranges )
301302{
302- /* elog(LOG, "lower: %d, upper: %d",
303+ elog (LOG ,"lower: %d, upper: %d" ,
303304irange_lower (lfirst_irange (lc )),
304- irange_upper(lfirst_irange(lc)));*/
305+ irange_upper (lfirst_irange (lc )));
305306}
306307}
307308