[BUGFIX] fix enum to str typr error

This commit is contained in:
obdev
2023-03-07 10:11:25 +00:00
committed by ob-robot
parent cc7b6e8574
commit b354b4f0bf
3 changed files with 16 additions and 6 deletions

View File

@ -6038,7 +6038,9 @@ int ObAggregateProcessor::get_json_objectagg_result(const ObAggrInfo &aggr_info,
scale1 = (val_type1 == ObBitType) ? aggr_info.param_exprs_.at(1)->datum_meta_.length_semantics_ : scale1; scale1 = (val_type1 == ObBitType) ? aggr_info.param_exprs_.at(1)->datum_meta_.length_semantics_ : scale1;
ObCollationType cs_type1 = tmp_obj[1].get_collation_type(); ObCollationType cs_type1 = tmp_obj[1].get_collation_type();
ObString key_string = tmp_obj[0].get_string(); ObString key_string = tmp_obj[0].get_string();
if (OB_SUCC(ret) && ObCharset::charset_type_by_coll(cs_type0) != CHARSET_UTF8MB4) { if (OB_FAIL(ObTextStringHelper::read_real_string_data(&tmp_alloc, tmp_obj[0], key_string))) {
LOG_WARN("fail to read key string", K(ret), K(tmp_obj[0]));
} else if (ObCharset::charset_type_by_coll(cs_type0) != CHARSET_UTF8MB4) {
ObString converted_key_str; ObString converted_key_str;
if (OB_FAIL(ObExprUtil::convert_string_collation(key_string, cs_type0, converted_key_str, if (OB_FAIL(ObExprUtil::convert_string_collation(key_string, cs_type0, converted_key_str,
CS_TYPE_UTF8MB4_BIN, tmp_alloc))) { CS_TYPE_UTF8MB4_BIN, tmp_alloc))) {

View File

@ -58,10 +58,16 @@ int ObExprTypeToStr::calc_result_type2(ObExprResType &type,
UNUSED(type_ctx); UNUSED(type_ctx);
UNUSED(type2); UNUSED(type2);
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (get_raw_expr()->get_extra() == 1) { if (get_raw_expr()->get_extra() == 0) {
type.set_type(ObLongTextType);
} else {
type.set_type(ObVarcharType); type.set_type(ObVarcharType);
} else {
ObObjType dst_type = static_cast<ObObjType>(get_raw_expr()->get_extra());
if (!ob_is_large_text(dst_type)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid dst type", K(ret), K(dst_type));
} else {
type.set_type(dst_type);
}
} }
type.set_collation_type(type1.get_collation_type()); type.set_collation_type(type1.get_collation_type());
type.set_collation_level(CS_LEVEL_IMPLICIT); type.set_collation_level(CS_LEVEL_IMPLICIT);

View File

@ -3840,8 +3840,10 @@ int ObRawExprUtils::create_type_to_str_expr(ObRawExprFactory &expr_factory,
LOG_ERROR("allocate expr operator failed", K(ret)); LOG_ERROR("allocate expr operator failed", K(ret));
} else { } else {
out_expr->set_func_name(ObString::make_string(func_name)); out_expr->set_func_name(ObString::make_string(func_name));
if (is_lob_storage(dst_type)) { if (ob_is_large_text(dst_type)) {
out_expr->set_extra(1); out_expr->set_extra(static_cast<uint64_t>(dst_type));
} else {
out_expr->set_extra(0);
} }
} }