提交 7dc47e8e 编写于 作者: S st0 提交者: wangzelin.wzl

fix cast string to number overflow bug

上级 fd70eda2
...@@ -3681,7 +3681,7 @@ static int string_number( ...@@ -3681,7 +3681,7 @@ static int string_number(
ret = value.from_sci_opt(str.ptr(), str.length(), params, &res_precision, &res_scale); ret = value.from_sci_opt(str.ptr(), str.length(), params, &res_precision, &res_scale);
// select cast('1e500' as decimal); -> max_val // select cast('1e500' as decimal); -> max_val
// select cast('-1e500' as decimal); -> min_val // select cast('-1e500' as decimal); -> min_val
if (CM_IS_SET_MIN_IF_OVERFLOW(cast_mode) && ret == OB_NUMERIC_OVERFLOW) { if (ret == OB_NUMERIC_OVERFLOW) {
int64_t i = 0; int64_t i = 0;
while (i < str.length() && isspace(str[i])) { while (i < str.length() && isspace(str[i])) {
++i; ++i;
......
...@@ -844,7 +844,7 @@ static OB_INLINE int common_string_number( ...@@ -844,7 +844,7 @@ static OB_INLINE int common_string_number(
ret = nmb.from_sci_opt(in_str.ptr(), in_str.length(), alloc, &res_precision, &res_scale); ret = nmb.from_sci_opt(in_str.ptr(), in_str.length(), alloc, &res_precision, &res_scale);
// select cast('1e500' as decimal); -> max_val // select cast('1e500' as decimal); -> max_val
// select cast('-1e500' as decimal); -> min_val // select cast('-1e500' as decimal); -> min_val
if (OB_NUMERIC_OVERFLOW == ret && CM_IS_SET_MIN_IF_OVERFLOW(expr.extra_)) { if (OB_NUMERIC_OVERFLOW == ret) {
int64_t i = 0; int64_t i = 0;
while (i < in_str.length() && isspace(in_str[i])) { while (i < in_str.length() && isspace(in_str[i])) {
++i; ++i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册