@@ -81,10 +81,10 @@ pathman_join_pathlist_hook(PlannerInfo *root,
81
81
const PartRelationInfo * inner_prel ;
82
82
List * joinclauses ,
83
83
* otherclauses ;
84
- ListCell * lc ;
85
84
WalkerContext context ;
86
85
double paramsel ;
87
- Node * expr ;
86
+ Node * part_expr ;
87
+ ListCell * lc ;
88
88
89
89
/* Call hooks set by other extensions */
90
90
if (set_join_pathlist_next )
@@ -130,14 +130,14 @@ pathman_join_pathlist_hook(PlannerInfo *root,
130
130
}
131
131
132
132
/* Make copy of partitioning expression and fix Var's varno attributes */
133
- expr = PrelExpressionForRelid (inner_prel , innerrel -> relid );
133
+ part_expr = PrelExpressionForRelid (inner_prel , innerrel -> relid );
134
134
135
135
paramsel = 1.0 ;
136
136
foreach (lc , joinclauses )
137
137
{
138
138
WrapperNode * wrap ;
139
139
140
- InitWalkerContext (& context , expr , inner_prel , NULL , false);
140
+ InitWalkerContext (& context , part_expr , inner_prel , NULL , false);
141
141
wrap = walk_expr_tree ((Expr * ) lfirst (lc ), & context );
142
142
paramsel *= wrap -> paramsel ;
143
143
}
@@ -308,13 +308,13 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
308
308
* pathkeyDesc = NULL ;
309
309
double paramsel = 1.0 ; /* default part selectivity */
310
310
WalkerContext context ;
311
- Node * expr ;
312
- bool modify_append_nodes ;
311
+ Node * part_expr ;
312
+ List * part_clauses ;
313
313
ListCell * lc ;
314
314
int i ;
315
315
316
316
/* Make copy of partitioning expression and fix Var's varno attributes */
317
- expr = PrelExpressionForRelid (prel , rti );
317
+ part_expr = PrelExpressionForRelid (prel , rti );
318
318
319
319
if (prel -> parttype == PT_RANGE )
320
320
{
@@ -328,11 +328,11 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
328
328
tce = lookup_type_cache (prel -> atttype , TYPECACHE_LT_OPR | TYPECACHE_GT_OPR );
329
329
330
330
/* Make pathkeys */
331
- pathkeys = build_expression_pathkey (root , (Expr * ) expr , NULL ,
331
+ pathkeys = build_expression_pathkey (root , (Expr * ) part_expr , NULL ,
332
332
tce -> lt_opr , NULL , false);
333
333
if (pathkeys )
334
334
pathkeyAsc = (PathKey * ) linitial (pathkeys );
335
- pathkeys = build_expression_pathkey (root , (Expr * ) expr , NULL ,
335
+ pathkeys = build_expression_pathkey (root , (Expr * ) part_expr , NULL ,
336
336
tce -> gt_opr , NULL , false);
337
337
if (pathkeys )
338
338
pathkeyDesc = (PathKey * ) linitial (pathkeys );
@@ -345,7 +345,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
345
345
ranges = list_make1_irange_full (prel , IR_COMPLETE );
346
346
347
347
/* Make wrappers over restrictions and collect final rangeset */
348
- InitWalkerContext (& context , expr , prel , NULL , false);
348
+ InitWalkerContext (& context , part_expr , prel , NULL , false);
349
349
wrappers = NIL ;
350
350
foreach (lc , rel -> baserestrictinfo )
351
351
{
@@ -359,12 +359,6 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
359
359
ranges = irange_list_intersection (ranges , wrap -> rangeset );
360
360
}
361
361
362
- /*
363
- * Walker should been have filled these parameter while checking.
364
- * Runtime[Merge]Append is pointless if there are no params in clauses.
365
- */
366
- modify_append_nodes = context .found_params ;
367
-
368
362
/* Get number of selected partitions */
369
363
irange_len = irange_list_length (ranges );
370
364
if (prel -> enable_parent )
@@ -441,7 +435,13 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
441
435
pg_pathman_enable_runtime_merge_append ))
442
436
return ;
443
437
444
- if (!modify_append_nodes )
438
+ /* Get partitioning-related clauses */
439
+ part_clauses = get_partitioning_clauses (list_union (rel -> baserestrictinfo ,
440
+ rel -> joininfo ),
441
+ prel , rti );
442
+
443
+ /* Skip if there's no PARAMs in partitioning-related clauses */
444
+ if (!clause_contains_params ((Node * ) part_clauses ))
445
445
return ;
446
446
447
447
/* Generate Runtime[Merge]Append paths if needed */
@@ -462,12 +462,6 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
462
462
/* Get existing parameterization */
463
463
ppi = get_appendrel_parampathinfo (rel , inner_required );
464
464
465
- /* Skip if there are no partitioning clauses */
466
- if (!get_partitioning_clauses (list_union (rel -> baserestrictinfo ,
467
- rel -> joininfo ),
468
- prel , rti ))
469
- return ;
470
-
471
465
if (IsA (cur_path , AppendPath ) && pg_pathman_enable_runtimeappend )
472
466
inner_path = create_runtimeappend_path (root , cur_path ,
473
467
ppi , paramsel );
0 commit comments