aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeHash.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-06-22 22:04:55 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-06-22 22:04:55 +0000
commitbff0422b6c8f65b2f8210d8690a7f63f8d6e2782 (patch)
treea3ec649b7c6251efdae2be1b923462979ad7184e /src/backend/executor/nodeHash.c
parent0dda75f6eb4bb9d65a7c2ad729fbf21d616c1bb1 (diff)
downloadpostgresql-bff0422b6c8f65b2f8210d8690a7f63f8d6e2782.tar.gz
postgresql-bff0422b6c8f65b2f8210d8690a7f63f8d6e2782.zip
Revise hash join and hash aggregation code to use the same datatype-
specific hash functions used by hash indexes, rather than the old not-datatype-aware ComputeHashFunc routine. This makes it safe to do hash joining on several datatypes that previously couldn't use hashing. The sets of datatypes that are hash indexable and hash joinable are now exactly the same, whereas before each had some that weren't in the other.
Diffstat (limited to 'src/backend/executor/nodeHash.c')
-rw-r--r--src/backend/executor/nodeHash.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index b338c8961e2..f00cc28684d 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.75 2003/03/27 16:51:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.76 2003/06/22 22:04:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -192,7 +192,7 @@ ExecEndHash(HashState *node)
* ----------------------------------------------------------------
*/
HashJoinTable
-ExecHashTableCreate(Hash *node)
+ExecHashTableCreate(Hash *node, List *hashOperators)
{
HashJoinTable hashtable;
Plan *outerNode;
@@ -201,7 +201,7 @@ ExecHashTableCreate(Hash *node)
int nbatch;
int nkeys;
int i;
- List *hk;
+ List *ho;
MemoryContext oldcxt;
/*
@@ -237,17 +237,20 @@ ExecHashTableCreate(Hash *node)
hashtable->outerBatchSize = NULL;
/*
- * Get info about the datatypes of the hash keys.
+ * Get info about the hash functions to be used for each hash key.
*/
- nkeys = length(node->hashkeys);
- hashtable->typLens = (int16 *) palloc(nkeys * sizeof(int16));
- hashtable->typByVals = (bool *) palloc(nkeys * sizeof(bool));
+ nkeys = length(hashOperators);
+ hashtable->hashfunctions = (FmgrInfo *) palloc(nkeys * sizeof(FmgrInfo));
i = 0;
- foreach(hk, node->hashkeys)
+ foreach(ho, hashOperators)
{
- get_typlenbyval(exprType(lfirst(hk)),
- &hashtable->typLens[i],
- &hashtable->typByVals[i]);
+ Oid hashfn;
+
+ hashfn = get_op_hash_function(lfirsto(ho));
+ if (!OidIsValid(hashfn))
+ elog(ERROR, "Could not find hash function for hash operator %u",
+ lfirsto(ho));
+ fmgr_info(hashfn, &hashtable->hashfunctions[i]);
i++;
}
@@ -520,7 +523,7 @@ ExecHashGetBucket(HashJoinTable hashtable,
/*
* We reset the eval context each time to reclaim any memory leaked in
- * the hashkey expressions or ComputeHashFunc itself.
+ * the hashkey expressions.
*/
ResetExprContext(econtext);
@@ -545,9 +548,11 @@ ExecHashGetBucket(HashJoinTable hashtable,
*/
if (!isNull) /* treat nulls as having hash key 0 */
{
- hashkey ^= ComputeHashFunc(keyval,
- (int) hashtable->typLens[i],
- hashtable->typByVals[i]);
+ uint32 hkey;
+
+ hkey = DatumGetUInt32(FunctionCall1(&hashtable->hashfunctions[i],
+ keyval));
+ hashkey ^= hkey;
}
i++;