+/*
+ * create_gather_plan
+ *
+ * Create a Gather plan for 'best_path' and (recursively) plans
+ * for its subpaths.
+ */
+static Gather *
+create_gather_plan(PlannerInfo *root, GatherPath *best_path)
+{
+ Gather *gather_plan;
+ Plan *subplan;
+
+ subplan = create_plan_recurse(root, best_path->subpath);
+
+ gather_plan = make_gather(subplan->targetlist,
+ NIL,
+ best_path->num_workers,
+ best_path->single_copy,
+ subplan);
+
+ copy_path_costsize(&gather_plan->plan, &best_path->path);
+
+ /* use parallel mode for parallel plans. */
+ root->glob->parallelModeNeeded = true;
+
+ return gather_plan;
+}
+