From 490ce0a9df2ceef2c1f25483a5c457ec3851c860 Mon Sep 17 00:00:00 2001 From: xf0 Date: Wed, 13 Oct 2021 20:33:10 +0800 Subject: [PATCH] fix bugs of INET expr --- src/sql/engine/expr/ob_expr_case.cpp | 2 +- src/sql/engine/expr/ob_expr_export_set.cpp | 4 ++-- src/sql/engine/expr/ob_expr_inet.cpp | 2 +- src/sql/engine/expr/ob_expr_int2ip.h | 11 +++++------ src/sql/rewrite/ob_transform_pre_process.cpp | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/sql/engine/expr/ob_expr_case.cpp b/src/sql/engine/expr/ob_expr_case.cpp index 6345cb61cf..b207ea43f0 100644 --- a/src/sql/engine/expr/ob_expr_case.cpp +++ b/src/sql/engine/expr/ob_expr_case.cpp @@ -49,7 +49,7 @@ int ObExprCase::calc_result_typeN( } else { // param_num >=3 and param_num is odd /* in order to be compatible with mysql - * both in ob_expr_cae.cpp and ob_expr_arg_case.cpp + * both in ob_expr_case.cpp and ob_expr_arg_case.cpp * types_stack includes the condition exprs. * In expr_case, there is no arg param expr compared with expr_arg_case */ diff --git a/src/sql/engine/expr/ob_expr_export_set.cpp b/src/sql/engine/expr/ob_expr_export_set.cpp index 128e968456..ecde0f39ca 100644 --- a/src/sql/engine/expr/ob_expr_export_set.cpp +++ b/src/sql/engine/expr/ob_expr_export_set.cpp @@ -52,7 +52,7 @@ int ObExprExportSet::calc_result_typeN(ObExprResType& type, ObExprResType* types int64_t str_num = 2; const uint64_t max_len = std::max(on_len, off_len); // when bits exceed uint_max or int_min, ob is not compatible to mysql. - types_array[0].set_calc_type(common::ObBitType); + types_array[0].set_calc_type(common::ObUInt64Type); types_array[1].set_calc_type(common::ObVarcharType); types_array[2].set_calc_type(common::ObVarcharType); if (3 < param_num) { @@ -130,7 +130,7 @@ int ObExprExportSet::calc_export_set(ObObj& result, const ObObj& bits, const ObO local_on = on.get_string(); local_off = off.get_string(); local_sep = sep.get_string(); - if (OB_FAIL(bits.get_bit(local_bits))) { + if (OB_FAIL(bits.get_uint64(local_bits))) { LOG_WARN("fail to get bit", K(ret), K(bits)); } else if (OB_FAIL(n_bits.get_int(local_n_bits))) { LOG_WARN("fail to get int", K(ret), K(n_bits)); diff --git a/src/sql/engine/expr/ob_expr_inet.cpp b/src/sql/engine/expr/ob_expr_inet.cpp index fb8d1dedd8..eeffc94f85 100644 --- a/src/sql/engine/expr/ob_expr_inet.cpp +++ b/src/sql/engine/expr/ob_expr_inet.cpp @@ -468,7 +468,7 @@ inline int ObExprInet6Ntoa::calc_result_type1( ret = OB_ERR_UNEXPECTED; LOG_WARN("session is null",K(ret)); } else { - type.set_collation_type(session->get_nls_collation()); + type.set_collation_type(get_default_collation_type(type.get_type(), *type_ctx.get_session())); } return ret; } diff --git a/src/sql/engine/expr/ob_expr_int2ip.h b/src/sql/engine/expr/ob_expr_int2ip.h index 545e046e0a..cd94aae4e4 100644 --- a/src/sql/engine/expr/ob_expr_int2ip.h +++ b/src/sql/engine/expr/ob_expr_int2ip.h @@ -39,16 +39,15 @@ private: inline int ObExprInt2ip::calc_result_type1( ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const { - UNUSED(type_ctx); - UNUSED(text); + type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_STRING_INTEGER_TRUNC); + text.set_calc_type(common::ObIntType); type.set_varchar(); type.set_length(common::MAX_IP_ADDR_LENGTH); type.set_collation_level(common::CS_LEVEL_COERCIBLE); type.set_default_collation_type(); - // set calc type - text.set_calc_type(common::ObIntType); return common::OB_SUCCESS; } -} // namespace sql -} // namespace oceanbase + +} +} #endif /* OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_INT2IP_ */ diff --git a/src/sql/rewrite/ob_transform_pre_process.cpp b/src/sql/rewrite/ob_transform_pre_process.cpp index 37927ea6c8..2a8c7a088b 100644 --- a/src/sql/rewrite/ob_transform_pre_process.cpp +++ b/src/sql/rewrite/ob_transform_pre_process.cpp @@ -3362,7 +3362,7 @@ int ObTransformPreProcess::create_equal_expr_for_case_expr(ObRawExprFactory& exp int ret = OB_SUCCESS; ObObjType obj_type = ObMaxType; const ObExprResType& arg_type = arg_expr->get_result_type(); - const ObExprResType& when_type = arg_expr->get_result_type(); + const ObExprResType& when_type = when_expr->get_result_type(); ObRawExpr* new_when_expr = NULL; // cast expr may added ObRawExpr* new_arg_expr = NULL; if (OB_ISNULL(arg_expr) || OB_ISNULL(when_expr)) { -- GitLab