diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index 6fa27a029bfd5356cca3e34dffe8d3018ade9fd8..34dda32401b604450b3179cf0f344f53b6e2cb51 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 3bb120c6410a2ea2e9c671bb4aca56fc8014124f..9736ac121fac21a443b2c740b27cede465bc460f 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