From 9af567f3654190c7ce71a77690c45f6fb29611fb Mon Sep 17 00:00:00 2001
From: Vaibhav Jain <jainva@google.com>
Date: Mon, 22 Sep 2025 18:11:08 +0530
Subject: Fix overflow of nbatch

With a1b4f28, to compute current_space, nbatch is being multiplied
by BLCKSZ. nbatch is int and when multiplied with BLCKSZ, it can
easily overflow the int limit. To keep the calculation safe for
current_space, convert nbatch to size_t.
---
 src/backend/executor/nodeHash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index a3415db4e20..c31beb540fd 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -667,7 +667,7 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
 	size_t		hash_table_bytes;
 	size_t		bucket_bytes;
 	size_t		max_pointers;
-	int			nbatch = 1;
+	size_t		nbatch = 1;
 	int			nbuckets;
 	double		dbuckets;

