aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeHash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/nodeHash.c')
-rw-r--r--src/backend/executor/nodeHash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 123079c16cc..c48d92259f9 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -832,7 +832,10 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
* overhead for the hash code, pointer to the next tuple, etc.
*/
bucket_size = (tupsize * NTUP_PER_BUCKET + sizeof(HashJoinTuple));
- sbuckets = pg_nextpower2_size_t(hash_table_bytes / bucket_size);
+ if (hash_table_bytes <= bucket_size)
+ sbuckets = 1; /* avoid pg_nextpower2_size_t(0) */
+ else
+ sbuckets = pg_nextpower2_size_t(hash_table_bytes / bucket_size);
sbuckets = Min(sbuckets, max_pointers);
nbuckets = (int) sbuckets;
nbuckets = pg_nextpower2_32(nbuckets);