@@ -51,7 +51,6 @@ pathman_join_pathlist_hook(PlannerInfo *root,
51
51
ListCell * lc ;
52
52
WalkerContext context ;
53
53
double paramsel ;
54
- bool innerrel_rinfo_contains_part_attr ;
55
54
56
55
/* Call hooks set by other extensions */
57
56
if (set_join_pathlist_next )
@@ -103,11 +102,6 @@ pathman_join_pathlist_hook(PlannerInfo *root,
103
102
paramsel *= wrap -> paramsel ;
104
103
}
105
104
106
- /* Check that innerrel's RestrictInfos contain partitioned column */
107
- innerrel_rinfo_contains_part_attr =
108
- get_partitioned_attr_clauses (innerrel -> baserestrictinfo ,
109
- inner_prel , innerrel -> relid ) != NULL ;
110
-
111
105
foreach (lc , innerrel -> pathlist )
112
106
{
113
107
AppendPath * cur_inner_path = (AppendPath * ) lfirst (lc );
@@ -132,14 +126,10 @@ pathman_join_pathlist_hook(PlannerInfo *root,
132
126
/* Get the ParamPathInfo for a parameterized path */
133
127
ppi = get_baserel_parampathinfo (root , innerrel , inner_required );
134
128
135
- /*
136
- * Skip if neither rel->baserestrictinfo nor
137
- * ppi->ppi_clauses reference partition attribute
138
- */
139
- if (!(innerrel_rinfo_contains_part_attr ||
140
- (ppi && get_partitioned_attr_clauses (ppi -> ppi_clauses ,
141
- inner_prel ,
142
- innerrel -> relid ))))
129
+ /* Skip ppi->ppi_clauses don't reference partition attribute */
130
+ if (!(ppi && get_partitioned_attr_clauses (ppi -> ppi_clauses ,
131
+ inner_prel ,
132
+ innerrel -> relid )))
143
133
continue ;
144
134
145
135
inner = create_runtimeappend_path (root , cur_inner_path , ppi , paramsel );
@@ -213,13 +203,13 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
213
203
ListCell * lc ;
214
204
Oid * children ;
215
205
List * ranges ,
216
- * wrappers ;
206
+ * wrappers ,
207
+ * rel_partattr_clauses = NIL ;
217
208
PathKey * pathkeyAsc = NULL ,
218
209
* pathkeyDesc = NULL ;
219
210
double paramsel = 1.0 ;
220
211
WalkerContext context ;
221
212
int i ;
222
- bool rel_rinfo_contains_part_attr = false;
223
213
224
214
if (prel -> parttype == PT_RANGE )
225
215
{
@@ -336,20 +326,19 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
336
326
pg_pathman_enable_runtime_merge_append ))
337
327
return ;
338
328
329
+ /* Check that rel's RestrictInfo contains partitioned column */
330
+ rel_partattr_clauses = get_partitioned_attr_clauses (rel -> baserestrictinfo ,
331
+ prel , rel -> relid );
332
+
339
333
/* Runtime[Merge]Append is pointless if there are no params in clauses */
340
- if (!clause_contains_params ((Node * ) get_actual_clauses ( rel -> baserestrictinfo ) ))
334
+ if (!clause_contains_params ((Node * ) rel_partattr_clauses ))
341
335
return ;
342
336
343
- /* Check that rel's RestrictInfo contains partitioned column */
344
- rel_rinfo_contains_part_attr =
345
- get_partitioned_attr_clauses (rel -> baserestrictinfo ,
346
- prel , rel -> relid ) != NULL ;
347
-
348
337
foreach (lc , rel -> pathlist )
349
338
{
350
339
AppendPath * cur_path = (AppendPath * ) lfirst (lc );
351
340
Relids inner_required = PATH_REQ_OUTER ((Path * ) cur_path );
352
- ParamPathInfo * ppi = get_appendrel_parampathinfo ( rel , inner_required );
341
+ ParamPathInfo * ppi = get_baserel_parampathinfo ( root , rel , inner_required );
353
342
Path * inner_path = NULL ;
354
343
355
344
/* Skip if rel contains some join-related stuff or path type mismatched */
@@ -363,7 +352,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
363
352
* Skip if neither rel->baserestrictinfo nor
364
353
* ppi->ppi_clauses reference partition attribute
365
354
*/
366
- if (!(rel_rinfo_contains_part_attr ||
355
+ if (!(rel_partattr_clauses ||
367
356
(ppi && get_partitioned_attr_clauses (ppi -> ppi_clauses ,
368
357
prel , rel -> relid ))))
369
358
continue ;
0 commit comments