From 9c837a7345f8c4440928c2d26a004662b0e4ca21 Mon Sep 17 00:00:00 2001
From: Peter Geoghegan <pg@bowt.ie>
Date: Mon, 13 Jul 2020 17:06:06 -0700
Subject: [PATCH v2 1/2] Rename hash_mem local variable.

The variable name hash_mem will take on new significance due to an
upcoming patch that will add a hash_mem_multiplier work_mem GUC.  Update
a local variable name to avoid ambiguity.

This patch does not rename fields from the AggState or
AggregateInstrumentation structs, though that seems worth considering.
(These structs have fields that use a variation of the name "hash_mem".)
---
 src/backend/executor/nodeAgg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 8eb1732ca8..b79c845a6b 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -1896,7 +1896,7 @@ static void
 hash_agg_update_metrics(AggState *aggstate, bool from_tape, int npartitions)
 {
 	Size		meta_mem;
-	Size		hash_mem;
+	Size		hashkey_mem;
 	Size		buffer_mem;
 	Size		total_mem;
 
@@ -1908,7 +1908,7 @@ hash_agg_update_metrics(AggState *aggstate, bool from_tape, int npartitions)
 	meta_mem = MemoryContextMemAllocated(aggstate->hash_metacxt, true);
 
 	/* memory for the group keys and transition states */
-	hash_mem = MemoryContextMemAllocated(aggstate->hashcontext->ecxt_per_tuple_memory, true);
+	hashkey_mem = MemoryContextMemAllocated(aggstate->hashcontext->ecxt_per_tuple_memory, true);
 
 	/* memory for read/write tape buffers, if spilled */
 	buffer_mem = npartitions * HASHAGG_WRITE_BUFFER_SIZE;
@@ -1916,7 +1916,7 @@ hash_agg_update_metrics(AggState *aggstate, bool from_tape, int npartitions)
 		buffer_mem += HASHAGG_READ_BUFFER_SIZE;
 
 	/* update peak mem */
-	total_mem = meta_mem + hash_mem + buffer_mem;
+	total_mem = meta_mem + hashkey_mem + buffer_mem;
 	if (total_mem > aggstate->hash_mem_peak)
 		aggstate->hash_mem_peak = total_mem;
 
@@ -1934,7 +1934,7 @@ hash_agg_update_metrics(AggState *aggstate, bool from_tape, int npartitions)
 	{
 		aggstate->hashentrysize =
 			sizeof(TupleHashEntryData) +
-			(hash_mem / (double) aggstate->hash_ngroups_current);
+			(hashkey_mem / (double) aggstate->hash_ngroups_current);
 	}
 }
 
-- 
2.25.1

