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

Function equality_ops_are_compatible

src/backend/utils/cache/lsyscache.c:845–882  ·  view source on GitHub ↗

* equality_ops_are_compatible * Return true if the two given equality operators have compatible * semantics. * * This is trivially true if they are the same operator. Otherwise, * we look to see if they can be found in the same btree or hash opfamily. * Either finding allows us to assume that they have compatible notions * of equality. (The reason we need to do these pushups is that one

Source from the content-addressed store, hash-verified

843 * be a cross-type operator; for instance int24eq vs int4eq.)
844 */
845bool
846equality_ops_are_compatible(Oid opno1, Oid opno2)
847{
848 bool result;
849 CatCList *catlist;
850 int i;
851
852 /* Easy if they're the same operator */
853 if (opno1 == opno2)
854 return true;
855
856 /*
857 * We search through all the pg_amop entries for opno1.
858 */
859 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
860
861 result = false;
862 for (i = 0; i < catlist->n_members; i++)
863 {
864 HeapTuple op_tuple = &catlist->members[i]->tuple;
865 Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
866
867 /* must be btree or hash */
868 if (IsIndexAccessMethod(op_form->amopmethod, BTREE_AM_OID) ||
869 IsIndexAccessMethod(op_form->amopmethod, HASH_AM_OID))
870 {
871 if (op_in_opfamily(opno2, op_form->amopfamily))
872 {
873 result = true;
874 break;
875 }
876 }
877 }
878
879 ReleaseSysCacheList(catlist);
880
881 return result;
882}
883
884/*
885 * comparison_ops_are_compatible

Callers 1

query_is_distinct_forFunction · 0.85

Calls 3

ObjectIdGetDatumFunction · 0.85
IsIndexAccessMethodFunction · 0.85
op_in_opfamilyFunction · 0.85

Tested by

no test coverage detected