Define variable only in the scope that needs it

Started by Antonin Houskaalmost 8 years ago2 messages
#1Antonin Houska
ah@cybertec.at

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

#2Robert Haas
robertmhaas@gmail.com
In reply to: Antonin Houska (#1)
Re: Define variable only in the scope that needs it

On Tue, Mar 20, 2018 at 7:11 AM, Antonin Houska <ah@cybertec.at> wrote:

I suppose the current definition in the higher scope is not intentional. This
is what I suggest:

This is moot in light of commit 4f15e5d09de276fb77326be5567dd9796008ca2e.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company