Fix a couple of planner bugs in Gather Merge.
authorRobert Haas <rhaas@postgresql.org>
Thu, 9 Mar 2017 17:05:54 +0000 (12:05 -0500)
committerRobert Haas <rhaas@postgresql.org>
Thu, 9 Mar 2017 17:06:49 +0000 (12:06 -0500)
Neha Sharma reported these to Rushabh Lathia just after I commit
355d3993c53ed62c5b53d020648e4fbcfbf5f155 went in.  The patch is
Rushabh's, with input from me.

src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/planner.c

index e18c634a7be86ff7dda5982d4f3f7ae4889d9b81..d002e6d5672d0078d13a11ebb6f54e6674a0ff96 100644 (file)
@@ -1474,13 +1474,14 @@ create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path)
        Oid                *sortOperators;
        Oid                *collations;
        bool       *nullsFirst;
+       List       *tlist = build_path_tlist(root, &best_path->path);
 
        /* As with Gather, it's best to project away columns in the workers. */
        subplan = create_plan_recurse(root, best_path->subpath, CP_EXACT_TLIST);
 
        /* See create_merge_append_plan for why there's no make_xxx function */
        gm_plan = makeNode(GatherMerge);
-       gm_plan->plan.targetlist = subplan->targetlist;
+       gm_plan->plan.targetlist = tlist;
        gm_plan->num_workers = best_path->num_workers;
        copy_generic_path_info(&gm_plan->plan, &best_path->path);
 
index 209f76963263e4c5895239e59e6cb845b4b177d8..02286d9c52f397783cbdd40559e65334de49183e 100644 (file)
@@ -3746,7 +3746,7 @@ create_grouping_paths(PlannerInfo *root,
                                                create_gather_merge_path(root,
                                                                                                 grouped_rel,
                                                                                                 subpath,
-                                                                                                NULL,
+                                                                                                partial_grouping_target,
                                                                                                 root->group_pathkeys,
                                                                                                 NULL,
                                                                                                 &total_groups);