summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-09-17 18:29:54 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-09-17 18:29:54 +0000
commitf4d5c52a83b9af2346e58c2e036469b8a14cabfa (patch)
tree9f303e927441e6b36a6ca83626c9e3a8534b2139
parent3c06653fbd58d5e3708bb6b251e66321a35a5f39 (diff)
downloadpostgresql-f4d5c52a83b9af2346e58c2e036469b8a14cabfa.tar.gz
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.
-rw-r--r--src/backend/executor/nodeHashjoin.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
index 12f6d58443..7d3924b497 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.38 2001/03/22 06:16:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.38.2.1 2004/09/17 18:29:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -575,12 +575,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;