Fix NAN related operator bugs in non-static typing engine
This commit is contained in:
@ -1603,6 +1603,12 @@ static int float_number(
|
|||||||
if (OB_UNLIKELY(ObFloatTC != in.get_type_class() || ObNumberTC != ob_obj_type_class(expect_type))) {
|
if (OB_UNLIKELY(ObFloatTC != in.get_type_class() || ObNumberTC != ob_obj_type_class(expect_type))) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_ERROR("invalid input type", K(ret), K(in), K(expect_type));
|
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 if (ObUNumberType == expect_type && CAST_FAIL(numeric_negative_check(value))) {
|
||||||
} else {
|
} else {
|
||||||
char buf[MAX_DOUBLE_STRICT_PRINT_SIZE];
|
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))) {
|
if (OB_UNLIKELY(ObDoubleTC != in.get_type_class() || ObNumberTC != ob_obj_type_class(expect_type))) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_ERROR("invalid input type", K(ret), K(in), K(expect_type));
|
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 if (ObUNumberType == expect_type && CAST_FAIL(numeric_negative_check(value))) {
|
||||||
} else {
|
} else {
|
||||||
char buf[MAX_DOUBLE_STRICT_PRINT_SIZE];
|
char buf[MAX_DOUBLE_STRICT_PRINT_SIZE];
|
||||||
|
|||||||
@ -1841,7 +1841,7 @@ int ObRelationalExprOperator::calc_result2(
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
// TODO:: raw
|
// TODO:: raw
|
||||||
// bool need_cast = (share::is_oracle_mode() && obj1.get_collation_type() != obj2.get_collation_type());
|
// 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);
|
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
|
* FIX ME,please. It seems that we must check obj1 and obj2 are null or not here
|
||||||
|
|||||||
@ -70,14 +70,8 @@ int ObExprPower::calc(ObObj& result, const ObObj& obj1, const ObObj& obj2, ObExp
|
|||||||
} else if (obj1.is_double() && obj2.is_double()) {
|
} else if (obj1.is_double() && obj2.is_double()) {
|
||||||
// same as oracle behavior: if at least one of the arguments is
|
// same as oracle behavior: if at least one of the arguments is
|
||||||
// binary_double, result type is double
|
// binary_double, result type is double
|
||||||
double double_base = obj1.get_double();
|
// keep same with static typing engine.
|
||||||
double double_exponent = obj2.get_double();
|
ret = ObExprPow::safe_set_double(result, std::pow(obj1.get_double(), 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);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("obj type should be number or double", K(obj1), K(obj2), K(ret));
|
LOG_WARN("obj type should be number or double", K(obj1), K(obj2), K(ret));
|
||||||
|
|||||||
Reference in New Issue
Block a user