提交 35a20136 编写于 作者: wmmhello's avatar wmmhello

fix/TD-10399 <fix> fix error tips because of overflowing of convert time precision

上级 0777f280
...@@ -380,15 +380,20 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec ...@@ -380,15 +380,20 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec
assert(toPrecision == TSDB_TIME_PRECISION_MILLI || assert(toPrecision == TSDB_TIME_PRECISION_MILLI ||
toPrecision == TSDB_TIME_PRECISION_MICRO || toPrecision == TSDB_TIME_PRECISION_MICRO ||
toPrecision == TSDB_TIME_PRECISION_NANO); toPrecision == TSDB_TIME_PRECISION_NANO);
double tempResult = time;
switch(fromPrecision) { switch(fromPrecision) {
case TSDB_TIME_PRECISION_MILLI: { case TSDB_TIME_PRECISION_MILLI: {
switch (toPrecision) { switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI: case TSDB_TIME_PRECISION_MILLI:
return time; return time;
case TSDB_TIME_PRECISION_MICRO: case TSDB_TIME_PRECISION_MICRO:
return time * 1000; tempResult *= 1000;
time *= 1000;
goto end_;
case TSDB_TIME_PRECISION_NANO: case TSDB_TIME_PRECISION_NANO:
return time * 1000000; tempResult *= 1000000;
time *= 1000000;
goto end_;
} }
} // end from milli } // end from milli
case TSDB_TIME_PRECISION_MICRO: { case TSDB_TIME_PRECISION_MICRO: {
...@@ -398,7 +403,9 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec ...@@ -398,7 +403,9 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec
case TSDB_TIME_PRECISION_MICRO: case TSDB_TIME_PRECISION_MICRO:
return time; return time;
case TSDB_TIME_PRECISION_NANO: case TSDB_TIME_PRECISION_NANO:
return time * 1000; tempResult *= 1000;
time *= 1000;
goto end_;
} }
} //end from micro } //end from micro
case TSDB_TIME_PRECISION_NANO: { case TSDB_TIME_PRECISION_NANO: {
...@@ -416,6 +423,10 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec ...@@ -416,6 +423,10 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec
return time; // only to pass windows compilation return time; // only to pass windows compilation
} }
} //end switch fromPrecision } //end switch fromPrecision
end_:
if (tempResult > (double)INT64_MAX) return INT64_MAX;
if (tempResult < (double)INT64_MIN) return INT64_MIN;
return time;
} }
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) { static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
......
...@@ -70,7 +70,8 @@ SSqlInfo qSqlParse(const char *pStr) { ...@@ -70,7 +70,8 @@ SSqlInfo qSqlParse(const char *pStr) {
default: default:
Parse(pParser, t0.type, t0, &sqlInfo); Parse(pParser, t0.type, t0, &sqlInfo);
if (sqlInfo.valid == false) { if (sqlInfo.valid == false || terrno != TSDB_CODE_SUCCESS) {
snprintf(sqlInfo.msg, tListLen(sqlInfo.msg), "%s", t0.z);
goto abort_parse; goto abort_parse;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册