From bff0422b6c8f65b2f8210d8690a7f63f8d6e2782 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 22 Jun 2003 22:04:55 +0000 Subject: 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. --- src/backend/executor/nodeHashjoin.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/backend/executor/nodeHashjoin.c') diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 17585b2f0f..9a0071f018 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.51 2003/05/30 20:23:10 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.52 2003/06/22 22:04:54 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -117,7 +117,8 @@ ExecHashJoin(HashJoinState *node) * create the hash table */ Assert(hashtable == NULL); - hashtable = ExecHashTableCreate((Hash *) hashNode->ps.plan); + hashtable = ExecHashTableCreate((Hash *) hashNode->ps.plan, + node->hj_HashOperators); node->hj_HashTable = hashtable; /* @@ -305,6 +306,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate) Plan *outerNode; Hash *hashNode; List *hclauses; + List *hoperators; List *hcl; /* @@ -406,8 +408,9 @@ ExecInitHashJoin(HashJoin *node, EState *estate) /* * The planner already made a list of the inner hashkeys for us, - * but we also need a list of the outer hashkeys. Each list of - * exprs must then be prepared for execution. + * but we also need a list of the outer hashkeys, as well as a list + * of the hash operator OIDs. Both lists of exprs must then be prepared + * for execution. */ hjstate->hj_InnerHashKeys = (List *) ExecInitExpr((Expr *) hashNode->hashkeys, @@ -416,13 +419,19 @@ ExecInitHashJoin(HashJoin *node, EState *estate) hjstate->hj_InnerHashKeys; hclauses = NIL; + hoperators = NIL; foreach(hcl, node->hashclauses) { - hclauses = lappend(hclauses, get_leftop(lfirst(hcl))); + OpExpr *hclause = (OpExpr *) lfirst(hcl); + + Assert(IsA(hclause, OpExpr)); + hclauses = lappend(hclauses, get_leftop((Expr *) hclause)); + hoperators = lappendo(hoperators, hclause->opno); } hjstate->hj_OuterHashKeys = (List *) ExecInitExpr((Expr *) hclauses, (PlanState *) hjstate); + hjstate->hj_HashOperators = hoperators; hjstate->js.ps.ps_OuterTupleSlot = NULL; hjstate->js.ps.ps_TupFromTlist = false; -- cgit v1.2.1