postgres.git / summary / log / commit / refs

commit    44ed69c8f3b3e21153af60cc22287fd0258878fe
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Fri Sep 17 18:29:40 2004 +0000
First released in: 8.0.0, 7.2.6, 7.3.8, 7.4.6

    Hashed LEFT JOIN would miss outer tuples with no inner match if the join
    was large enough to be batched and the tuples fell into a batch where
    there were no inner tuples at all.  Thanks to Xiaoyu Wang for finding a
    test case that exposed this long-standing bug.


src/backend/executor/nodeHashjoin.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 58e97b8adb1..64ab1cc2338 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.39 2001/10/25 05:49:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.39.2.1 2004/09/17 18:29:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -569,12 +569,14 @@ ExecHashJoinNewBatch(HashJoinState *hjstate) } /* - * We can skip over any batches that are empty on either side. Release - * associated temp files right away. + * Normally we can skip over any batches that are empty on either side + * --- but for JOIN_LEFT, can only skip when left side is empty. + * Release associated temp files right away. */ while (newbatch <= nbatch && - (innerBatchSize[newbatch - 1] == 0L || - outerBatchSize[newbatch - 1] == 0L)) + (outerBatchSize[newbatch - 1] == 0L || + (innerBatchSize[newbatch - 1] == 0L && + hjstate->js.jointype != JOIN_LEFT))) { BufFileClose(hashtable->innerBatchFile[newbatch - 1]); hashtable->innerBatchFile[newbatch - 1] = NULL; [parent: a59084fe5e72]