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.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index b925517d7b1..c4409d33a2c 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.79 2003/08/04 02:39:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.79.4.1 2009/10/30 20:59:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -377,6 +377,8 @@ ExecChooseHashTableSize(double ntuples, int tupwidth,
nbuckets = (int) (hash_table_bytes / (bucketsize * FUDGE_FAC));
if (nbuckets <= 0)
nbuckets = 1;
+ /* Ensure we can allocate an array of nbuckets pointers */
+ nbuckets = Min(nbuckets, MaxAllocSize / sizeof(void *));
if (totalbuckets <= nbuckets)
{
@@ -401,10 +403,10 @@ ExecChooseHashTableSize(double ntuples, int tupwidth,
*/
dtmp = ceil((inner_rel_bytes - hash_table_bytes) /
hash_table_bytes);
- if (dtmp < INT_MAX)
+ if (dtmp < MaxAllocSize / sizeof(void *))
nbatch = (int) dtmp;
else
- nbatch = INT_MAX;
+ nbatch = MaxAllocSize / sizeof(void *);
if (nbatch <= 0)
nbatch = 1;
}