diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index d002e6d..73a71d7 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -1499,7 +1499,6 @@ create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path) &gm_plan->collations, &gm_plan->nullsFirst); - /* Compute sort column info, and adjust subplan's tlist as needed */ subplan = prepare_sort_from_pathkeys(subplan, pathkeys, best_path->subpath->parent->relids, @@ -1511,11 +1510,13 @@ create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path) &collations, &nullsFirst); - /* As for MergeAppend, check that we got the same sort key information. */ + /* + * As for MergeAppend, check that we got the same sort key information. + * Unlike MergeAppend, for GatherMerge its not necessary that tlists + * for the path and subpath match up as GatherMerge is projection capable + * plan. So removed that check from here. + */ Assert(numsortkeys == gm_plan->numCols); - if (memcmp(sortColIdx, gm_plan->sortColIdx, - numsortkeys * sizeof(AttrNumber)) != 0) - elog(ERROR, "GatherMerge child's targetlist doesn't match GatherMerge"); Assert(memcmp(sortOperators, gm_plan->sortOperators, numsortkeys * sizeof(Oid)) == 0); Assert(memcmp(collations, gm_plan->collations,