aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/hash/hashfn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/hash/hashfn.c')
-rw-r--r--src/backend/utils/hash/hashfn.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c
index ed0826e8e51..af528881eff 100644
--- a/src/backend/utils/hash/hashfn.c
+++ b/src/backend/utils/hash/hashfn.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.27 2006/07/14 14:52:25 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.28 2006/09/27 18:40:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,8 +27,16 @@
uint32
string_hash(const void *key, Size keysize)
{
+ /*
+ * If the string exceeds keysize-1 bytes, we want to hash only that many,
+ * because when it is copied into the hash table it will be truncated at
+ * that length.
+ */
+ Size s_len = strlen((const char *) key);
+
+ s_len = Min(s_len, keysize-1);
return DatumGetUInt32(hash_any((const unsigned char *) key,
- (int) strlen((const char *) key)));
+ (int) s_len));
}
/*