Address the issue of improper comparison due to mismatched data types on both sides of the IN expression.
This commit is contained in:
@ -106,7 +106,8 @@ int ObExprCase::calc_result_typeN(ObExprResType &type,
|
|||||||
types_stack[i].set_calc_meta(types_stack[i].get_obj_meta());
|
types_stack[i].set_calc_meta(types_stack[i].get_obj_meta());
|
||||||
} else {
|
} else {
|
||||||
types_stack[i].set_calc_meta(type.get_obj_meta());
|
types_stack[i].set_calc_meta(type.get_obj_meta());
|
||||||
if (ObDecimalIntType == type.get_obj_meta().get_type()) {
|
if (ObDecimalIntType == type.get_obj_meta().get_type() ||
|
||||||
|
ob_is_double_type(type.get_obj_meta().get_type())) {
|
||||||
types_stack[i].set_calc_accuracy(type.get_accuracy());
|
types_stack[i].set_calc_accuracy(type.get_accuracy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1169,56 +1169,62 @@ int ObExprInOrNotIn::inner_eval_vector_in_without_row_fallback(const ObExpr &exp
|
|||||||
sql::RowCmpFunc row_cmp_func = VectorCmpExprFuncsHelper::get_row_cmp_func(
|
sql::RowCmpFunc row_cmp_func = VectorCmpExprFuncsHelper::get_row_cmp_func(
|
||||||
expr.args_[0]->datum_meta_,
|
expr.args_[0]->datum_meta_,
|
||||||
expr.args_[1]->args_[0]->datum_meta_);
|
expr.args_[1]->args_[0]->datum_meta_);
|
||||||
if (std::is_same<LeftVec, ObFixedLengthBase>::value) {
|
if (OB_ISNULL(row_cmp_func)) {
|
||||||
fixed_base_l_payload = (reinterpret_cast<ObFixedLengthBase *>(input_left_vec))->get_data();
|
ret = OB_ERR_UNEXPECTED;
|
||||||
l_len = (reinterpret_cast<ObFixedLengthBase *>(input_left_vec))->get_length();
|
LOG_WARN("row_cmp_func is null", K(ret), K(expr.args_[0]->datum_meta_),
|
||||||
}
|
K(expr.args_[1]->args_[0]->datum_meta_), K(expr.args_[1]->arg_cnt_));
|
||||||
for (; OB_SUCC(ret) && idx < bound.end(); ++idx) {
|
} else {
|
||||||
if (my_skip.at(idx) || eval_flags.at(idx)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// The situation "input_left_vec->is_null(idx)" has already been handled previously.
|
|
||||||
if (std::is_same<LeftVec, ObFixedLengthBase>::value) {
|
if (std::is_same<LeftVec, ObFixedLengthBase>::value) {
|
||||||
l_payload = fixed_base_l_payload + l_len * idx;
|
fixed_base_l_payload = (reinterpret_cast<ObFixedLengthBase *>(input_left_vec))->get_data();
|
||||||
} else {
|
l_len = (reinterpret_cast<ObFixedLengthBase *>(input_left_vec))->get_length();
|
||||||
input_left_vec->get_payload(idx, l_payload, l_len);
|
|
||||||
}
|
}
|
||||||
bool left_hit = false;
|
for (; OB_SUCC(ret) && idx < bound.end(); ++idx) {
|
||||||
if (right_has_null) {
|
if (my_skip.at(idx) || eval_flags.at(idx)) {
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < expr.inner_func_cnt_; ++i) {
|
continue;
|
||||||
right = right_store[i];
|
}
|
||||||
if (right->is_null()) {
|
// The situation "input_left_vec->is_null(idx)" has already been handled previously.
|
||||||
// do nothing
|
if (std::is_same<LeftVec, ObFixedLengthBase>::value) {
|
||||||
} else if (OB_FAIL((row_cmp_func)(expr.args_[0]->obj_meta_,
|
l_payload = fixed_base_l_payload + l_len * idx;
|
||||||
expr.args_[1]->args_[i]->obj_meta_,
|
} else {
|
||||||
(const void *)l_payload, l_len,
|
input_left_vec->get_payload(idx, l_payload, l_len);
|
||||||
(const void *)right->ptr_, right->len_, cmp_ret))) {
|
}
|
||||||
LOG_WARN("row_cmp_func failed!", K(ret), K(expr.args_[0]->obj_meta_),
|
bool left_hit = false;
|
||||||
K(expr.args_[1]->args_[i]->obj_meta_));
|
if (right_has_null) {
|
||||||
} else if (cmp_ret == 0) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < expr.inner_func_cnt_; ++i) {
|
||||||
left_hit = true;
|
right = right_store[i];
|
||||||
break;
|
if (right->is_null()) {
|
||||||
|
// do nothing
|
||||||
|
} else if (OB_FAIL((row_cmp_func)(expr.args_[0]->obj_meta_,
|
||||||
|
expr.args_[1]->args_[i]->obj_meta_,
|
||||||
|
(const void *)l_payload, l_len,
|
||||||
|
(const void *)right->ptr_, right->len_, cmp_ret))) {
|
||||||
|
LOG_WARN("row_cmp_func failed!", K(ret), K(expr.args_[0]->obj_meta_),
|
||||||
|
K(expr.args_[1]->args_[i]->obj_meta_));
|
||||||
|
} else if (cmp_ret == 0) {
|
||||||
|
left_hit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int64_t i = 0; OB_SUCC(ret) && i < expr.inner_func_cnt_; ++i) {
|
||||||
|
right = right_store[i];
|
||||||
|
if (OB_FAIL((row_cmp_func)(expr.args_[0]->obj_meta_,
|
||||||
|
expr.args_[1]->args_[i]->obj_meta_,
|
||||||
|
(const void *)l_payload, l_len,
|
||||||
|
(const void *)right->ptr_, right->len_, cmp_ret))) {
|
||||||
|
LOG_WARN("row_cmp_func failed!", K(ret), K(expr.args_[0]->obj_meta_),
|
||||||
|
K(expr.args_[1]->args_[i]->obj_meta_));
|
||||||
|
} else if (cmp_ret == 0) {
|
||||||
|
left_hit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (OB_SUCC(ret)) {
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < expr.inner_func_cnt_; ++i) {
|
set_vector_result<ResVec>(T_OP_IN == expr.type_, left_hit, right_has_null, res_vec, idx);
|
||||||
right = right_store[i];
|
eval_flags.set(idx);
|
||||||
if (OB_FAIL((row_cmp_func)(expr.args_[0]->obj_meta_,
|
|
||||||
expr.args_[1]->args_[i]->obj_meta_,
|
|
||||||
(const void *)l_payload, l_len,
|
|
||||||
(const void *)right->ptr_, right->len_, cmp_ret))) {
|
|
||||||
LOG_WARN("row_cmp_func failed!", K(ret), K(expr.args_[0]->obj_meta_),
|
|
||||||
K(expr.args_[1]->args_[i]->obj_meta_));
|
|
||||||
} else if (cmp_ret == 0) {
|
|
||||||
left_hit = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
set_vector_result<ResVec>(T_OP_IN == expr.type_, left_hit, right_has_null, res_vec, idx);
|
|
||||||
eval_flags.set(idx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user