30 #define HJ_BUILD_HASHTABLE 1
31 #define HJ_NEED_NEW_OUTER 2
32 #define HJ_SCAN_BUCKET 3
33 #define HJ_FILL_OUTER_TUPLE 4
34 #define HJ_FILL_INNER_TUPLES 5
35 #define HJ_NEED_NEW_BATCH 6
38 #define HJ_FILL_OUTER(hjstate) ((hjstate)->hj_NullInnerTupleSlot != NULL)
40 #define HJ_FILL_INNER(hjstate) ((hjstate)->hj_NullOuterTupleSlot != NULL)
245 if (batchno != hashtable->
curbatch &&
296 if (joinqual ==
NIL ||
ExecQual(joinqual, econtext,
false))
315 if (otherqual ==
NIL ||
316 ExecQual(otherqual, econtext,
false))
354 if (otherqual ==
NIL ||
355 ExecQual(otherqual, econtext,
false))
393 if (otherqual ==
NIL ||
394 ExecQual(otherqual, econtext,
false))
422 elog(
ERROR,
"unrecognized hashjoin state: %d",
524 elog(
ERROR,
"unrecognized join type: %d",
694 else if (curbatch < hashtable->nbatch)
733 nbatch = hashtable->
nbatch;
779 while (curbatch < nbatch &&
806 if (curbatch >= nbatch)
818 if (innerFile !=
NULL)
823 errmsg(
"could not rewind hash-join temporary file: %m")));
853 errmsg(
"could not rewind hash-join temporary file: %m")));
885 if (written !=
sizeof(
uint32))
888 errmsg(
"could not write to hash-join temporary file: %m")));
891 if (written != tuple->
t_len)
894 errmsg(
"could not write to hash-join temporary file: %m")));
919 nread =
BufFileRead(file, (
void *) header,
sizeof(header));
925 if (nread !=
sizeof(header))
928 errmsg(
"could not read from hash-join temporary file: %m")));
929 *hashvalue = header[0];
931 tuple->
t_len = header[1];
933 (
void *) ((
char *) tuple +
sizeof(
uint32)),
934 header[1] -
sizeof(
uint32));
935 if (nread != header[1] -
sizeof(
uint32))
938 errmsg(
"could not read from hash-join temporary file: %m")));
#define HJ_NEED_NEW_BATCH
#define INVALID_SKEW_BUCKET_NO
TupleTableSlot * ExecProcNode(PlanState *node)
#define IsA(nodeptr, _type_)
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate)
HashJoinTable ExecHashTableCreate(Hash *node, List *hashOperators, bool keepNulls)
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
TupleTableSlot * hj_NullInnerTupleSlot
ProjectionInfo * ps_ProjInfo
int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence)
void ExecEndNode(PlanState *node)
bool ExecScanHashTableForUnmatched(HashJoinState *hjstate, ExprContext *econtext)
MinimalTuple ExecFetchSlotMinimalTuple(TupleTableSlot *slot)
void ExecPrepHashTableForUnmatched(HashJoinState *hjstate)
ExprContext * ps_ExprContext
void ExecHashTableReset(HashJoinTable hashtable)
void ExecReScan(PlanState *node)
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
TupleTableSlot * ExecProject(ProjectionInfo *projInfo, ExprDoneCond *isDone)
static TupleTableSlot * ExecHashJoinOuterGetTuple(PlanState *outerNode, HashJoinState *hjstate, uint32 *hashvalue)
TupleTableSlot * hj_OuterTupleSlot
struct PlanState * righttree
List * lappend_oid(List *list, Oid datum)
TupleTableSlot * hj_FirstOuterTupleSlot
void ExecFreeExprContext(PlanState *planstate)
void BufFileClose(BufFile *file)
int ExecHashGetSkewBucket(HashJoinTable hashtable, uint32 hashvalue)
void ExecAssignResultTypeFromTL(PlanState *planstate)
struct PlanState * lefttree
void ExecEndHashJoin(HashJoinState *node)
#define HJ_FILL_INNER(hjstate)
void ExecHashTableInsert(HashJoinTable hashtable, TupleTableSlot *slot, uint32 hashvalue)
void ExecHashGetBucketAndBatch(HashJoinTable hashtable, uint32 hashvalue, int *bucketno, int *batchno)
TupleTableSlot * ps_ResultTupleSlot
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
TupleTableSlot * ExecInitNullTupleSlot(EState *estate, TupleDesc tupType)
TupleTableSlot * hj_NullOuterTupleSlot
BufFile * BufFileCreateTemp(bool interXact)
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
#define EXEC_FLAG_BACKWARD
BufFile ** outerBatchFile
#define outerPlanState(node)
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
HashJoinTuple hj_CurTuple
MinimalTupleData * MinimalTuple
bool ExecScanHashBucket(HashJoinState *hjstate, ExprContext *econtext)
int errcode_for_file_access(void)
TupleTableSlot * ecxt_innertuple
bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
#define InstrCountFiltered1(node, delta)
#define ereport(elevel, rest)
List * lappend(List *list, void *datum)
#define HJ_FILL_INNER_TUPLES
#define HJ_FILL_OUTER(hjstate)
HashSkewBucket ** skewBucket
HashJoinState * ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc)
#define HJTUPLE_MINTUPLE(hjtup)
TupleTableSlot * ecxt_outertuple
#define Assert(condition)
#define InstrCountFiltered2(node, delta)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
BufFile ** innerBatchFile
static TupleTableSlot * ExecHashJoinGetSavedTuple(HashJoinState *hjstate, BufFile *file, uint32 *hashvalue, TupleTableSlot *tupleSlot)
static void header(const char *fmt,...) pg_attribute_printf(1
TupleDesc ExecGetResultType(PlanState *planstate)
#define HJ_NEED_NEW_OUTER
TupleTableSlot * ExecHashJoin(HashJoinState *node)
TupleTableSlot * hj_HashTupleSlot
#define HJ_BUILD_HASHTABLE
HashJoinTable hj_HashTable
int errmsg(const char *fmt,...)
Node * MultiExecProcNode(PlanState *node)
size_t BufFileRead(BufFile *file, void *ptr, size_t size)
#define HeapTupleHeaderSetMatch(tup)
size_t BufFileWrite(BufFile *file, void *ptr, size_t size)
void ExecHashTableResetMatchFlags(HashJoinTable hashtable)
bool ExecHashGetHashValue(HashJoinTable hashtable, ExprContext *econtext, List *hashkeys, bool outer_tuple, bool keep_nulls, uint32 *hashvalue)
#define CHECK_FOR_INTERRUPTS()
#define HJ_FILL_OUTER_TUPLE
#define innerPlanState(node)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
static bool ExecHashJoinNewBatch(HashJoinState *hjstate)
void ExecHashJoinSaveTuple(MinimalTuple tuple, uint32 hashvalue, BufFile **fileptr)
void ExecHashTableDestroy(HashJoinTable hashtable)
#define ResetExprContext(econtext)
void ExecReScanHashJoin(HashJoinState *node)