提交 09072fba 编写于 作者: S Shengliang Guan

TD-1057 localtime func may crash while input < 0 in windows

上级 872ec08f
...@@ -368,6 +368,10 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { ...@@ -368,6 +368,10 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
tt = (time_t)(val / 1000); tt = (time_t)(val / 1000);
} }
if (tt < 0) {
tt = 0;
}
struct tm* ptm = localtime(&tt); struct tm* ptm = localtime(&tt);
size_t pos = strftime(buf, 32, "%Y-%m-%d %H:%M:%S", ptm); size_t pos = strftime(buf, 32, "%Y-%m-%d %H:%M:%S", ptm);
......
...@@ -23,7 +23,7 @@ void taosRemoveDir(char *rootDir) { ...@@ -23,7 +23,7 @@ void taosRemoveDir(char *rootDir) {
int taosMkDir(const char *path, mode_t mode) { int taosMkDir(const char *path, mode_t mode) {
uError("%s not implemented yet", __FUNCTION__); uError("%s not implemented yet", __FUNCTION__);
return -1; return 0;
} }
void taosMvDir(char* destDir, char *srcDir) { void taosMvDir(char* destDir, char *srcDir) {
......
...@@ -69,12 +69,14 @@ if $data00 != @{slop:1.000000, intercept:1.000000}@ then ...@@ -69,12 +69,14 @@ if $data00 != @{slop:1.000000, intercept:1.000000}@ then
endi endi
print =============== step5 print =============== step5
print select leastsquares(tbcol, 1, 1) as b from $tb interval(1d)
sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m) sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m)
print ===> $data01 print ===> $data01
if $data01 != @{slop:1.000000, intercept:1.000000}@ then if $data01 != @{slop:1.000000, intercept:1.000000}@ then
return -1 return -1
endi endi
print select leastsquares(tbcol, 1, 1) as b from $tb interval(1d)
sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d) sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d)
print ===> $data01 print ===> $data01
if $data01 != @{slop:1.000000, intercept:1.000000}@ then if $data01 != @{slop:1.000000, intercept:1.000000}@ then
......
...@@ -783,10 +783,15 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { ...@@ -783,10 +783,15 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
tt = *(int64_t *)row[i] / 1000; tt = *(int64_t *)row[i] / 1000;
if (tt < 0) {
tt = 0;
}
tp = localtime(&tt); tp = localtime(&tt);
strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", tp); strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", tp);
sprintf(value, "%s.%03d", timeStr, sprintf(value, "%s.%03d", timeStr,
(int)(*((int64_t *)row[i]) % 1000)); (int)(*((int64_t *)row[i]) % 1000));
break; break;
default: default:
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册