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

Method sleuth

src/dsql/BoolNodes.cpp:1066–1137  ·  view source on GitHub ↗

Execute SLEUTH operator.

Source from the content-addressed store, hash-verified

1064
1065// Execute SLEUTH operator.
1066bool ComparativeBoolNode::sleuth(thread_db* tdbb, Request* request, const dsc* desc1,
1067 const dsc* desc2) const
1068{
1069 SET_TDBB(tdbb);
1070
1071 // Choose interpretation for the operation
1072
1073 USHORT ttype;
1074 if (desc1->isBlob())
1075 {
1076 if (desc1->dsc_sub_type == isc_blob_text)
1077 ttype = desc1->dsc_blob_ttype(); // Load blob character set and collation
1078 else
1079 ttype = INTL_TTYPE(desc2);
1080 }
1081 else
1082 ttype = INTL_TTYPE(desc1);
1083
1084 Collation* obj = INTL_texttype_lookup(tdbb, ttype);
1085
1086 // Get operator definition string (control string)
1087
1088 dsc* desc3 = EVL_expr(tdbb, request, arg3);
1089
1090 UCHAR* p1;
1091 MoveBuffer sleuth_str;
1092 USHORT l1 = MOV_make_string2(tdbb, desc3, ttype, &p1, sleuth_str);
1093 // Get address and length of search string
1094 UCHAR* p2;
1095 MoveBuffer match_str;
1096 USHORT l2 = MOV_make_string2(tdbb, desc2, ttype, &p2, match_str);
1097
1098 // Merge search and control strings
1099 UCHAR control[BUFFER_SMALL];
1100 const SLONG control_length = obj->sleuthMerge(*tdbb->getDefaultPool(), p2, l2, p1, l1, control); //, BUFFER_SMALL);
1101
1102 // Note: resulting string from sleuthMerge is either USHORT or UCHAR
1103 // and never Multibyte (see note in EVL_mb_sleuthCheck)
1104 bool ret_val;
1105 MoveBuffer data_str;
1106 if (!desc1->isBlob())
1107 {
1108 // Source is not a blob, do a simple search
1109
1110 l1 = MOV_make_string2(tdbb, desc1, ttype, &p1, data_str);
1111 ret_val = obj->sleuthCheck(*tdbb->getDefaultPool(), 0, p1, l1, control, control_length);
1112 }
1113 else
1114 {
1115 // Source string is a blob, things get interesting
1116
1117 blb* blob = blb::open(tdbb, request->req_transaction,
1118 reinterpret_cast<bid*>(desc1->dsc_address));
1119
1120 UCHAR buffer[BUFFER_LARGE];
1121 ret_val = false;
1122
1123 while (!(blob->blb_flags & BLB_eof))

Callers

nothing calls this directly

Calls 12

SET_TDBBFunction · 0.85
INTL_texttype_lookupFunction · 0.85
EVL_exprFunction · 0.85
MOV_make_string2Function · 0.85
isBlobMethod · 0.80
dsc_blob_ttypeMethod · 0.80
sleuthMergeMethod · 0.80
sleuthCheckMethod · 0.80
BLB_get_segmentMethod · 0.80
BLB_closeMethod · 0.80
openFunction · 0.50
getDefaultPoolMethod · 0.45

Tested by

no test coverage detected