MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / CVT2_blob_compare

Function CVT2_blob_compare

src/jrd/cvt2.cpp:731–914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729
730
731int CVT2_blob_compare(const dsc* arg1, const dsc* arg2, DecimalStatus decSt)
732{
733/**************************************
734 *
735 * C V T 2 _ b l o b _ c o m p a r e
736 *
737 **************************************
738 *
739 * Functional description
740 * Compare two blobs. Return (-1, 0, 1) if a<b, a=b, or a>b.
741 * Alternatively, it will try to compare a blob against a string;
742 * in this case, the string should be the second argument.
743 * CVC: Ann Harrison asked for this function to make comparisons more
744 * complete in the engine.
745 *
746 **************************************/
747
748 SLONG l1, l2;
749 USHORT ttype2;
750 int ret_val = 0;
751
752 thread_db* tdbb = NULL;
753 SET_TDBB(tdbb);
754
755 // DEV_BLKCHK (node, type_nod);
756
757 if (arg1->dsc_dtype != dtype_blob)
758 ERR_post(Arg::Gds(isc_wish_list) << Arg::Gds(isc_datnotsup));
759
760 USHORT ttype1;
761 if (arg1->dsc_sub_type == isc_blob_text)
762 ttype1 = arg1->dsc_blob_ttype(); // Load blob character set and collation
763 else
764 ttype1 = ttype_binary;
765
766 TextType* obj1 = INTL_texttype_lookup(tdbb, ttype1);
767 ttype1 = obj1->getType();
768
769 // Is arg2 a blob?
770 if (arg2->dsc_dtype == dtype_blob)
771 {
772 // Same blob id address?
773 if (arg1->dsc_address == arg2->dsc_address)
774 return 0;
775
776 // Second test for blob id, checking relation and slot.
777 const bid* bid1 = (bid*) arg1->dsc_address;
778 const bid* bid2 = (bid*) arg2->dsc_address;
779 if (*bid1 == *bid2)
780 {
781 return 0;
782 }
783
784 if (arg2->dsc_sub_type == isc_blob_text)
785 ttype2 = arg2->dsc_blob_ttype(); // Load blob character set and collation
786 else
787 ttype2 = ttype_binary;
788

Callers 1

CVT2_compareFunction · 0.85

Calls 15

SET_TDBBFunction · 0.85
GdsClass · 0.85
INTL_texttype_lookupFunction · 0.85
CVT2_make_string2Function · 0.85
dsc_blob_ttypeMethod · 0.80
isMultiByteMethod · 0.80
minBytesPerCharMethod · 0.80
BLB_get_dataMethod · 0.80
BLB_closeMethod · 0.80
dsc_ttypeMethod · 0.80
ERR_postFunction · 0.70
openFunction · 0.50

Tested by

no test coverage detected