105 #define EXEC_MJ_INITIALIZE_OUTER 1
106 #define EXEC_MJ_INITIALIZE_INNER 2
107 #define EXEC_MJ_JOINTUPLES 3
108 #define EXEC_MJ_NEXTOUTER 4
109 #define EXEC_MJ_TESTOUTER 5
110 #define EXEC_MJ_NEXTINNER 6
111 #define EXEC_MJ_SKIP_TEST 7
112 #define EXEC_MJ_SKIPOUTER_ADVANCE 8
113 #define EXEC_MJ_SKIPINNER_ADVANCE 9
114 #define EXEC_MJ_ENDOUTER 10
115 #define EXEC_MJ_ENDINNER 11
151 #define MarkInnerTuple(innerTupleSlot, mergestate) \
152 ExecCopySlot((mergestate)->mj_MarkedTupleSlot, (innerTupleSlot))
177 Oid *mergecollations,
178 int *mergestrategies,
179 bool *mergenullsfirst,
190 foreach(cl, mergeclauses)
194 Oid opfamily = mergefamilies[iClause];
195 Oid collation = mergecollations[iClause];
197 bool nulls_first = mergenullsfirst[iClause];
204 elog(
ERROR,
"mergejoin clause is not an OpExpr");
220 elog(
ERROR,
"unsupported mergejoin strategy %d", opstrategy);
229 elog(
ERROR,
"cannot merge using non-equality operator %u",
259 elog(
ERROR,
"missing support function %d(%u,%u) in opfamily %u",
394 bool nulleqnull =
false;
468 MJ_printf(
"ExecMergeJoin: returning outer fill tuple\n");
499 MJ_printf(
"ExecMergeJoin: returning inner fill tuple\n");
530 *is_const_false =
true;
543 #ifdef EXEC_MERGEJOINDEBUG
550 printf(
"==== outer tuple ====\n");
562 printf(
"==== inner tuple ====\n");
574 printf(
"==== marked tuple ====\n");
584 printf(
"******** ExecMergeTupleDump ********\n");
586 ExecMergeTupleDumpOuter(mergestate);
587 ExecMergeTupleDumpInner(mergestate);
588 ExecMergeTupleDumpMarked(mergestate);
653 MJ_printf(
"ExecMergeJoin: EXEC_MJ_INITIALIZE_OUTER\n");
683 MJ_printf(
"ExecMergeJoin: nothing in outer subplan\n");
701 MJ_printf(
"ExecMergeJoin: EXEC_MJ_INITIALIZE_INNER\n");
738 MJ_printf(
"ExecMergeJoin: nothing in inner subplan\n");
763 MJ_printf(
"ExecMergeJoin: EXEC_MJ_JOINTUPLES\n");
791 qualResult = (joinqual == NULL ||
824 qualResult = (otherqual == NULL ||
834 MJ_printf(
"ExecMergeJoin: returning tuple\n");
854 MJ_printf(
"ExecMergeJoin: EXEC_MJ_NEXTINNER\n");
902 if (compareResult == 0)
904 else if (compareResult < 0)
907 elog(
ERROR,
"mergejoin input data is out of order");
955 MJ_printf(
"ExecMergeJoin: EXEC_MJ_NEXTOUTER\n");
993 MJ_printf(
"ExecMergeJoin: end of outer subplan\n");
995 if (doFillInner && !
TupIsNull(innerTupleSlot))
1045 MJ_printf(
"ExecMergeJoin: EXEC_MJ_TESTOUTER\n");
1058 if (compareResult == 0)
1097 else if (compareResult > 0)
1150 elog(
ERROR,
"mergejoin input data is out of order");
1183 MJ_printf(
"ExecMergeJoin: EXEC_MJ_SKIP_TEST\n");
1193 if (compareResult == 0)
1202 else if (compareResult < 0)
1217 MJ_printf(
"ExecMergeJoin: EXEC_MJ_SKIPOUTER_ADVANCE\n");
1255 MJ_printf(
"ExecMergeJoin: end of outer subplan\n");
1257 if (doFillInner && !
TupIsNull(innerTupleSlot))
1279 MJ_printf(
"ExecMergeJoin: EXEC_MJ_SKIPINNER_ADVANCE\n");
1325 MJ_printf(
"ExecMergeJoin: end of inner subplan\n");
1327 if (doFillOuter && !
TupIsNull(outerTupleSlot))
1347 MJ_printf(
"ExecMergeJoin: EXEC_MJ_ENDOUTER\n");
1380 MJ_printf(
"ExecMergeJoin: end of inner subplan\n");
1393 MJ_printf(
"ExecMergeJoin: EXEC_MJ_ENDINNER\n");
1422 MJ_printf(
"ExecMergeJoin: end of outer subplan\n");
1433 elog(
ERROR,
"unrecognized mergejoin state: %d",
1455 "initializing node");
1578 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1579 errmsg(
"RIGHT JOIN is only supported with merge-joinable join conditions")));
1596 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1597 errmsg(
"FULL JOIN is only supported with merge-joinable join conditions")));
1600 elog(
ERROR,
"unrecognized join type: %d",
1609 node->mergeFamilies,
1610 node->mergeCollations,
1611 node->mergeStrategies,
1612 node->mergeNullsFirst,
1628 "node initialized");
1644 "ending node processing");
1653 "node processing ended");
#define Assert(condition)
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ExecMarkPos(PlanState *node)
void ExecReScan(PlanState *node)
void ExecRestrPos(PlanState *node)
ExprState * ExecInitQual(List *qual, PlanState *parent)
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
void ExecEndNode(PlanState *node)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
const TupleTableSlotOps TTSOpsVirtual
TupleTableSlot * ExecInitNullTupleSlot(EState *estate, TupleDesc tupType, const TupleTableSlotOps *tts_ops)
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
TupleDesc ExecGetResultType(PlanState *planstate)
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
ExprContext * CreateExprContext(EState *estate)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
#define MJ_DEBUG_COMPARE(res)
#define MJ_DEBUG_QUAL(clause, res)
#define MJ_DEBUG_PROC_NODE(slot)
#define MJ_debugtup(slot)
#define InstrCountFiltered1(node, delta)
#define outerPlanState(node)
#define InstrCountFiltered2(node, delta)
#define innerPlanState(node)
struct MergeJoinClauseData * MergeJoinClause
#define EXEC_FLAG_BACKWARD
static TupleTableSlot * ExecProject(ProjectionInfo *projInfo)
#define ResetExprContext(econtext)
static bool ExecQual(ExprState *state, ExprContext *econtext)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
static TupleTableSlot * ExecProcNode(PlanState *node)
#define OidFunctionCall1(functionId, arg1)
void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define CHECK_FOR_INTERRUPTS()
#define BTSORTSUPPORT_PROC
static int MJCompare(MergeJoinState *mergestate)
struct MergeJoinClauseData MergeJoinClauseData
#define EXEC_MJ_SKIP_TEST
#define EXEC_MJ_JOINTUPLES
#define EXEC_MJ_SKIPOUTER_ADVANCE
#define MarkInnerTuple(innerTupleSlot, mergestate)
#define EXEC_MJ_TESTOUTER
void ExecReScanMergeJoin(MergeJoinState *node)
static MJEvalResult MJEvalOuterValues(MergeJoinState *mergestate)
static MergeJoinClause MJExamineQuals(List *mergeclauses, Oid *mergefamilies, Oid *mergecollations, int *mergestrategies, bool *mergenullsfirst, PlanState *parent)
MergeJoinState * ExecInitMergeJoin(MergeJoin *node, EState *estate, int eflags)
#define EXEC_MJ_INITIALIZE_OUTER
#define EXEC_MJ_SKIPINNER_ADVANCE
static TupleTableSlot * MJFillInner(MergeJoinState *node)
#define EXEC_MJ_NEXTOUTER
void ExecEndMergeJoin(MergeJoinState *node)
static TupleTableSlot * ExecMergeJoin(PlanState *pstate)
#define EXEC_MJ_INITIALIZE_INNER
static MJEvalResult MJEvalInnerValues(MergeJoinState *mergestate, TupleTableSlot *innerslot)
static TupleTableSlot * MJFillOuter(MergeJoinState *node)
#define EXEC_MJ_NEXTINNER
static bool check_constant_qual(List *qual, bool *is_const_false)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
static int list_length(const List *l)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
MemoryContextSwitchTo(old_ctx)
void PrepareSortSupportComparisonShim(Oid cmpFunc, SortSupport ssup)
static int ApplySortComparator(Datum datum1, bool isNull1, Datum datum2, bool isNull2, SortSupport ssup)
#define BTGreaterStrategyNumber
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
MemoryContext ecxt_per_tuple_memory
TupleTableSlot * ecxt_innertuple
TupleTableSlot * ecxt_outertuple
TupleTableSlot * mj_MarkedTupleSlot
TupleTableSlot * mj_NullInnerTupleSlot
ExprContext * mj_InnerEContext
TupleTableSlot * mj_NullOuterTupleSlot
MergeJoinClause mj_Clauses
TupleTableSlot * mj_InnerTupleSlot
ExprContext * mj_OuterEContext
TupleTableSlot * mj_OuterTupleSlot
ExprContext * ps_ExprContext
ProjectionInfo * ps_ProjInfo
ExecProcNodeMtd ExecProcNode
int(* comparator)(Datum x, Datum y, SortSupport ssup)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)