Save PathTargets for distinct/ordered relations in root->upper_targets[].
authorEtsuro Fujita <[email protected]>
Mon, 18 Feb 2019 07:13:46 +0000 (16:13 +0900)
committerEtsuro Fujita <[email protected]>
Mon, 18 Feb 2019 07:13:46 +0000 (16:13 +0900)
For the convenience of extensions, we previously only saved PathTargets
for grouped, window, and final relations in root->upper_targets[] in
grouping_planner().  To improve the convenience, save PathTargets for
distinct and ordered relations as well.

Author: Antonin Houska, with an additional change by me
Discussion: https://postgr.es/m/10994.1549559088@localhost

src/backend/optimizer/plan/planner.c

index 4e52c4272113c5368d00fe8c78628411b38c6985..1a58d733fa655bc31701b8bb9fc76ef536fc2822 100644 (file)
@@ -2035,6 +2035,8 @@ grouping_planner(PlannerInfo *root, bool inheritance_update,
         * of the corresponding upperrels might not be needed for this query.
         */
        root->upper_targets[UPPERREL_FINAL] = final_target;
+       root->upper_targets[UPPERREL_ORDERED] = final_target;
+       root->upper_targets[UPPERREL_DISTINCT] = sort_input_target;
        root->upper_targets[UPPERREL_WINDOW] = sort_input_target;
        root->upper_targets[UPPERREL_GROUP_AGG] = grouping_target;