TODO: make class StringValue and StringSearch accept a case-sensitive flag and switch back to using the cheaper Constant<>() functions.
| 61 | // TODO: make class StringValue and StringSearch accept a case-sensitive flag and |
| 62 | // switch back to using the cheaper Constant<>() functions. |
| 63 | void LikePredicate::LikePrepareInternal(FunctionContext* context, |
| 64 | FunctionContext::FunctionStateScope scope, bool case_sensitive) { |
| 65 | if (scope != FunctionContext::THREAD_LOCAL) return; |
| 66 | LikePredicateState* state = new LikePredicateState(); |
| 67 | context->SetFunctionState(scope, state); |
| 68 | state->function_ = LikeFn; |
| 69 | state->case_sensitive_ = case_sensitive; |
| 70 | if (context->IsArgConstant(1)) { |
| 71 | StringVal pattern_val = *reinterpret_cast<StringVal*>(context->GetConstantArg(1)); |
| 72 | if (pattern_val.is_null) return; |
| 73 | StringValue pattern = StringValue::FromStringVal(pattern_val); |
| 74 | string pattern_str(pattern.Ptr(), pattern.Len()); |
| 75 | OptimizeConstantPatternMatch(pattern_str, state); |
| 76 | if (state->regex_ && !state->regex_->ok()) { |
| 77 | context->SetError(Substitute("Invalid regex: $0", pattern_str).c_str()); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void LikePredicate::LikeClose(FunctionContext* context, |
| 83 | FunctionContext::FunctionStateScope scope) { |
nothing calls this directly
no test coverage detected