@@ -108,20 +108,24 @@ pathman_join_pathlist_hook(PlannerInfo *root,
108
108
if (inner_rte -> inh )
109
109
return ;
110
110
111
+ /* We shouldn't process functions etc */
112
+ if (inner_rte -> rtekind != RTE_RELATION )
113
+ return ;
114
+
111
115
/* We don't support these join types (since inner will be parameterized) */
112
116
if (jointype == JOIN_FULL ||
113
117
jointype == JOIN_RIGHT ||
114
118
jointype == JOIN_UNIQUE_INNER )
115
119
return ;
116
120
121
+ /* Skip if inner table is not allowed to act as parent (e.g. FROM ONLY) */
122
+ if (PARENTHOOD_DISALLOWED == get_rel_parenthood_status (inner_rte ))
123
+ return ;
124
+
117
125
/* Proceed iff relation 'innerrel' is partitioned */
118
126
if ((inner_prel = get_pathman_relation_info (inner_rte -> relid )) == NULL )
119
127
return ;
120
128
121
- /* Skip if inner table is not allowed to act as parent (e.g. FROM ONLY) */
122
- if (PARENTHOOD_DISALLOWED == get_rel_parenthood_status (inner_rte ))
123
- goto cleanup ;
124
-
125
129
/*
126
130
* Check if query is:
127
131
* 1) UPDATE part_table SET = .. FROM part_table.
@@ -294,7 +298,6 @@ pathman_join_pathlist_hook(PlannerInfo *root,
294
298
add_path (joinrel , (Path * ) nest_path );
295
299
}
296
300
297
- cleanup :
298
301
/* Don't forget to close 'inner_prel'! */
299
302
close_pathman_relation_info (inner_prel );
300
303
}
@@ -380,14 +383,22 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
380
383
foreach (lc , root -> append_rel_list )
381
384
{
382
385
AppendRelInfo * appinfo = (AppendRelInfo * ) lfirst (lc );
386
+ Oid child_oid ,
387
+ parent_oid ;
388
+
389
+ /* Is it actually the same table? */
390
+ child_oid = root -> simple_rte_array [appinfo -> child_relid ]-> relid ;
391
+ parent_oid = root -> simple_rte_array [appinfo -> parent_relid ]-> relid ;
383
392
384
393
/*
385
394
* If there's an 'appinfo', it means that somebody
386
395
* (PG?) has already processed this partitioned table
387
396
* and added its children to the plan.
388
397
*/
389
- if (appinfo -> child_relid == rti )
398
+ if (appinfo -> child_relid == rti && child_oid == parent_oid )
399
+ {
390
400
goto cleanup ;
401
+ }
391
402
}
392
403
}
393
404
@@ -419,9 +430,6 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
419
430
pathkeyDesc = (PathKey * ) linitial (pathkeys );
420
431
}
421
432
422
- /* Mark as partitioned table */
423
- assign_rel_parenthood_status (rte , PARENTHOOD_DISALLOWED );
424
-
425
433
children = PrelGetChildrenArray (prel );
426
434
ranges = list_make1_irange_full (prel , IR_COMPLETE );
427
435
0 commit comments