@@ -498,7 +498,7 @@ generate_recursion_path(SetOperationStmt *setOp, PlannerInfo *root,
498
498
* interesting_pathkeys: if not NIL, also include paths that suit these
499
499
* pathkeys, sorting any unsorted paths as required.
500
500
* *pNumGroups: if not NULL, we estimate the number of distinct groups
501
- * in the result, and store it there
501
+ * in the result, and store it there.
502
502
*/
503
503
static void
504
504
build_setop_child_paths (PlannerInfo * root , RelOptInfo * rel ,
@@ -714,7 +714,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
714
714
List * groupList = NIL ;
715
715
Path * apath ;
716
716
Path * gpath = NULL ;
717
- bool try_sorted ;
717
+ bool try_sorted = false ;
718
718
List * union_pathkeys = NIL ;
719
719
720
720
/*
@@ -740,18 +740,21 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
740
740
tlist_list , refnames_tlist );
741
741
* pTargetList = tlist ;
742
742
743
- /* For for UNIONs (not UNION ALL), try sorting, if sorting is possible */
744
- try_sorted = !op -> all && grouping_is_sortable (op -> groupClauses );
745
-
746
- if (try_sorted )
743
+ /* For UNIONs (not UNION ALL), try sorting, if sorting is possible */
744
+ if (!op -> all )
747
745
{
748
746
/* Identify the grouping semantics */
749
747
groupList = generate_setop_grouplist (op , tlist );
750
748
751
- /* Determine the pathkeys for sorting by the whole target list */
752
- union_pathkeys = make_pathkeys_for_sortclauses (root , groupList , tlist );
749
+ if (grouping_is_sortable (op -> groupClauses ))
750
+ {
751
+ try_sorted = true;
752
+ /* Determine the pathkeys for sorting by the whole target list */
753
+ union_pathkeys = make_pathkeys_for_sortclauses (root , groupList ,
754
+ tlist );
753
755
754
- root -> query_pathkeys = union_pathkeys ;
756
+ root -> query_pathkeys = union_pathkeys ;
757
+ }
755
758
}
756
759
757
760
/*
0 commit comments