Fix prefix_pattern type deduce bug
This commit is contained in:
@ -180,63 +180,21 @@ int ObExprPrefixPattern::calc_result_type3(ObExprResType &type,
|
|||||||
ObExprTypeCtx &type_ctx) const
|
ObExprTypeCtx &type_ctx) const
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (lib::is_oracle_mode()) {
|
if ((!ob_is_string_type(type1.get_type()) && !type1.is_null())
|
||||||
auto str_params = make_const_carray(&type1);
|
|| (!ob_is_string_type(type3.get_type()) && !type3.is_null())) {
|
||||||
int64_t mbmaxlen = 0;
|
ret = OB_INVALID_ARGUMENT;
|
||||||
type2.set_calc_type(ObNumberType);
|
LOG_WARN("invalid param type", K(ret), K(type1), K(type2), K(type3));
|
||||||
type2.set_calc_scale(NUMBER_SCALE_UNKNOWN_YET);
|
|
||||||
type3.set_calc_type(ObVarcharType);
|
|
||||||
type3.set_calc_collation_type(type_ctx.get_session()->get_nls_collation());
|
|
||||||
type3.set_calc_collation_level(CS_LEVEL_IMPLICIT);
|
|
||||||
if(OB_FAIL(aggregate_string_type_and_charset_oracle(*type_ctx.get_session(),
|
|
||||||
str_params,
|
|
||||||
type,
|
|
||||||
PREFER_VAR_LEN_CHAR))) {
|
|
||||||
LOG_WARN("fail to aggregate string type and charset for result", K(ret));
|
|
||||||
} else if (OB_FAIL(deduce_string_param_calc_type_and_charset(*type_ctx.get_session(), type, str_params))) {
|
|
||||||
LOG_WARN("fail to deduce calc type and charset for params", K(ret));
|
|
||||||
} else {
|
|
||||||
if (type.is_varchar_or_char() && LS_BYTE == type.get_length_semantics()) {
|
|
||||||
if (OB_FAIL(ObCharset::get_mbmaxlen_by_coll(type.get_collation_type(), mbmaxlen))) {
|
|
||||||
SQL_RESV_LOG(WARN, "fail to get mbmaxlen", K(ret), K(type));
|
|
||||||
} else {
|
|
||||||
type.set_length(static_cast<ObLength>(type1.get_calc_length() * mbmaxlen));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
type.set_length(type1.get_calc_length());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const int32_t mbmaxlen = 4;
|
type1.set_calc_meta(type1.get_obj_meta());
|
||||||
if (ObTextType == type1.get_type()
|
type2.set_calc_meta(type2.get_obj_meta());
|
||||||
|| ObMediumTextType == type1.get_type()
|
type3.set_calc_meta(type3.get_obj_meta());
|
||||||
|| ObLongTextType == type1.get_type()) {
|
type.set_meta(type1.get_obj_meta());
|
||||||
type.set_type(ObLongTextType);
|
type.set_accuracy(type1.get_accuracy());
|
||||||
type.set_length(OB_MAX_LONGTEXT_LENGTH / mbmaxlen);
|
if (lib::is_oracle_mode()) {
|
||||||
} else if (ObTinyTextType == type1.get_type()) {
|
type2.set_calc_type(ObNumberType);
|
||||||
type.set_type(ObTextType);
|
type2.set_calc_scale(NUMBER_SCALE_UNKNOWN_YET);
|
||||||
type.set_length(OB_MAX_TEXT_LENGTH / mbmaxlen);
|
|
||||||
} else {
|
} else {
|
||||||
type.set_varchar();
|
type2.set_calc_type(ObIntType);
|
||||||
type.set_length(static_cast<ObLength>(type1.get_length()));
|
|
||||||
}
|
|
||||||
OZ(aggregate_charsets_for_string_result(type, &type1, 1, type_ctx.get_coll_type()));
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if ((type1.is_text() || type1.is_blob())) {
|
|
||||||
// do nothing
|
|
||||||
} else {
|
|
||||||
type1.set_calc_type(ObVarcharType);
|
|
||||||
}
|
|
||||||
type1.set_calc_collation_level(type.get_calc_collation_level());
|
|
||||||
type1.set_calc_collation_type(type.get_collation_type());
|
|
||||||
}
|
|
||||||
type2.set_calc_type(ObIntType);
|
|
||||||
type3.set_calc_type(ObVarcharType);
|
|
||||||
type3.set_calc_collation_type(type3.get_collation_type());
|
|
||||||
type3.set_calc_collation_level(type3.get_collation_level());
|
|
||||||
if (OB_SUCC(ret) && type.is_varchar()) {
|
|
||||||
// Set cast mode for integer parameters, truncate string to integer.
|
|
||||||
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_STRING_INTEGER_TRUNC);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user