| 729 | |
| 730 | |
| 731 | int 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 |
no test coverage detected