diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-20 18:55:07 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-20 18:55:07 +0000 |
commit | bdfbfde1b168b3332c4cdac34ac86a80aaf4d442 (patch) | |
tree | f35bf1af04733069f3a6b0a2698ac10dbd6544ed /src/backend/executor/nodeHashjoin.c | |
parent | be2b660ecd5ca205570825633e7b8479379ddc64 (diff) | |
download | postgresql-bdfbfde1b168b3332c4cdac34ac86a80aaf4d442.tar.gz postgresql-bdfbfde1b168b3332c4cdac34ac86a80aaf4d442.zip |
IN clauses appearing at top level of WHERE can now be handled as joins.
There are two implementation techniques: the executor understands a new
JOIN_IN jointype, which emits at most one matching row per left-hand row,
or the result of the IN's sub-select can be fed through a DISTINCT filter
and then joined as an ordinary relation.
Along the way, some minor code cleanup in the optimizer; notably, break
out most of the jointree-rearrangement preprocessing in planner.c and
put it in a new file prep/prepjointree.c.
Diffstat (limited to 'src/backend/executor/nodeHashjoin.c')
-rw-r--r-- | src/backend/executor/nodeHashjoin.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 48cf30c21f4..d452d3865f5 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 = |