aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeHashjoin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/nodeHashjoin.c')
-rw-r--r--src/backend/executor/nodeHashjoin.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
index a6847c956f4..7c02db94adb 100644
--- a/src/backend/executor/nodeHashjoin.c
+++ b/src/backend/executor/nodeHashjoin.c
@@ -113,6 +113,7 @@ ExecHashJoin(HashJoinState *node)
switch (node->hj_JoinState)
{
case HJ_BUILD_HASHTABLE:
+
/*
* First time through: build hash table for inner relation.
*/
@@ -123,12 +124,12 @@ ExecHashJoin(HashJoinState *node)
* right/full join, we can quit without building the hash
* table. However, for an inner join it is only a win to
* check this when the outer relation's startup cost is less
- * than the projected cost of building the hash
- * table. Otherwise it's best to build the hash table first
- * and see if the inner relation is empty. (When it's a left
- * join, we should always make this check, since we aren't
- * going to be able to skip the join on the strength of an
- * empty inner relation anyway.)
+ * than the projected cost of building the hash table.
+ * Otherwise it's best to build the hash table first and see
+ * if the inner relation is empty. (When it's a left join, we
+ * should always make this check, since we aren't going to be
+ * able to skip the join on the strength of an empty inner
+ * relation anyway.)
*
* If we are rescanning the join, we make use of information
* gained on the previous scan: don't bother to try the
@@ -185,8 +186,8 @@ ExecHashJoin(HashJoinState *node)
return NULL;
/*
- * need to remember whether nbatch has increased since we began
- * scanning the outer relation
+ * need to remember whether nbatch has increased since we
+ * began scanning the outer relation
*/
hashtable->nbatch_outstart = hashtable->nbatch;
@@ -202,6 +203,7 @@ ExecHashJoin(HashJoinState *node)
/* FALL THRU */
case HJ_NEED_NEW_OUTER:
+
/*
* We don't have an outer tuple, try to get the next one
*/
@@ -250,7 +252,7 @@ ExecHashJoin(HashJoinState *node)
Assert(batchno > hashtable->curbatch);
ExecHashJoinSaveTuple(ExecFetchSlotMinimalTuple(outerTupleSlot),
hashvalue,
- &hashtable->outerBatchFile[batchno]);
+ &hashtable->outerBatchFile[batchno]);
/* Loop around, staying in HJ_NEED_NEW_OUTER state */
continue;
}
@@ -261,6 +263,7 @@ ExecHashJoin(HashJoinState *node)
/* FALL THRU */
case HJ_SCAN_BUCKET:
+
/*
* Scan the selected hash bucket for matches to current outer
*/
@@ -296,8 +299,8 @@ ExecHashJoin(HashJoinState *node)
}
/*
- * In a semijoin, we'll consider returning the first match,
- * but after that we're done with this outer tuple.
+ * In a semijoin, we'll consider returning the first
+ * match, but after that we're done with this outer tuple.
*/
if (node->js.jointype == JOIN_SEMI)
node->hj_JoinState = HJ_NEED_NEW_OUTER;
@@ -320,10 +323,11 @@ ExecHashJoin(HashJoinState *node)
break;
case HJ_FILL_OUTER_TUPLE:
+
/*
* The current outer tuple has run out of matches, so check
- * whether to emit a dummy outer-join tuple. Whether we
- * emit one or not, the next state is NEED_NEW_OUTER.
+ * whether to emit a dummy outer-join tuple. Whether we emit
+ * one or not, the next state is NEED_NEW_OUTER.
*/
node->hj_JoinState = HJ_NEED_NEW_OUTER;
@@ -354,6 +358,7 @@ ExecHashJoin(HashJoinState *node)
break;
case HJ_FILL_INNER_TUPLES:
+
/*
* We have finished a batch, but we are doing right/full join,
* so any unmatched inner tuples in the hashtable have to be
@@ -389,11 +394,12 @@ ExecHashJoin(HashJoinState *node)
break;
case HJ_NEED_NEW_BATCH:
+
/*
* Try to advance to next batch. Done if there are no more.
*/
if (!ExecHashJoinNewBatch(node))
- return NULL; /* end of join */
+ return NULL; /* end of join */
node->hj_JoinState = HJ_NEED_NEW_OUTER;
break;
@@ -783,7 +789,7 @@ ExecHashJoinNewBatch(HashJoinState *hjstate)
}
if (curbatch >= nbatch)
- return false; /* no more batches */
+ return false; /* no more batches */
hashtable->curbatch = curbatch;
@@ -829,7 +835,7 @@ ExecHashJoinNewBatch(HashJoinState *hjstate)
if (BufFileSeek(hashtable->outerBatchFile[curbatch], 0, 0L, SEEK_SET))
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not rewind hash-join temporary file: %m")));
+ errmsg("could not rewind hash-join temporary file: %m")));
}
return true;
@@ -944,14 +950,13 @@ ExecReScanHashJoin(HashJoinState *node)
ExecHashTableResetMatchFlags(node->hj_HashTable);
/*
- * Also, we need to reset our state about the emptiness of
- * the outer relation, so that the new scan of the outer will
- * update it correctly if it turns out to be empty this time.
- * (There's no harm in clearing it now because ExecHashJoin won't
- * need the info. In the other cases, where the hash table
- * doesn't exist or we are destroying it, we leave this state
- * alone because ExecHashJoin will need it the first time
- * through.)
+ * Also, we need to reset our state about the emptiness of the
+ * outer relation, so that the new scan of the outer will update
+ * it correctly if it turns out to be empty this time. (There's no
+ * harm in clearing it now because ExecHashJoin won't need the
+ * info. In the other cases, where the hash table doesn't exist
+ * or we are destroying it, we leave this state alone because
+ * ExecHashJoin will need it the first time through.)
*/
node->hj_OuterNotEmpty = false;