summaryrefslogtreecommitdiff
path: root/src/backend/access/hash/hashfunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/hash/hashfunc.c')
-rw-r--r--src/backend/access/hash/hashfunc.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c
index 8709dd7b19..78af6353f0 100644
--- a/src/backend/access/hash/hashfunc.c
+++ b/src/backend/access/hash/hashfunc.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.23 2000/01/26 05:55:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.24 2000/02/21 03:36:46 tgl Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
@@ -146,8 +146,24 @@ hashoidvector(Oid *key)
int i;
uint32 result = 0;
- for (i = 0; i < INDEX_MAX_KEYS; i++)
- result = result ^ (~(uint32) key[i]);
+ for (i = INDEX_MAX_KEYS; --i >= 0; )
+ result = (result << 1) ^ (~(uint32) key[i]);
+ return result;
+}
+
+/*
+ * Note: hashint2vector currently can't be used as a user hash table
+ * hash function, because it has no pg_proc entry. We only need it
+ * for catcache indexing.
+ */
+uint32
+hashint2vector(int16 *key)
+{
+ int i;
+ uint32 result = 0;
+
+ for (i = INDEX_MAX_KEYS; --i >= 0; )
+ result = (result << 1) ^ (~(uint32) key[i]);
return result;
}
@@ -158,13 +174,10 @@ hashoidvector(Oid *key)
uint32
hashchar(char key)
{
- int len;
uint32 h;
- h = 0;
- len = sizeof(char);
/* Convert char to integer */
- h = h * PRIME1 ^ (key - ' ');
+ h = (key - ' ');
h %= PRIME2;
return h;