|
|
|
@ -8,7 +8,7 @@ |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
* IDENTIFICATION |
|
|
|
* IDENTIFICATION |
|
|
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.39.2.1 2004/09/17 18:29:40 tgl Exp $ |
|
|
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.39.2.2 2004/10/13 21:56:14 tgl Exp $ |
|
|
|
* |
|
|
|
* |
|
|
|
*------------------------------------------------------------------------- |
|
|
|
*------------------------------------------------------------------------- |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -23,13 +23,13 @@ |
|
|
|
#include "utils/memutils.h" |
|
|
|
#include "utils/memutils.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static TupleTableSlot *ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, |
|
|
|
static TupleTableSlot *ExecHashJoinOuterGetTuple(Plan *node, HashJoin *parent, |
|
|
|
HashJoinState *hjstate); |
|
|
|
HashJoinState *hjstate); |
|
|
|
static TupleTableSlot *ExecHashJoinGetSavedTuple(HashJoinState *hjstate, |
|
|
|
static TupleTableSlot *ExecHashJoinGetSavedTuple(HashJoinState *hjstate, |
|
|
|
BufFile *file, |
|
|
|
BufFile *file, |
|
|
|
TupleTableSlot *tupleSlot); |
|
|
|
TupleTableSlot *tupleSlot); |
|
|
|
static int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable); |
|
|
|
static int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable); |
|
|
|
static int ExecHashJoinNewBatch(HashJoinState *hjstate); |
|
|
|
static int ExecHashJoinNewBatch(HashJoinState *hjstate, HashJoin *node); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
|
|
|
/* ----------------------------------------------------------------
|
|
|
|
@ -154,7 +154,7 @@ ExecHashJoin(HashJoin *node) |
|
|
|
if (hjstate->hj_NeedNewOuter) |
|
|
|
if (hjstate->hj_NeedNewOuter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
outerTupleSlot = ExecHashJoinOuterGetTuple(outerNode, |
|
|
|
outerTupleSlot = ExecHashJoinOuterGetTuple(outerNode, |
|
|
|
(Plan *) node, |
|
|
|
node, |
|
|
|
hjstate); |
|
|
|
hjstate); |
|
|
|
if (TupIsNull(outerTupleSlot)) |
|
|
|
if (TupIsNull(outerTupleSlot)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -470,7 +470,7 @@ ExecEndHashJoin(HashJoin *node) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
static TupleTableSlot * |
|
|
|
static TupleTableSlot * |
|
|
|
ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, HashJoinState *hjstate) |
|
|
|
ExecHashJoinOuterGetTuple(Plan *node, HashJoin *parent, HashJoinState *hjstate) |
|
|
|
{ |
|
|
|
{ |
|
|
|
HashJoinTable hashtable = hjstate->hj_HashTable; |
|
|
|
HashJoinTable hashtable = hjstate->hj_HashTable; |
|
|
|
int curbatch = hashtable->curbatch; |
|
|
|
int curbatch = hashtable->curbatch; |
|
|
|
@ -478,7 +478,7 @@ ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, HashJoinState *hjstate) |
|
|
|
|
|
|
|
|
|
|
|
if (curbatch == 0) |
|
|
|
if (curbatch == 0) |
|
|
|
{ /* if it is the first pass */ |
|
|
|
{ /* if it is the first pass */ |
|
|
|
slot = ExecProcNode(node, parent); |
|
|
|
slot = ExecProcNode(node, (Plan *) parent); |
|
|
|
if (!TupIsNull(slot)) |
|
|
|
if (!TupIsNull(slot)) |
|
|
|
return slot; |
|
|
|
return slot; |
|
|
|
|
|
|
|
|
|
|
|
@ -486,7 +486,7 @@ ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, HashJoinState *hjstate) |
|
|
|
* We have just reached the end of the first pass. Try to switch |
|
|
|
* We have just reached the end of the first pass. Try to switch |
|
|
|
* to a saved batch. |
|
|
|
* to a saved batch. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
curbatch = ExecHashJoinNewBatch(hjstate); |
|
|
|
curbatch = ExecHashJoinNewBatch(hjstate, parent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
@ -500,7 +500,7 @@ ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, HashJoinState *hjstate) |
|
|
|
hjstate->hj_OuterTupleSlot); |
|
|
|
hjstate->hj_OuterTupleSlot); |
|
|
|
if (!TupIsNull(slot)) |
|
|
|
if (!TupIsNull(slot)) |
|
|
|
return slot; |
|
|
|
return slot; |
|
|
|
curbatch = ExecHashJoinNewBatch(hjstate); |
|
|
|
curbatch = ExecHashJoinNewBatch(hjstate, parent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Out of batches... */ |
|
|
|
/* Out of batches... */ |
|
|
|
@ -546,7 +546,7 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate, |
|
|
|
* ---------------------------------------------------------------- |
|
|
|
* ---------------------------------------------------------------- |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static int |
|
|
|
static int |
|
|
|
ExecHashJoinNewBatch(HashJoinState *hjstate) |
|
|
|
ExecHashJoinNewBatch(HashJoinState *hjstate, HashJoin *node) |
|
|
|
{ |
|
|
|
{ |
|
|
|
HashJoinTable hashtable = hjstate->hj_HashTable; |
|
|
|
HashJoinTable hashtable = hjstate->hj_HashTable; |
|
|
|
int nbatch = hashtable->nbatch; |
|
|
|
int nbatch = hashtable->nbatch; |
|
|
|
@ -576,7 +576,7 @@ ExecHashJoinNewBatch(HashJoinState *hjstate) |
|
|
|
while (newbatch <= nbatch && |
|
|
|
while (newbatch <= nbatch && |
|
|
|
(outerBatchSize[newbatch - 1] == 0L || |
|
|
|
(outerBatchSize[newbatch - 1] == 0L || |
|
|
|
(innerBatchSize[newbatch - 1] == 0L && |
|
|
|
(innerBatchSize[newbatch - 1] == 0L && |
|
|
|
hjstate->js.jointype != JOIN_LEFT))) |
|
|
|
node->join.jointype != JOIN_LEFT))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BufFileClose(hashtable->innerBatchFile[newbatch - 1]); |
|
|
|
BufFileClose(hashtable->innerBatchFile[newbatch - 1]); |
|
|
|
hashtable->innerBatchFile[newbatch - 1] = NULL; |
|
|
|
hashtable->innerBatchFile[newbatch - 1] = NULL; |
|
|
|
|