Fix regexp function bug

This commit is contained in:
obdev
2023-04-13 09:05:30 +00:00
committed by ob-robot
parent 48c57d0564
commit c1ac596d14
13 changed files with 146 additions and 32 deletions

View File

@ -50,14 +50,24 @@ int ObExprRegexpInstr::calc_result_typeN(ObExprResType &type,
ret = OB_ERR_PARAM_SIZE;
LOG_WARN("param number of regexp_instr at least 2 and at most 7", K(ret), K(param_num));
} else {
bool is_case_sensitive = types[0].get_calc_collation_type();
for (int i = 0; OB_SUCC(ret) && i < param_num; i++) {
if (!types[i].is_null() && !is_type_valid(types[i].get_type())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("the parameter is not castable", K(ret), K(i));
}
}
if (OB_SUCC(ret) && is_mysql_mode()) {
ObExprResType cmp_type;
if (OB_FAIL(ObExprRegexContext::check_binary_compatible(types, 2))) {
LOG_WARN("types are not compatible with binary.", K(ret));
} else if (OB_FAIL(aggregate_charsets_for_comparison(cmp_type, types, 2, type_ctx.get_coll_type()))) {
LOG_WARN("fail to aggregate charsets for comparison");
} else {
is_case_sensitive = ObCharset::is_bin_sort(cmp_type.get_calc_collation_type());
}
}
if (OB_SUCC(ret)) {
bool is_case_sensitive = ObCharset::is_bin_sort(types[0].get_calc_collation_type());
bool need_utf8 = false;
switch (param_num) {
case 7/*subexpr*/: