@@ -179,18 +179,16 @@ get_partition_oids(List *ranges, int *n, PartRelationInfo *prel)
179
179
180
180
static Path *
181
181
create_pickyappend_path (PlannerInfo * root ,
182
- RelOptInfo * joinrel ,
183
- RelOptInfo * outerrel ,
184
- RelOptInfo * innerrel ,
185
- ParamPathInfo * param_info ,
186
- JoinPathExtraData * extra )
182
+ AppendPath * inner_append ,
183
+ ParamPathInfo * param_info ,
184
+ JoinPathExtraData * extra )
187
185
{
188
- AppendPath * inner_append = ( AppendPath * ) linitial ( innerrel -> cheapest_parameterized_paths ) ;
189
- List * joinrestrictclauses = extra -> restrictlist ;
190
- List * joinclauses ;
191
- List * otherclauses ;
192
- ListCell * lc ;
193
- int i ;
186
+ RelOptInfo * innerrel = inner_append -> path . parent ;
187
+ List * joinrestrictclauses = extra -> restrictlist ;
188
+ List * joinclauses ;
189
+ List * otherclauses ;
190
+ ListCell * lc ;
191
+ int i ;
194
192
195
193
RangeTblEntry * inner_entry = root -> simple_rte_array [innerrel -> relid ];
196
194
@@ -272,6 +270,7 @@ pathman_join_pathlist_hook(PlannerInfo *root,
272
270
PartRelationInfo * inner_prel ;
273
271
NestPath * nest_path ;
274
272
List * pathkeys = NIL ;
273
+ ListCell * lc ;
275
274
276
275
if (set_join_pathlist_next )
277
276
set_join_pathlist_next (root , joinrel , outerrel ,
@@ -280,38 +279,44 @@ pathman_join_pathlist_hook(PlannerInfo *root,
280
279
if (jointype == JOIN_FULL || !pg_pathman_enable_pickyappend )
281
280
return ;
282
281
283
- if (innerrel -> reloptkind == RELOPT_BASEREL &&
284
- inner_entry -> inh &&
285
- IsA (linitial (innerrel -> cheapest_parameterized_paths ), AppendPath ) &&
286
- (inner_prel = get_pathman_relation_info (inner_entry -> relid , NULL )))
282
+ if (innerrel -> reloptkind != RELOPT_BASEREL ||
283
+ !inner_entry -> inh ||
284
+ !(inner_prel = get_pathman_relation_info (inner_entry -> relid , NULL )))
287
285
{
288
- elog ( LOG , "adding new nestloop path with pickyappend" );
286
+ return ; /* Obviously not our case */
289
287
}
290
- else return ;
291
288
292
- outer = outerrel -> cheapest_total_path ;
289
+ foreach (lc , innerrel -> pathlist )
290
+ {
291
+ AppendPath * cur_inner_path = (AppendPath * ) lfirst (lc );
293
292
294
- inner_required = bms_union ( PATH_REQ_OUTER (( Path * ) linitial ( innerrel -> cheapest_parameterized_paths )),
295
- bms_make_singleton ( outerrel -> relid )) ;
293
+ if (! IsA ( cur_inner_path , AppendPath ))
294
+ continue ;
296
295
297
- inner = create_pickyappend_path (root , joinrel , outerrel , innerrel ,
298
- get_appendrel_parampathinfo (innerrel ,
299
- inner_required ),
300
- extra );
296
+ outer = outerrel -> cheapest_total_path ;
301
297
302
- initial_cost_nestloop (root , & workspace , jointype ,
303
- outer , inner ,
304
- extra -> sjinfo , & extra -> semifactors );
298
+ inner_required = bms_union (PATH_REQ_OUTER ((Path * ) cur_inner_path ),
299
+ bms_make_singleton (outerrel -> relid ));
305
300
306
- pathkeys = build_join_pathkeys (root , joinrel , jointype , outer -> pathkeys );
301
+ inner = create_pickyappend_path (root , cur_inner_path ,
302
+ get_appendrel_parampathinfo (innerrel ,
303
+ inner_required ),
304
+ extra );
307
305
308
- nest_path = create_nestloop_path (root , joinrel , jointype , & workspace ,
309
- extra -> sjinfo , & extra -> semifactors ,
310
- outer , inner , extra -> restrictlist ,
311
- pathkeys ,
312
- calc_nestloop_required_outer (outer , inner ));
306
+ initial_cost_nestloop (root , & workspace , jointype ,
307
+ outer , inner ,
308
+ extra -> sjinfo , & extra -> semifactors );
313
309
314
- add_path (joinrel , (Path * ) nest_path );
310
+ pathkeys = build_join_pathkeys (root , joinrel , jointype , outer -> pathkeys );
311
+
312
+ nest_path = create_nestloop_path (root , joinrel , jointype , & workspace ,
313
+ extra -> sjinfo , & extra -> semifactors ,
314
+ outer , inner , extra -> restrictlist ,
315
+ pathkeys ,
316
+ calc_nestloop_required_outer (outer , inner ));
317
+
318
+ add_path (joinrel , (Path * ) nest_path );
319
+ }
315
320
}
316
321
317
322
static void
0 commit comments