@@ -1637,14 +1637,16 @@ set_append_references(PlannerInfo *root,
16371637 * See if it's safe to get rid of the Append entirely. For this to be
16381638 * safe, there must be only one child plan and that child plan's parallel
16391639 * awareness must match that of the Append's. The reason for the latter
1640- * is that the if the Append is parallel aware and the child is not then
1641- * the calling plan may execute the non-parallel aware child multiple
1642- * times.
1640+ * is that if the Append is parallel aware and the child is not, then the
1641+ * calling plan may execute the non-parallel aware child multiple times.
16431642 */
1644- if (list_length (aplan -> appendplans ) == 1 &&
1645- ((Plan * ) linitial (aplan -> appendplans ))-> parallel_aware == aplan -> plan .parallel_aware )
1646- return clean_up_removed_plan_level ((Plan * ) aplan ,
1647- (Plan * ) linitial (aplan -> appendplans ));
1643+ if (list_length (aplan -> appendplans ) == 1 )
1644+ {
1645+ Plan * p = (Plan * ) linitial (aplan -> appendplans );
1646+
1647+ if (p -> parallel_aware == aplan -> plan .parallel_aware )
1648+ return clean_up_removed_plan_level ((Plan * ) aplan , p );
1649+ }
16481650
16491651 /*
16501652 * Otherwise, clean up the Append as needed. It's okay to do this after
@@ -1709,14 +1711,17 @@ set_mergeappend_references(PlannerInfo *root,
17091711 * See if it's safe to get rid of the MergeAppend entirely. For this to
17101712 * be safe, there must be only one child plan and that child plan's
17111713 * parallel awareness must match that of the MergeAppend's. The reason
1712- * for the latter is that the if the MergeAppend is parallel aware and the
1714+ * for the latter is that if the MergeAppend is parallel aware and the
17131715 * child is not then the calling plan may execute the non-parallel aware
17141716 * child multiple times.
17151717 */
1716- if (list_length (mplan -> mergeplans ) == 1 &&
1717- ((Plan * ) linitial (mplan -> mergeplans ))-> parallel_aware == mplan -> plan .parallel_aware )
1718- return clean_up_removed_plan_level ((Plan * ) mplan ,
1719- (Plan * ) linitial (mplan -> mergeplans ));
1718+ if (list_length (mplan -> mergeplans ) == 1 )
1719+ {
1720+ Plan * p = (Plan * ) linitial (mplan -> mergeplans );
1721+
1722+ if (p -> parallel_aware == mplan -> plan .parallel_aware )
1723+ return clean_up_removed_plan_level ((Plan * ) mplan , p );
1724+ }
17201725
17211726 /*
17221727 * Otherwise, clean up the MergeAppend as needed. It's okay to do this
0 commit comments