diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-12-30 15:21:23 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-12-30 15:21:23 +0000 |
commit | a0fa0117a5ad728b6f85a39cc52006736f54f90e (patch) | |
tree | 80e4e43aea88ace1e0668ea9f63c9767bb64b63f /src/backend/executor/nodeHashjoin.c | |
parent | e533e7dcf53e7df2d8241b9db33ef33ac0b96d21 (diff) | |
download | postgresql-a0fa0117a5ad728b6f85a39cc52006736f54f90e.tar.gz postgresql-a0fa0117a5ad728b6f85a39cc52006736f54f90e.zip |
Better solution to integer overflow problem in hash batch-number
computation: reduce the bucket number mod nbatch. This changes the
association between original bucket numbers and batches, but that
doesn't matter. Minor other cleanups in hashjoin code to help
centralize decisions.
Diffstat (limited to 'src/backend/executor/nodeHashjoin.c')
-rw-r--r-- | src/backend/executor/nodeHashjoin.c | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 8f899b577d7..48cf30c21f4 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.45 2002/12/15 16:17:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.46 2002/12/30 15:21:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,6 @@ static TupleTableSlot *ExecHashJoinOuterGetTuple(PlanState *node, static TupleTableSlot *ExecHashJoinGetSavedTuple(HashJoinState *hjstate, BufFile *file, TupleTableSlot *tupleSlot); -static int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable); static int ExecHashJoinNewBatch(HashJoinState *hjstate); @@ -179,17 +178,15 @@ ExecHashJoin(HashJoinState *node) */ if (hashtable->curbatch == 0) { - int batch = ExecHashJoinGetBatch(node->hj_CurBucketNo, - hashtable); + int batchno = ExecHashGetBatch(node->hj_CurBucketNo, + hashtable); - if (batch > 0) + if (batchno >= 0) { /* * Need to postpone this outer tuple to a later batch. * Save it in the corresponding outer-batch file. */ - int batchno = batch - 1; - hashtable->outerBatchSize[batchno]++; ExecHashJoinSaveTuple(outerTupleSlot->val, hashtable->outerBatchFile[batchno]); @@ -641,28 +638,6 @@ ExecHashJoinNewBatch(HashJoinState *hjstate) } /* ---------------------------------------------------------------- - * ExecHashJoinGetBatch - * - * determine the batch number for a bucketno - * +----------------+-------+-------+ ... +-------+ - * 0 nbuckets totalbuckets - * batch 0 1 2 ... - * ---------------------------------------------------------------- - */ -static int -ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable) -{ - int b; - - if (bucketno < hashtable->nbuckets || hashtable->nbatch == 0) - return 0; - - b = (hashtable->nbatch * (bucketno - hashtable->nbuckets)) / - (hashtable->totalbuckets - hashtable->nbuckets); - return b + 1; -} - -/* ---------------------------------------------------------------- * ExecHashJoinSaveTuple * * save a tuple to a tmp file. |