Perform one of the complex string functions CONTAINING, MATCHES, or STARTS WITH.
| 858 | |
| 859 | // Perform one of the complex string functions CONTAINING, MATCHES, or STARTS WITH. |
| 860 | bool ComparativeBoolNode::stringBoolean(thread_db* tdbb, Request* request, dsc* desc1, |
| 861 | dsc* desc2, bool computedInvariant) const |
| 862 | { |
| 863 | SET_TDBB(tdbb); |
| 864 | |
| 865 | USHORT type1; |
| 866 | |
| 867 | if (!desc1->isBlob()) |
| 868 | type1 = INTL_TEXT_TYPE(*desc1); |
| 869 | else |
| 870 | { |
| 871 | // No MATCHES support for blob |
| 872 | if (blrOp == blr_matching) |
| 873 | return false; |
| 874 | |
| 875 | type1 = desc1->dsc_sub_type == isc_blob_text ? desc1->dsc_blob_ttype() : ttype_none; |
| 876 | } |
| 877 | |
| 878 | Collation* obj = INTL_texttype_lookup(tdbb, type1); |
| 879 | CharSet* charset = obj->getCharSet(); |
| 880 | |
| 881 | VaryStr<TEMP_STR_LENGTH> escapeTemp; |
| 882 | const UCHAR* escapeStr = nullptr; |
| 883 | USHORT escapeLen = 0; |
| 884 | |
| 885 | // Handle escape for LIKE and SIMILAR |
| 886 | if (blrOp == blr_like || blrOp == blr_similar) |
| 887 | { |
| 888 | // ensure 3rd argument (escape char) is in operation text type |
| 889 | if (arg3 && !computedInvariant) |
| 890 | { |
| 891 | // Convert ESCAPE to operation character set |
| 892 | dsc* desc = EVL_expr(tdbb, request, arg3); |
| 893 | |
| 894 | if (request->req_flags & req_null) |
| 895 | { |
| 896 | if (nodFlags & FLAG_INVARIANT) |
| 897 | { |
| 898 | impure_value* impure = request->getImpure<impure_value>(impureOffset); |
| 899 | impure->vlu_flags |= VLU_computed; |
| 900 | impure->vlu_flags |= VLU_null; |
| 901 | } |
| 902 | return false; |
| 903 | } |
| 904 | |
| 905 | escapeLen = MOV_make_string(tdbb, desc, type1, |
| 906 | reinterpret_cast<const char**>(&escapeStr), &escapeTemp, sizeof(escapeTemp)); |
| 907 | |
| 908 | if (!escapeLen || charset->length(escapeLen, escapeStr, true) != 1) |
| 909 | { |
| 910 | // If characters left, or null byte character, return error |
| 911 | ERR_post(Arg::Gds(isc_escape_invalid)); |
| 912 | } |
| 913 | |
| 914 | USHORT escape[2] = {0, 0}; |
| 915 | |
| 916 | charset->getConvToUnicode().convert(escapeLen, escapeStr, sizeof(escape), escape); |
| 917 |
nothing calls this directly
no test coverage detected