diff --git a/src/share/object/ob_obj_cast.cpp b/src/share/object/ob_obj_cast.cpp index 9df9657a62e195be2dd1bcf3121d8b90f5c3ffcc..6373d1b39561bf87816931fb94367861a758c189 100644 --- a/src/share/object/ob_obj_cast.cpp +++ b/src/share/object/ob_obj_cast.cpp @@ -1603,6 +1603,12 @@ static int float_number( if (OB_UNLIKELY(ObFloatTC != in.get_type_class() || ObNumberTC != ob_obj_type_class(expect_type))) { ret = OB_ERR_UNEXPECTED; LOG_ERROR("invalid input type", K(ret), K(in), K(expect_type)); + } else if (isnan(value)) { + ret = OB_INVALID_NUMERIC; + LOG_WARN("float_number failed ", K(ret), K(value)); + } else if (isinf(value)) { + ret = OB_NUMERIC_OVERFLOW; + LOG_WARN("float_number failed", K(ret), K(value)); } else if (ObUNumberType == expect_type && CAST_FAIL(numeric_negative_check(value))) { } else { char buf[MAX_DOUBLE_STRICT_PRINT_SIZE]; @@ -1902,6 +1908,12 @@ static int double_number( if (OB_UNLIKELY(ObDoubleTC != in.get_type_class() || ObNumberTC != ob_obj_type_class(expect_type))) { ret = OB_ERR_UNEXPECTED; LOG_ERROR("invalid input type", K(ret), K(in), K(expect_type)); + } else if (isnan(value) && lib::is_oracle_mode()) { + ret = OB_INVALID_NUMERIC; + LOG_WARN("float_number failed ", K(ret), K(value)); + } else if (isinf(value) && lib::is_oracle_mode()) { + ret = OB_NUMERIC_OVERFLOW; + LOG_WARN("float_number failed", K(ret), K(value)); } else if (ObUNumberType == expect_type && CAST_FAIL(numeric_negative_check(value))) { } else { char buf[MAX_DOUBLE_STRICT_PRINT_SIZE]; diff --git a/src/sql/engine/expr/ob_expr_operator.cpp b/src/sql/engine/expr/ob_expr_operator.cpp index 95d9784619d0d5209ad67e7a791097051a687836..e384532957cb174d3ac84bec76c3820a7868b8b2 100644 --- a/src/sql/engine/expr/ob_expr_operator.cpp +++ b/src/sql/engine/expr/ob_expr_operator.cpp @@ -1841,7 +1841,7 @@ int ObRelationalExprOperator::calc_result2( int ret = OB_SUCCESS; // TODO:: raw // bool need_cast = (share::is_oracle_mode() && obj1.get_collation_type() != obj2.get_collation_type()); - bool need_cast = false; + bool need_cast = (share::is_oracle_mode() && obj1.get_type() != obj2.get_type()); EXPR_DEFINE_CMP_CTX(result_type_.get_calc_meta(), is_null_safe, expr_ctx); /* * FIX ME,please. It seems that we must check obj1 and obj2 are null or not here diff --git a/src/sql/engine/expr/ob_expr_power.cpp b/src/sql/engine/expr/ob_expr_power.cpp index 2a44583d56ff583b68a937187b942133e01704a0..ca964cc81a21776d6efae102f016d0d0a60c0073 100644 --- a/src/sql/engine/expr/ob_expr_power.cpp +++ b/src/sql/engine/expr/ob_expr_power.cpp @@ -70,14 +70,8 @@ int ObExprPower::calc(ObObj& result, const ObObj& obj1, const ObObj& obj2, ObExp } else if (obj1.is_double() && obj2.is_double()) { // same as oracle behavior: if at least one of the arguments is // binary_double, result type is double - double double_base = obj1.get_double(); - double double_exponent = obj2.get_double(); - double result_double = std::pow(double_base, double_exponent); - if (isinf(result_double) || isnan(result_double)) { - ret = OB_OPERATE_OVERFLOW; - } else { - result.set_double(result_double); - } + // keep same with static typing engine. + ret = ObExprPow::safe_set_double(result, std::pow(obj1.get_double(), obj2.get_double())); } else { ret = OB_ERR_UNEXPECTED; LOG_WARN("obj type should be number or double", K(obj1), K(obj2), K(ret));