@@ -248,6 +248,12 @@ get_partition_oids(List *ranges, int *n, const PartRelationInfo *prel)
248248 Oid * result = (Oid * ) palloc (allocated * sizeof (Oid ));
249249 Oid * children = PrelGetChildrenArray (prel );
250250
251+ /* If required, add parent to result */
252+ Assert (INITIAL_ALLOC_NUM >= 1 );
253+ if (prel -> enable_parent )
254+ result [used ++ ] = PrelParentRelid (prel );
255+
256+ /* Deal with selected partitions */
251257 foreach (range_cell , ranges )
252258 {
253259 uint32 i ;
@@ -366,6 +372,10 @@ create_append_plan_common(PlannerInfo *root, RelOptInfo *rel,
366372 {
367373 Plan * child_plan = (Plan * ) lfirst (lc2 );
368374 RelOptInfo * child_rel = ((Path * ) lfirst (lc1 ))-> parent ;
375+ Oid child_relid ;
376+
377+ /* Fetch relid of the 'child_rel' */
378+ child_relid = root -> simple_rte_array [child_rel -> relid ]-> relid ;
369379
370380 /* Replace rel's tlist with a matching one */
371381 if (!cscan -> scan .plan .targetlist )
@@ -380,6 +390,10 @@ create_append_plan_common(PlannerInfo *root, RelOptInfo *rel,
380390 if (!cscan -> custom_scan_tlist )
381391 cscan -> custom_scan_tlist = replace_tlist_varnos (child_plan -> targetlist ,
382392 rel );
393+
394+ /* If this is a plan for parent table, fill it with quals */
395+ if (PrelParentRelid (prel ) == child_relid )
396+ child_plan -> qual = get_actual_clauses (clauses );
383397 }
384398 }
385399
0 commit comments