diff options
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 58bfd491307..f98cce49c7e 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -544,8 +544,13 @@ create_scan_plan(PlannerInfo *root, Path *best_path, int flags) { /* For index-only scan, the preferred tlist is the index's */ tlist = copyObject(((IndexPath *) best_path)->indexinfo->indextlist); - /* Transfer any sortgroupref data to the replacement tlist */ - apply_pathtarget_labeling_to_tlist(tlist, best_path->pathtarget); + + /* + * Transfer any sortgroupref data to the replacement tlist, unless + * we don't care because the gating Result will handle it. + */ + if (!gating_clauses) + apply_pathtarget_labeling_to_tlist(tlist, best_path->pathtarget); } else { @@ -557,8 +562,9 @@ create_scan_plan(PlannerInfo *root, Path *best_path, int flags) } else { - /* Transfer any sortgroupref data to the replacement tlist */ - apply_pathtarget_labeling_to_tlist(tlist, best_path->pathtarget); + /* As above, transfer sortgroupref data to replacement tlist */ + if (!gating_clauses) + apply_pathtarget_labeling_to_tlist(tlist, best_path->pathtarget); } } } |