update comments

This commit is contained in:
Bruce Momjian 1999-02-24 10:20:07 +00:00
parent 02fa3e4394
commit f3f7c2acde
1 changed files with 89 additions and 78 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.23 1999/02/23 07:35:09 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.24 1999/02/24 10:20:07 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -288,7 +288,7 @@ MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext)
*/ */
#ifdef EXEC_MERGEJOINDEBUG #ifdef EXEC_MERGEJOINDEBUG
void void
ExecMergeTupleDumpInner(ExprContext *econtext); ExecMergeTupleDumpInner(ExprContext *econtext);
void void
ExecMergeTupleDumpInner(ExprContext *econtext) ExecMergeTupleDumpInner(ExprContext *econtext)
@ -305,7 +305,7 @@ ExecMergeTupleDumpInner(ExprContext *econtext)
} }
void void
ExecMergeTupleDumpOuter(ExprContext *econtext); ExecMergeTupleDumpOuter(ExprContext *econtext);
void void
ExecMergeTupleDumpOuter(ExprContext *econtext) ExecMergeTupleDumpOuter(ExprContext *econtext)
@ -321,8 +321,7 @@ ExecMergeTupleDumpOuter(ExprContext *econtext)
outerSlot->ttc_tupleDescriptor); outerSlot->ttc_tupleDescriptor);
} }
void void ExecMergeTupleDumpMarked(ExprContext *econtext,
ExecMergeTupleDumpMarked(ExprContext *econtext,
MergeJoinState *mergestate); MergeJoinState *mergestate);
void void
@ -342,7 +341,7 @@ ExecMergeTupleDumpMarked(ExprContext *econtext,
} }
void void
ExecMergeTupleDump(ExprContext *econtext, MergeJoinState *mergestate); ExecMergeTupleDump(ExprContext *econtext, MergeJoinState *mergestate);
void void
ExecMergeTupleDump(ExprContext *econtext, MergeJoinState *mergestate) ExecMergeTupleDump(ExprContext *econtext, MergeJoinState *mergestate)
@ -355,6 +354,7 @@ ExecMergeTupleDump(ExprContext *econtext, MergeJoinState *mergestate)
printf("******** \n"); printf("******** \n");
} }
#endif #endif
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
@ -427,11 +427,14 @@ ExecMergeJoin(MergeJoin *node)
ExprContext *econtext; ExprContext *econtext;
#ifdef ENABLE_OUTER_JOINS #ifdef ENABLE_OUTER_JOINS
/* These should be set from the expression context!
* - thomas 1999-02-20 /*
* These should be set from the expression context! - thomas
* 1999-02-20
*/ */
static bool isLeftJoin = true; static bool isLeftJoin = true;
static bool isRightJoin = false; static bool isRightJoin = false;
#endif #endif
/* ---------------- /* ----------------
@ -486,19 +489,19 @@ ExecMergeJoin(MergeJoin *node)
switch (mergestate->mj_JoinState) switch (mergestate->mj_JoinState)
{ {
/********************************* /*
* EXEC_MJ_INITIALIZE means that this is the first time * EXEC_MJ_INITIALIZE means that this is the first time
* ExecMergeJoin() has been called and so we have to initialize * ExecMergeJoin() has been called and so we have to
* the inner, outer and marked tuples as well as various stuff * initialize the inner, outer and marked tuples as well
* in the expression context. * as various stuff in the expression context.
*********************************/ */
case EXEC_MJ_INITIALIZE: case EXEC_MJ_INITIALIZE:
MJ_printf("ExecMergeJoin: EXEC_MJ_INITIALIZE\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_INITIALIZE\n");
/* ----------------
* Note: at this point, if either of our inner or outer /*
* tuples are nil, then the join ends immediately because * Note: at this point, if either of our inner or outer
* we know one of the subplans is empty. * tuples are nil, then the join ends immediately because
* ---------------- * we know one of the subplans is empty.
*/ */
innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node);
if (TupIsNull(innerTupleSlot)) if (TupIsNull(innerTupleSlot))
@ -531,11 +534,12 @@ ExecMergeJoin(MergeJoin *node)
mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; mergestate->mj_JoinState = EXEC_MJ_SKIPINNER;
break; break;
/********************************* /*
* EXEC_MJ_JOINMARK means we have just found a new outer tuple * EXEC_MJ_JOINMARK means we have just found a new outer
* and a possible matching inner tuple. This is the case after * tuple and a possible matching inner tuple. This is the
* the INITIALIZE, SKIPOUTER or SKIPINNER states. * case after the INITIALIZE, SKIPOUTER or SKIPINNER
*********************************/ * states.
*/
case EXEC_MJ_JOINMARK: case EXEC_MJ_JOINMARK:
MJ_printf("ExecMergeJoin: EXEC_MJ_JOINMARK\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_JOINMARK\n");
ExecMarkPos(innerPlan); ExecMarkPos(innerPlan);
@ -545,7 +549,7 @@ ExecMergeJoin(MergeJoin *node)
mergestate->mj_JoinState = EXEC_MJ_JOINTEST; mergestate->mj_JoinState = EXEC_MJ_JOINTEST;
break; break;
/********************************* /*
* EXEC_MJ_JOINTEST means we have two tuples which might * EXEC_MJ_JOINTEST means we have two tuples which might
* satisfy the merge clause, so we test them. * satisfy the merge clause, so we test them.
* *
@ -553,7 +557,7 @@ ExecMergeJoin(MergeJoin *node)
* next inner tuple (EXEC_MJ_JOINTUPLES). * next inner tuple (EXEC_MJ_JOINTUPLES).
* *
* If they do not satisfy then advance to next outer tuple. * If they do not satisfy then advance to next outer tuple.
*********************************/ */
case EXEC_MJ_JOINTEST: case EXEC_MJ_JOINTEST:
MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTEST\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTEST\n");
@ -566,11 +570,11 @@ ExecMergeJoin(MergeJoin *node)
mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER;
break; break;
/********************************* /*
* EXEC_MJ_JOINTUPLES means we have two tuples which * EXEC_MJ_JOINTUPLES means we have two tuples which
* satisified the merge clause so we join them and then * satisified the merge clause so we join them and then
* proceed to get the next inner tuple (EXEC_NEXT_INNER). * proceed to get the next inner tuple (EXEC_NEXT_INNER).
*********************************/ */
case EXEC_MJ_JOINTUPLES: case EXEC_MJ_JOINTUPLES:
MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTUPLES\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTUPLES\n");
mergestate->mj_JoinState = EXEC_MJ_NEXTINNER; mergestate->mj_JoinState = EXEC_MJ_NEXTINNER;
@ -599,11 +603,11 @@ ExecMergeJoin(MergeJoin *node)
} }
break; break;
/********************************* /*
* EXEC_MJ_NEXTINNER means advance the inner scan to * EXEC_MJ_NEXTINNER means advance the inner scan to the
* the next tuple. If the tuple is not nil, we then * next tuple. If the tuple is not nil, we then proceed to
* proceed to test it against the join qualification. * test it against the join qualification.
*********************************/ */
case EXEC_MJ_NEXTINNER: case EXEC_MJ_NEXTINNER:
MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTINNER\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTINNER\n");
@ -621,21 +625,22 @@ ExecMergeJoin(MergeJoin *node)
mergestate->mj_JoinState = EXEC_MJ_JOINTEST; mergestate->mj_JoinState = EXEC_MJ_JOINTEST;
break; break;
/********************************* /*-------------------------------------------
* EXEC_MJ_NEXTOUTER means * EXEC_MJ_NEXTOUTER means
* *
* outer inner * outer inner
* outer tuple - 5 5 - marked tuple * outer tuple - 5 5 - marked tuple
* 5 5 * 5 5
* 6 6 - inner tuple * 6 6 - inner tuple
* 7 7 * 7 7
* *
* we know we just bumped into the * we know we just bumped into the
* first inner tuple > current outer tuple * first inner tuple > current outer tuple
* so get a new outer tuple and then * so get a new outer tuple and then
* proceed to test it against the marked tuple * proceed to test it against the marked tuple
* (EXEC_MJ_TESTOUTER) * (EXEC_MJ_TESTOUTER)
*********************************/ *------------------------------------------------
*/
case EXEC_MJ_NEXTOUTER: case EXEC_MJ_NEXTOUTER:
MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTOUTER\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTOUTER\n");
@ -657,7 +662,7 @@ ExecMergeJoin(MergeJoin *node)
mergestate->mj_JoinState = EXEC_MJ_TESTOUTER; mergestate->mj_JoinState = EXEC_MJ_TESTOUTER;
break; break;
/********************************* /*--------------------------------------------------------
* EXEC_MJ_TESTOUTER If the new outer tuple and the marked * EXEC_MJ_TESTOUTER If the new outer tuple and the marked
* tuple satisfy the merge clause then we know we have * tuple satisfy the merge clause then we know we have
* duplicates in the outer scan so we have to restore the * duplicates in the outer scan so we have to restore the
@ -687,9 +692,10 @@ ExecMergeJoin(MergeJoin *node)
* 7 12 * 7 12
* *
* *
* new outer tuple > marked tuple * new outer tuple > marked tuple
* *
*********************************/ *---------------------------------------------------------
*/
case EXEC_MJ_TESTOUTER: case EXEC_MJ_TESTOUTER:
MJ_printf("ExecMergeJoin: EXEC_MJ_TESTOUTER\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_TESTOUTER\n");
@ -731,11 +737,11 @@ ExecMergeJoin(MergeJoin *node)
* tuple didn't match the marked outer tuple then * tuple didn't match the marked outer tuple then
* we may have the case: * we may have the case:
* *
* outer inner * outer inner
* 4 4 - marked tuple * 4 4 - marked tuple
* new outer - 5 4 * new outer - 5 4
* 6 nil - inner tuple * 6 nil - inner tuple
* 7 * 7
* *
* which means that all subsequent outer tuples will be * which means that all subsequent outer tuples will be
* larger than our inner tuples. * larger than our inner tuples.
@ -760,22 +766,23 @@ ExecMergeJoin(MergeJoin *node)
} }
break; break;
/********************************* /*----------------------------------------------------------
* EXEC_MJ_SKIPOUTER means skip over tuples in the outer plan * EXEC_MJ_SKIPOUTER means skip over tuples in the outer plan
* until we find an outer tuple > current inner tuple. * until we find an outer tuple > current inner tuple.
* *
* For example: * For example:
* *
* outer inner * outer inner
* 5 5 * 5 5
* 5 5 * 5 5
* outer tuple - 6 8 - inner tuple * outer tuple - 6 8 - inner tuple
* 7 12 * 7 12
* 8 14 * 8 14
* *
* we have to advance the outer scan * we have to advance the outer scan
* until we find the outer 8. * until we find the outer 8.
*********************************/ *----------------------------------------------------------
*/
case EXEC_MJ_SKIPOUTER: case EXEC_MJ_SKIPOUTER:
MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPOUTER\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPOUTER\n");
/* ---------------- /* ----------------
@ -867,23 +874,24 @@ ExecMergeJoin(MergeJoin *node)
mergestate->mj_JoinState = EXEC_MJ_JOINMARK; mergestate->mj_JoinState = EXEC_MJ_JOINMARK;
break; break;
/********************************* /*-----------------------------------------------------------
* EXEC_MJ_SKIPINNER means skip over tuples in the inner plan * EXEC_MJ_SKIPINNER means skip over tuples in the inner plan
* until we find an inner tuple > current outer tuple. * until we find an inner tuple > current outer tuple.
* *
* For example: * For example:
* *
* outer inner * outer inner
* 5 5 * 5 5
* 5 5 * 5 5
* outer tuple - 12 8 - inner tuple * outer tuple - 12 8 - inner tuple
* 14 10 * 14 10
* 17 12 * 17 12
* *
* we have to advance the inner scan * we have to advance the inner scan
* until we find the inner 12. * until we find the inner 12.
* *
*********************************/ *-------------------------------------------------------
*/
case EXEC_MJ_SKIPINNER: case EXEC_MJ_SKIPINNER:
MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPINNER\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPINNER\n");
/* ---------------- /* ----------------
@ -997,11 +1005,13 @@ ExecMergeJoin(MergeJoin *node)
break; break;
#ifdef ENABLE_OUTER_JOINS #ifdef ENABLE_OUTER_JOINS
/*********************************
* EXEC_MJ_FILLINNER means we have an unmatched inner tuple /*
* which must be null-expanded into the projection tuple. * EXEC_MJ_FILLINNER means we have an unmatched inner
* get the next inner tuple and reset markers (EXEC_MJ_JOINMARK). * tuple which must be null-expanded into the projection
*********************************/ * tuple. get the next inner tuple and reset markers
* (EXEC_MJ_JOINMARK).
*/
case EXEC_MJ_FILLINNER: case EXEC_MJ_FILLINNER:
MJ_printf("ExecMergeJoin: EXEC_MJ_FILLINNER\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_FILLINNER\n");
mergestate->mj_JoinState = EXEC_MJ_JOINMARK; mergestate->mj_JoinState = EXEC_MJ_JOINMARK;
@ -1046,11 +1056,12 @@ ExecMergeJoin(MergeJoin *node)
*/ */
break; break;
/********************************* /*
* EXEC_MJ_FILLOUTER means we have an unmatched outer tuple * EXEC_MJ_FILLOUTER means we have an unmatched outer
* which must be null-expanded into the projection tuple. * tuple which must be null-expanded into the projection
* get the next outer tuple and reset markers (EXEC_MJ_JOINMARK). * tuple. get the next outer tuple and reset markers
*********************************/ * (EXEC_MJ_JOINMARK).
*/
case EXEC_MJ_FILLOUTER: case EXEC_MJ_FILLOUTER:
MJ_printf("ExecMergeJoin: EXEC_MJ_FILLOUTER\n"); MJ_printf("ExecMergeJoin: EXEC_MJ_FILLOUTER\n");
mergestate->mj_JoinState = EXEC_MJ_JOINMARK; mergestate->mj_JoinState = EXEC_MJ_JOINMARK;
@ -1095,10 +1106,10 @@ ExecMergeJoin(MergeJoin *node)
break; break;
#endif #endif
/********************************* /*
* if we get here it means our code is fouled up * if we get here it means our code is fouled up and so we
* and so we just end the join prematurely. * just end the join prematurely.
*********************************/ */
default: default:
elog(NOTICE, "ExecMergeJoin: invalid join state. aborting"); elog(NOTICE, "ExecMergeJoin: invalid join state. aborting");
return NULL; return NULL;