summaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/nodeHashjoin.c12
-rw-r--r--src/backend/executor/nodeMergejoin.c16
-rw-r--r--src/backend/executor/nodeNestloop.c12
3 files changed, 34 insertions, 6 deletions
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
index 48cf30c21f..d452d3865f 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.46 2002/12/30 15:21:20 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.47 2003/01/20 18:54:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -96,6 +96,15 @@ ExecHashJoin(HashJoinState *node)
}
/*
+ * If we're doing an IN join, we want to return at most one row per
+ * outer tuple; so we can stop scanning the inner scan if we matched on
+ * the previous try.
+ */
+ if (node->js.jointype == JOIN_IN &&
+ node->hj_MatchedOuter)
+ node->hj_NeedNewOuter = true;
+
+ /*
* Reset per-tuple memory context to free any expression evaluation
* storage allocated in the previous tuple cycle. Note this can't
* happen until we're done projecting out tuples from a join tuple.
@@ -353,6 +362,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
switch (node->join.jointype)
{
case JOIN_INNER:
+ case JOIN_IN:
break;
case JOIN_LEFT:
hjstate->hj_NullInnerTupleSlot =
diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c
index af6cd8d6f3..d5dc7f421a 100644
--- a/src/backend/executor/nodeMergejoin.c
+++ b/src/backend/executor/nodeMergejoin.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.55 2002/12/15 16:17:46 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.56 2003/01/20 18:54:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -381,6 +381,7 @@ ExecMergeJoin(MergeJoinState *node)
switch (node->js.jointype)
{
case JOIN_INNER:
+ case JOIN_IN:
doFillOuter = false;
doFillInner = false;
break;
@@ -581,9 +582,15 @@ ExecMergeJoin(MergeJoinState *node)
* the econtext's tuple pointers were set up before
* checking the merge qual, so we needn't do it again.
*/
- qualResult = (joinqual == NIL ||
- ExecQual(joinqual, econtext, false));
- MJ_DEBUG_QUAL(joinqual, qualResult);
+ if (node->js.jointype == JOIN_IN &&
+ node->mj_MatchedOuter)
+ qualResult = false;
+ else
+ {
+ qualResult = (joinqual == NIL ||
+ ExecQual(joinqual, econtext, false));
+ MJ_DEBUG_QUAL(joinqual, qualResult);
+ }
if (qualResult)
{
@@ -1452,6 +1459,7 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate)
switch (node->join.jointype)
{
case JOIN_INNER:
+ case JOIN_IN:
break;
case JOIN_LEFT:
mergestate->mj_NullInnerTupleSlot =
diff --git a/src/backend/executor/nodeNestloop.c b/src/backend/executor/nodeNestloop.c
index 917a7011cb..1bae980589 100644
--- a/src/backend/executor/nodeNestloop.c
+++ b/src/backend/executor/nodeNestloop.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.29 2002/12/15 16:17:46 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.30 2003/01/20 18:54:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,6 +102,15 @@ ExecNestLoop(NestLoopState *node)
}
/*
+ * If we're doing an IN join, we want to return at most one row per
+ * outer tuple; so we can stop scanning the inner scan if we matched on
+ * the previous try.
+ */
+ if (node->js.jointype == JOIN_IN &&
+ node->nl_MatchedOuter)
+ node->nl_NeedNewOuter = true;
+
+ /*
* Reset per-tuple memory context to free any expression evaluation
* storage allocated in the previous tuple cycle. Note this can't
* happen until we're done projecting out tuples from a join tuple.
@@ -312,6 +321,7 @@ ExecInitNestLoop(NestLoop *node, EState *estate)
switch (node->join.jointype)
{
case JOIN_INNER:
+ case JOIN_IN:
break;
case JOIN_LEFT:
nlstate->nl_NullInnerTupleSlot =