MCPcopy Create free account
hub / github.com/apache/cloudberry / execTuplesUnequal

Function execTuplesUnequal

src/backend/executor/nodeSubplan.c:659–715  ·  view source on GitHub ↗

* execTuplesUnequal * Return true if two tuples are definitely unequal in the indicated * fields. * * Nulls are neither equal nor unequal to anything else. A true result * is obtained only if there are non-null fields that compare not-equal. * * slot1, slot2: the tuples to compare (must have same columns!) * numCols: the number of attributes to be examined * matchColIdx: array of attri

Source from the content-addressed store, hash-verified

657 * evalContext: short-term memory context for executing the functions
658 */
659static bool
660execTuplesUnequal(TupleTableSlot *slot1,
661 TupleTableSlot *slot2,
662 int numCols,
663 AttrNumber *matchColIdx,
664 FmgrInfo *eqfunctions,
665 const Oid *collations,
666 MemoryContext evalContext)
667{
668 MemoryContext oldContext;
669 bool result;
670 int i;
671
672 /* Reset and switch into the temp context. */
673 MemoryContextReset(evalContext);
674 oldContext = MemoryContextSwitchTo(evalContext);
675
676 /*
677 * We cannot report a match without checking all the fields, but we can
678 * report a non-match as soon as we find unequal fields. So, start
679 * comparing at the last field (least significant sort key). That's the
680 * most likely to be different if we are dealing with sorted input.
681 */
682 result = false;
683
684 for (i = numCols; --i >= 0;)
685 {
686 AttrNumber att = matchColIdx[i];
687 Datum attr1,
688 attr2;
689 bool isNull1,
690 isNull2;
691
692 attr1 = slot_getattr(slot1, att, &isNull1);
693
694 if (isNull1)
695 continue; /* can't prove anything here */
696
697 attr2 = slot_getattr(slot2, att, &isNull2);
698
699 if (isNull2)
700 continue; /* can't prove anything here */
701
702 /* Apply the type-specific equality function */
703 if (!DatumGetBool(FunctionCall2Coll(&eqfunctions[i],
704 collations[i],
705 attr1, attr2)))
706 {
707 result = true; /* they are unequal */
708 break;
709 }
710 }
711
712 MemoryContextSwitchTo(oldContext);
713
714 return result;
715}
716

Callers 1

findPartialMatchFunction · 0.85

Calls 5

MemoryContextResetFunction · 0.85
MemoryContextSwitchToFunction · 0.85
slot_getattrFunction · 0.85
DatumGetBoolFunction · 0.85
FunctionCall2CollFunction · 0.85

Tested by

no test coverage detected