提交 93676a18 编写于 作者: B br0 提交者: LINGuanRen

Fix NAN related operator bugs in non-static typing engine

上级 42a62429
......@@ -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];
......
......@@ -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
......
......@@ -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));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册