8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.77 2005/11/22 18: 17:10 momjian Exp $
11
+ * $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.78 2005/11/28 17:14:23 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -152,12 +152,7 @@ ExecHashJoin(HashJoinState *node)
152
152
* outer join, we can quit without scanning the outer relation.
153
153
*/
154
154
if (hashtable -> totalTuples == 0 && node -> js .jointype != JOIN_LEFT )
155
- {
156
- ExecHashTableDestroy (hashtable );
157
- node -> hj_HashTable = NULL ;
158
- node -> hj_FirstOuterTupleSlot = NULL ;
159
155
return NULL ;
160
- }
161
156
162
157
/*
163
158
* need to remember whether nbatch has increased since we began
@@ -487,7 +482,6 @@ ExecEndHashJoin(HashJoinState *node)
487
482
{
488
483
ExecHashTableDestroy (node -> hj_HashTable );
489
484
node -> hj_HashTable = NULL ;
490
- node -> hj_FirstOuterTupleSlot = NULL ;
491
485
}
492
486
493
487
/*
@@ -803,38 +797,33 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
803
797
void
804
798
ExecReScanHashJoin (HashJoinState * node , ExprContext * exprCtxt )
805
799
{
806
- /*
807
- * If we haven't yet built the hash table then we can just return; nothing
808
- * done yet, so nothing to undo.
809
- */
810
- if (node -> hj_HashTable == NULL )
811
- return ;
812
-
813
800
/*
814
801
* In a multi-batch join, we currently have to do rescans the hard way,
815
802
* primarily because batch temp files may have already been released. But
816
803
* if it's a single-batch join, and there is no parameter change for the
817
804
* inner subnode, then we can just re-use the existing hash table without
818
805
* rebuilding it.
819
806
*/
820
- if (node -> hj_HashTable -> nbatch == 1 &&
821
- ((PlanState * ) node )-> righttree -> chgParam == NULL )
822
- {
823
- /* okay to reuse the hash table; needn't rescan inner, either */
824
- }
825
- else
807
+ if (node -> hj_HashTable != NULL )
826
808
{
827
- /* must destroy and rebuild hash table */
828
- ExecHashTableDestroy (node -> hj_HashTable );
829
- node -> hj_HashTable = NULL ;
830
- node -> hj_FirstOuterTupleSlot = NULL ;
809
+ if (node -> hj_HashTable -> nbatch == 1 &&
810
+ ((PlanState * ) node )-> righttree -> chgParam == NULL )
811
+ {
812
+ /* okay to reuse the hash table; needn't rescan inner, either */
813
+ }
814
+ else
815
+ {
816
+ /* must destroy and rebuild hash table */
817
+ ExecHashTableDestroy (node -> hj_HashTable );
818
+ node -> hj_HashTable = NULL ;
831
819
832
- /*
833
- * if chgParam of subnode is not null then plan will be re-scanned by
834
- * first ExecProcNode.
835
- */
836
- if (((PlanState * ) node )-> righttree -> chgParam == NULL )
837
- ExecReScan (((PlanState * ) node )-> righttree , exprCtxt );
820
+ /*
821
+ * if chgParam of subnode is not null then plan will be re-scanned
822
+ * by first ExecProcNode.
823
+ */
824
+ if (((PlanState * ) node )-> righttree -> chgParam == NULL )
825
+ ExecReScan (((PlanState * ) node )-> righttree , exprCtxt );
826
+ }
838
827
}
839
828
840
829
/* Always reset intra-tuple state */
@@ -846,6 +835,7 @@ ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt)
846
835
node -> js .ps .ps_TupFromTlist = false;
847
836
node -> hj_NeedNewOuter = true;
848
837
node -> hj_MatchedOuter = false;
838
+ node -> hj_FirstOuterTupleSlot = NULL ;
849
839
850
840
/*
851
841
* if chgParam of subnode is not null then plan will be re-scanned by
0 commit comments