aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorKevin Grittner <kgrittn@postgresql.org>2015-08-19 08:31:13 -0500
committerKevin Grittner <kgrittn@postgresql.org>2015-08-19 08:31:13 -0500
commit24bf2ee22233244eb9e2c71de754b1c71258d004 (patch)
treeefb68ecd652be2a5a90a053d0155143409863d98 /src/backend/executor
parent4c3754ffe0f5f85cdecd01d7c1ab55df94559302 (diff)
downloadpostgresql-24bf2ee22233244eb9e2c71de754b1c71258d004.tar.gz
postgresql-24bf2ee22233244eb9e2c71de754b1c71258d004.zip
Fix bug in calculations of hash join buckets.
Commit 8cce08f168481c5fc5be4e7e29b968e314f1b41e used a left-shift on a literal of 1 that could (in large allocations) be shifted by 31 or more bits. This was assigned to a local variable that was already declared to be a long to protect against overruns of int, but the literal in this shift needs to be declared long to allow it to work correctly in some compilers. Backpatch to 9.5, where the bug was introduced. Report and patch by KaiGai Kohei, slighly modified based on discussion.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/nodeHash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index ee9298a157f..0b2c13917ee 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -518,7 +518,7 @@ 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));
- lbuckets = 1 << my_log2(hash_table_bytes / bucket_size);
+ lbuckets = 1L << my_log2(hash_table_bytes / bucket_size);
lbuckets = Min(lbuckets, max_pointers);
nbuckets = (int) lbuckets;
bucket_bytes = nbuckets * sizeof(HashJoinTuple);