From 43e2b37be76e15b06a05f386cabf5434a2eacfe6 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 17 Jun 2021 09:17:17 +0800 Subject: [PATCH] [TD-4740] --- src/common/src/ttypes.c | 10 +++++++++- tests/script/general/field/bigint.sim | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index 6fa27a029b..34dda32401 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -632,7 +632,15 @@ int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bo } // the string may be overflow according to errno - *value = issigned? strtoll(z, &endPtr, radix):strtoull(z, &endPtr, radix); + if (!issigned) { + const char *p = z; + while(*p != 0 && *p == ' ') p++; + if (*p != 0 && *p == '-') { return -1;} + + *value = strtoull(z, &endPtr, radix); + } else { + *value = strtoll(z, &endPtr, radix); + } // not a valid integer number, return error if (endPtr - z != n || errno == ERANGE) { diff --git a/tests/script/general/field/bigint.sim b/tests/script/general/field/bigint.sim index 3bb120c641..9736ac121f 100644 --- a/tests/script/general/field/bigint.sim +++ b/tests/script/general/field/bigint.sim @@ -32,6 +32,9 @@ while $i < 5 $ms = $x . m sql insert into $tb values (now + $ms , 0 ) $x = $x + 1 + sql_error insert into $tb values (now + $ms , -10) + sql_error insert into $tb values (now + $ms , -1000) + sql_error insert into $tb values (now + $ms , -10000000) endw $i = $i + 1 endw @@ -159,4 +162,4 @@ if $rows != 0 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT -- GitLab