--- like-predicate.cc 2013-02-26 22:15:58.000000000 +0800 +++ 1.cc 2013-02-28 16:13:07.735567855 +0800 @@ -55,6 +55,15 @@ return &p->result_.bool_val; } +void* LikePredicate::ConstantEqualWithFn(Expr* e, TupleRow* row) { + LikePredicate* p = static_cast(e); + DCHECK_EQ(p->GetNumChildren(), 2); + StringValue* val = static_cast(e->GetChild(0)->GetValue(row)); + if (val == NULL) return NULL; + p->result_.bool_val = p->search_string_sv_.Eq(*val); + return &p->result_.bool_val; +} + void* LikePredicate::ConstantEndsWithFn(Expr* e, TupleRow* row) { LikePredicate* p = static_cast(e); DCHECK_EQ(p->GetNumChildren(), 2); @@ -150,7 +159,15 @@ StringValue(const_cast(search_string_.c_str()), search_string_.size()); compute_fn_ = ConstantEndsWithFn; return Status::OK; - } + }else{ + // for the condition: ... where city LIKE 'HangZhou' ... + search_string_ = match_res.str(1); + search_string_sv_ = + StringValue(const_cast(search_string_.c_str()), search_string_.size()); + compute_fn_ = ConstantEqualWithFn; + return Status::OK; + } + } string re_pattern; if (opcode_ == TExprOpcode::LIKE) { @@ -225,3 +242,4 @@ } } +