Define variable only in the scope that needs it - Mailing list pgsql-hackers

From Antonin Houska
Subject Define variable only in the scope that needs it
Date
Msg-id 31698.1521544277@localhost
Whole thread Raw
Responses Re: Define variable only in the scope that needs it  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
I suppose the current definition in the higher scope is not intentional. This
is what I suggest:

diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
new file mode 100644
index 9c4a1ba..ae35e1e
*** a/src/backend/optimizer/plan/planner.c
--- b/src/backend/optimizer/plan/planner.c
*************** create_ordinary_grouping_paths(PlannerIn
*** 3837,3843 ****
  {
      Query       *parse = root->parse;
      Path       *cheapest_path = input_rel->cheapest_total_path;
-     AggClauseCosts agg_partial_costs;    /* parallel only */
      AggClauseCosts agg_final_costs; /* parallel only */
      double        dNumGroups;
      bool        can_hash;
--- 3837,3842 ----
*************** create_ordinary_grouping_paths(PlannerIn
*** 3904,3909 ****
--- 3903,3909 ----
      if (try_parallel_aggregation)
      {
          PathTarget *partial_grouping_target;
+         AggClauseCosts agg_partial_costs;    /* parallel only */

          /*
           * Build target list for partial aggregate paths.  These paths cannot


--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com


pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: [HACKERS] path toward faster partition pruning
Next
From: Eren Başak
Date:
Subject: Re: [HACKERS] Optional message to user when terminating/cancelling backend