diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-22 22:04:55 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-22 22:04:55 +0000 |
commit | bff0422b6c8f65b2f8210d8690a7f63f8d6e2782 (patch) | |
tree | a3ec649b7c6251efdae2be1b923462979ad7184e /src/backend/executor/nodeAgg.c | |
parent | 0dda75f6eb4bb9d65a7c2ad729fbf21d616c1bb1 (diff) | |
download | postgresql-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/nodeAgg.c')
-rw-r--r-- | src/backend/executor/nodeAgg.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index f2499cb4e5e..d0dd6b31c99 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -45,7 +45,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.106 2003/06/06 15:04:01 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.107 2003/06/22 22:04:54 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -582,6 +582,7 @@ build_hash_table(AggState *aggstate) aggstate->hashtable = BuildTupleHashTable(node->numCols, node->grpColIdx, aggstate->eqfunctions, + aggstate->hashfunctions, node->numGroups, entrysize, aggstate->aggcontext, @@ -1035,6 +1036,7 @@ ExecInitAgg(Agg *node, EState *estate) aggstate->aggs = NIL; aggstate->numaggs = 0; aggstate->eqfunctions = NULL; + aggstate->hashfunctions = NULL; aggstate->peragg = NULL; aggstate->agg_done = false; aggstate->pergroup = NULL; @@ -1123,14 +1125,23 @@ ExecInitAgg(Agg *node, EState *estate) } /* - * If we are grouping, precompute fmgr lookup data for inner loop + * If we are grouping, precompute fmgr lookup data for inner loop. + * We need both equality and hashing functions to do it by hashing, + * but only equality if not hashing. */ if (node->numCols > 0) { - aggstate->eqfunctions = - execTuplesMatchPrepare(ExecGetScanType(&aggstate->ss), - node->numCols, - node->grpColIdx); + if (node->aggstrategy == AGG_HASHED) + execTuplesHashPrepare(ExecGetScanType(&aggstate->ss), + node->numCols, + node->grpColIdx, + &aggstate->eqfunctions, + &aggstate->hashfunctions); + else + aggstate->eqfunctions = + execTuplesMatchPrepare(ExecGetScanType(&aggstate->ss), + node->numCols, + node->grpColIdx); } /* |