fix: localtime issue

This commit is contained in:
dapan1121 2024-10-10 09:45:37 +08:00
parent 0aae99ca8f
commit d55a0032b1
17 changed files with 65 additions and 64 deletions

View File

@ -64,7 +64,7 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
: 1000000000;
time_t t = taosTime(NULL);
struct tm tm;
(void) taosLocalTime(&t, &tm, NULL);
(void) taosLocalTime(&t, &tm, NULL, 0);
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;

View File

@ -251,6 +251,7 @@ void syslog(int unused, const char *format, ...);
#define TD_LOCALE_LEN 64
#define TD_CHARSET_LEN 64
#define TD_TIMEZONE_LEN 96
#define TD_TIME_STR_LEN 128
#define TD_IP_LEN 64
#ifdef __cplusplus

View File

@ -91,7 +91,7 @@ static FORCE_INLINE int64_t taosGetMonoTimestampMs() {
}
char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm);
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf);
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf, int32_t bufSize);
struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst);
time_t taosTime(time_t *t);
time_t taosMktime(struct tm *timep);

View File

@ -2446,7 +2446,7 @@ _error:
return NULL;
}
static char* formatTimestamp(char* buf, int64_t val, int precision) {
static char* formatTimestamp(char* buf, int32_t bufSize, int64_t val, int precision) {
time_t tt;
int32_t ms = 0;
if (precision == TSDB_TIME_PRECISION_NANO) {
@ -2479,11 +2479,11 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
}
}
struct tm ptm = {0};
if (taosLocalTime(&tt, &ptm, buf) == NULL) {
if (taosLocalTime(&tt, &ptm, buf, bufSize) == NULL) {
return buf;
}
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
size_t pos = strftime(buf, bufSize, "%Y-%m-%d %H:%M:%S", &ptm);
if (precision == TSDB_TIME_PRECISION_NANO) {
sprintf(buf + pos, ".%09d", ms);
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
@ -2500,7 +2500,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
int32_t size = 2048 * 1024;
int32_t code = 0;
char* dumpBuf = NULL;
char pBuf[128] = {0};
char pBuf[TD_TIME_STR_LEN] = {0};
int32_t rows = pDataBlock->info.rows;
int32_t len = 0;
@ -2543,7 +2543,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
switch (pColInfoData->info.type) {
case TSDB_DATA_TYPE_TIMESTAMP:
memset(pBuf, 0, sizeof(pBuf));
(void)formatTimestamp(pBuf, *(uint64_t*)var, pColInfoData->info.precision);
(void)formatTimestamp(pBuf, sizeof(pBuf), *(uint64_t*)var, pColInfoData->info.precision);
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
if (len >= size - 1) goto _exit;
break;

View File

@ -33,7 +33,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
}
struct tm tm;
time_t t = (time_t)start;
taosLocalTime(&t, &tm);
taosLocalTime(&t, &tm, NULL, 0);
tm.tm_sec = 0;
tm.tm_min = 0;
tm.tm_hour = 0;

View File

@ -693,7 +693,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
struct tm tm;
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
struct tm* ptm = taosLocalTime(&tt, &tm, NULL);
struct tm* ptm = taosLocalTime(&tt, &tm, NULL, 0);
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
tm.tm_year = mon / 12;
tm.tm_mon = mon % 12;
@ -754,11 +754,11 @@ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interva
struct tm tm;
time_t t = (time_t)skey;
struct tm* ptm = taosLocalTime(&t, &tm, NULL);
struct tm* ptm = taosLocalTime(&t, &tm, NULL, 0);
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
t = (time_t)ekey;
ptm = taosLocalTime(&t, &tm, NULL);
ptm = taosLocalTime(&t, &tm, NULL, 0);
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
if (unit == 'y') {
@ -782,7 +782,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
struct tm tm;
time_t tt = (time_t)start;
struct tm* ptm = taosLocalTime(&tt, &tm, NULL);
struct tm* ptm = taosLocalTime(&tt, &tm, NULL, 0);
tm.tm_sec = 0;
tm.tm_min = 0;
tm.tm_hour = 0;
@ -911,13 +911,13 @@ int64_t taosTimeGetIntervalEnd(int64_t intervalStart, const SInterval* pInterval
// 2020-07-03 17:48:42
// and the parameter can also be a variable.
const char* fmtts(int64_t ts) {
static char buf[96] = {0};
static char buf[TD_TIME_STR_LEN] = {0};
size_t pos = 0;
struct tm tm;
if (ts > -62135625943 && ts < 32503651200) {
time_t t = (time_t)ts;
if (taosLocalTime(&t, &tm, buf) == NULL) {
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
return buf;
}
pos += strftime(buf + pos, sizeof(buf), "s=%Y-%m-%d %H:%M:%S", &tm);
@ -925,7 +925,7 @@ const char* fmtts(int64_t ts) {
if (ts > -62135625943000 && ts < 32503651200000) {
time_t t = (time_t)(ts / 1000);
if (taosLocalTime(&t, &tm, buf) == NULL) {
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
return buf;
}
if (pos > 0) {
@ -939,7 +939,7 @@ const char* fmtts(int64_t ts) {
{
time_t t = (time_t)(ts / 1000000);
if (taosLocalTime(&t, &tm, buf) == NULL) {
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
return buf;
}
if (pos > 0) {
@ -993,7 +993,7 @@ int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precisio
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
}
if (NULL == taosLocalTime(&quot, &ptm, buf)) {
if (NULL == taosLocalTime(&quot, &ptm, buf, bufLen)) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
}
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
@ -1007,7 +1007,7 @@ int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precisio
int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm) {
tm->fsec = ts % TICK_PER_SECOND[precision] * (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]);
time_t t = ts / TICK_PER_SECOND[precision];
if (NULL == taosLocalTime(&t, &tm->tm, NULL)) {
if (NULL == taosLocalTime(&t, &tm->tm, NULL, 0)) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
}
return TSDB_CODE_SUCCESS;

View File

@ -208,10 +208,10 @@ static int32_t countTrailingSpaces(const SValueNode* pVal, bool isLtrim) {
}
static int32_t addTimezoneParam(SNodeList* pList) {
char buf[6] = {0};
char buf[TD_TIME_STR_LEN] = {0};
time_t t = taosTime(NULL);
struct tm tmInfo;
if (taosLocalTime(&t, &tmInfo, buf) != NULL) {
if (taosLocalTime(&t, &tmInfo, buf, sizeof(buf)) != NULL) {
(void)strftime(buf, sizeof(buf), "%z", &tmInfo);
}
int32_t len = (int32_t)strlen(buf);

View File

@ -2193,7 +2193,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
NUM_TO_STRING(type, input, sizeof(fraction), fraction);
int32_t fractionLen;
char buf[64] = {0};
char buf[TD_TIME_STR_LEN] = {0};
int64_t timeVal;
char* format = NULL;
int64_t quot = 0;
@ -2244,7 +2244,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
struct tm tmInfo;
int32_t len = 0;
if (taosLocalTime((const time_t *)&quot, &tmInfo, buf) == NULL) {
if (taosLocalTime((const time_t *)&quot, &tmInfo, buf, sizeof(buf)) == NULL) {
len = (int32_t)strlen(buf);
goto _end;
}

View File

@ -332,8 +332,8 @@ int32_t taosGetFqdn(char *fqdn) {
// thus, we choose AF_INET (ipv4 for the moment) to make getaddrinfo return
// immediately
// hints.ai_family = AF_INET;
tstrncpy(fqdn, hostname, TSDB_FQDN_LEN);
tstrncpy(fqdn + strlen(hostname), ".local", TSDB_FQDN_LEN - strlen(hostname));
tstrncpy(fqdn, hostname, TD_FQDN_LEN);
tstrncpy(fqdn + strlen(hostname), ".local", TD_FQDN_LEN - strlen(hostname));
#else // linux
#endif // linux

View File

@ -474,15 +474,15 @@ time_t taosMktime(struct tm *timep) {
#endif
}
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf) {
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf, int32_t bufSize) {
struct tm *res = NULL;
if (timep == NULL) {
if (timep == NULL || result == NULL) {
return NULL;
}
#ifdef WINDOWS
if (*timep < -2208988800LL) {
if (buf != NULL) {
snprintf(buf, 4, "NaN");
snprintf(buf, bufSize, "NaN");
}
return NULL;
} else if (*timep < 0) {
@ -494,7 +494,7 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf) {
time_t tt = 0;
if (localtime_s(&tm1, &tt) != 0) {
if (buf != NULL) {
snprintf(buf, 4, "NaN");
snprintf(buf, bufSize, "NaN");
}
return NULL;
}
@ -525,7 +525,7 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf) {
} else {
if (localtime_s(result, timep) != 0) {
if (buf != NULL) {
snprintf(buf, 4, "NaN");
snprintf(buf, bufSize, "NaN");
}
return NULL;
}
@ -533,7 +533,7 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf) {
#else
res = localtime_r(timep, result);
if (res == NULL && buf != NULL) {
(void)snprintf(buf, 4, "NaN");
(void)snprintf(buf, bufSize, "NaN");
}
#endif
return result;

View File

@ -926,7 +926,7 @@ int32_t taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone)
*/
time_t tx1 = taosGetTimestampSec();
struct tm tm1;
if (taosLocalTime(&tx1, &tm1, NULL) == NULL) {
if (taosLocalTime(&tx1, &tm1, NULL, 0) == NULL) {
return TSDB_CODE_TIME_ERROR;
}
daylight = tm1.tm_isdst;
@ -956,7 +956,7 @@ int32_t taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone)
*/
time_t tx1 = taosGetTimestampSec();
struct tm tm1;
if(taosLocalTime(&tx1, &tm1, NULL) == NULL) {
if(taosLocalTime(&tx1, &tm1, NULL, 0) == NULL) {
return TSDB_CODE_TIME_ERROR;
}
/* load time zone string from /etc/timezone */
@ -1037,7 +1037,7 @@ int32_t taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone)
*/
time_t tx1 = taosGetTimestampSec();
struct tm tm1;
if(taosLocalTime(&tx1, &tm1, NULL) == NULL) {
if(taosLocalTime(&tx1, &tm1, NULL, 0) == NULL) {
return TSDB_CODE_TIME_ERROR;
}
isdst_now = tm1.tm_isdst;

View File

@ -50,7 +50,7 @@ TEST(osTimeTests, taosLocalTime) {
// Test 1: Test when both timep and result are not NULL
time_t timep = 1617531000; // 2021-04-04 18:10:00
struct tm result;
struct tm* local_time = taosLocalTime(&timep, &result, NULL);
struct tm* local_time = taosLocalTime(&timep, &result, NULL, 0);
ASSERT_NE(local_time, nullptr);
ASSERT_EQ(local_time->tm_year, 121);
ASSERT_EQ(local_time->tm_mon, 3);
@ -60,13 +60,13 @@ TEST(osTimeTests, taosLocalTime) {
ASSERT_EQ(local_time->tm_sec, 00);
// Test 2: Test when timep is NULL
local_time = taosLocalTime(NULL, &result, NULL);
local_time = taosLocalTime(NULL, &result, NULL, 0);
ASSERT_EQ(local_time, nullptr);
// Test 4: Test when timep is negative on Windows
#ifdef WINDOWS
time_t pos_timep = 1609459200; // 2021-01-01 08:00:00
local_time = taosLocalTime(&pos_timep, &result, NULL);
local_time = taosLocalTime(&pos_timep, &result, NULL, 0);
ASSERT_NE(local_time, nullptr);
ASSERT_EQ(local_time->tm_year, 121);
ASSERT_EQ(local_time->tm_mon, 0);
@ -76,7 +76,7 @@ TEST(osTimeTests, taosLocalTime) {
ASSERT_EQ(local_time->tm_sec, 0);
time_t neg_timep = -1617531000; // 1918-09-29 21:50:00
local_time = taosLocalTime(&neg_timep, &result, NULL);
local_time = taosLocalTime(&neg_timep, &result, NULL, 0);
ASSERT_NE(local_time, nullptr);
ASSERT_EQ(local_time->tm_year, 18);
ASSERT_EQ(local_time->tm_mon, 8);
@ -86,7 +86,7 @@ TEST(osTimeTests, taosLocalTime) {
ASSERT_EQ(local_time->tm_sec, 0);
time_t neg_timep2 = -315619200; // 1960-01-01 08:00:00
local_time = taosLocalTime(&neg_timep2, &result, NULL);
local_time = taosLocalTime(&neg_timep2, &result, NULL, 0);
ASSERT_NE(local_time, nullptr);
ASSERT_EQ(local_time->tm_year, 60);
ASSERT_EQ(local_time->tm_mon, 0);
@ -96,7 +96,7 @@ TEST(osTimeTests, taosLocalTime) {
ASSERT_EQ(local_time->tm_sec, 0);
time_t zero_timep = 0; // 1970-01-01 08:00:00
local_time = taosLocalTime(&zero_timep, &result, NULL);
local_time = taosLocalTime(&zero_timep, &result, NULL, 0);
ASSERT_NE(local_time, nullptr);
ASSERT_EQ(local_time->tm_year, 70);
ASSERT_EQ(local_time->tm_mon, 0);
@ -106,7 +106,7 @@ TEST(osTimeTests, taosLocalTime) {
ASSERT_EQ(local_time->tm_sec, 0);
time_t neg_timep3 = -78115158887;
local_time = taosLocalTime(&neg_timep3, &result, NULL);
local_time = taosLocalTime(&neg_timep3, &result, NULL, 0);
ASSERT_EQ(local_time, nullptr);
#endif
}

View File

@ -149,18 +149,18 @@ static int32_t taosStartLog() {
return 0;
}
static void getDay(char* buf){
static void getDay(char* buf, int32_t bufSize){
time_t t = taosTime(NULL);
struct tm tmInfo;
if (taosLocalTime(&t, &tmInfo, buf) != NULL) {
TAOS_UNUSED(strftime(buf, LOG_FILE_DAY_LEN, "%Y-%m-%d", &tmInfo));
if (taosLocalTime(&t, &tmInfo, buf, bufSize) != NULL) {
TAOS_UNUSED(strftime(buf, bufSize, "%Y-%m-%d", &tmInfo));
}
}
static int64_t getTimestampToday() {
time_t t = taosTime(NULL);
struct tm tm;
if (taosLocalTime(&t, &tm, NULL) == NULL) {
if (taosLocalTime(&t, &tm, NULL, 0) == NULL) {
return 0;
}
tm.tm_hour = 0;
@ -196,10 +196,10 @@ int32_t taosInitSlowLog() {
getFullPathName(tsLogObj.slowLogName, logFileName);
char name[PATH_MAX + LOG_FILE_DAY_LEN] = {0};
char day[LOG_FILE_DAY_LEN] = {0};
getDay(day);
(void)snprintf(name, PATH_MAX + LOG_FILE_DAY_LEN, "%s.%s", tsLogObj.slowLogName, day);
char name[PATH_MAX + TD_TIME_STR_LEN] = {0};
char day[TD_TIME_STR_LEN] = {0};
getDay(day, sizeof(day));
(void)snprintf(name, PATH_MAX + TD_TIME_STR_LEN, "%s.%s", tsLogObj.slowLogName, day);
tsLogObj.timestampToday = getTimestampToday();
tsLogObj.slowHandle = taosLogBuffNew(LOG_SLOW_BUF_SIZE);
@ -428,11 +428,11 @@ static void taosOpenNewSlowLogFile() {
taosWriteLog(tsLogObj.slowHandle);
atomic_store_32(&tsLogObj.slowHandle->lock, 0);
char day[LOG_FILE_DAY_LEN] = {0};
getDay(day);
char day[TD_TIME_STR_LEN] = {0};
getDay(day, sizeof(day));
TdFilePtr pFile = NULL;
char name[PATH_MAX + LOG_FILE_DAY_LEN] = {0};
(void)snprintf(name, PATH_MAX + LOG_FILE_DAY_LEN, "%s.%s", tsLogObj.slowLogName, day);
char name[PATH_MAX + TD_TIME_STR_LEN] = {0};
(void)snprintf(name, PATH_MAX + TD_TIME_STR_LEN, "%s.%s", tsLogObj.slowLogName, day);
pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
if (pFile == NULL) {
uError("open new log file fail! reason:%s, reuse lastlog", strerror(errno));
@ -629,7 +629,7 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) {
TAOS_UNUSED(taosGetTimeOfDay(&timeSecs));
time_t curTime = timeSecs.tv_sec;
ptm = taosLocalTime(&curTime, &Tm, NULL);
ptm = taosLocalTime(&curTime, &Tm, NULL, 0);
return sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d %08" PRId64 " %s %s", ptm->tm_mon + 1, ptm->tm_mday,
ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (int32_t)timeSecs.tv_usec, taosGetSelfPthreadId(),

View File

@ -44,7 +44,7 @@ static int32_t shellRunSingleCommand(char *command);
static void shellRecordCommandToHistory(char *command);
static int32_t shellRunCommand(char *command, bool recordHistory);
static void shellRunSingleCommandImp(char *command);
static char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision);
static char *shellFormatTimestamp(char *buf, int32_t bufSize, int64_t val, int32_t precision);
static int64_t shellDumpResultToFile(const char *fname, TAOS_RES *tres);
static void shellPrintNChar(const char *str, int32_t length, int32_t width);
static void shellPrintGeometry(const unsigned char *str, int32_t length, int32_t width);
@ -304,7 +304,7 @@ void shellRunSingleCommandImp(char *command) {
printf("\r\n");
}
char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
char *shellFormatTimestamp(char *buf, int32_t bufSize, int64_t val, int32_t precision) {
if (shell.args.is_raw_time) {
sprintf(buf, "%" PRId64, val);
return buf;
@ -335,7 +335,7 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
}
struct tm ptm = {0};
if (taosLocalTime(&tt, &ptm, buf) == NULL) {
if (taosLocalTime(&tt, &ptm, buf, bufSize) == NULL) {
return buf;
}
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
@ -465,7 +465,7 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
break;
}
case TSDB_DATA_TYPE_TIMESTAMP:
shellFormatTimestamp(buf, *(int64_t *)val, precision);
shellFormatTimestamp(buf, sizeof(buf), *(int64_t *)val, precision);
taosFprintfFile(pFile, "%s%s%s", quotationStr, buf, quotationStr);
break;
default:
@ -710,7 +710,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
shellPrintGeometry(val, length, width);
break;
case TSDB_DATA_TYPE_TIMESTAMP:
shellFormatTimestamp(buf, *(int64_t *)val, precision);
shellFormatTimestamp(buf, sizeof(buf), *(int64_t *)val, precision);
printf("%s", buf);
break;
default:

View File

@ -597,7 +597,7 @@ void printParaIntoFile() {
time_t tTime = taosGetTimestampSec();
struct tm tm;
taosLocalTime(&tTime, &tm, NULL);
taosLocalTime(&tTime, &tm, NULL, 0);
taosFprintfFile(pFile, "###################################################################\n");
taosFprintfFile(pFile, "# configDir: %s\n", configDir);

View File

@ -166,7 +166,7 @@ static void printHelp() {
char* getCurrentTimeString(char* timeString) {
time_t tTime = taosGetTimestampSec();
struct tm tm;
taosLocalTime(&tTime, &tm, NULL);
taosLocalTime(&tTime, &tm, NULL, 0);
sprintf(timeString, "%d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
tm.tm_min, tm.tm_sec);
@ -441,7 +441,7 @@ int32_t saveConsumeContentToTbl(SThreadInfo* pInfo, char* buf) {
return 0;
}
static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) {
static char* shellFormatTimestamp(char* buf, int32_t bufSize, int64_t val, int32_t precision) {
// if (shell.args.is_raw_time) {
// sprintf(buf, "%" PRId64, val);
// return buf;
@ -472,7 +472,7 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) {
}
struct tm ptm;
if (taosLocalTime(&tt, &ptm, buf) == NULL) {
if (taosLocalTime(&tt, &ptm, buf, bufSize) == NULL) {
return buf;
}
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
@ -559,7 +559,7 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* f
taosFprintfFile(pFile, "%s%s%s", quotationStr, buf, quotationStr);
} break;
case TSDB_DATA_TYPE_TIMESTAMP:
shellFormatTimestamp(buf, *(int64_t*)val, precision);
shellFormatTimestamp(buf, sizeof(buf), *(int64_t*)val, precision);
taosFprintfFile(pFile, "%s%s%s", quotationStr, buf, quotationStr);
break;
default:

View File

@ -797,7 +797,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
tt = (*(int64_t *)row[i]) / 1000000000;
}
if (taosLocalTime(&tt, &tp, timeStr) == NULL) {
if (taosLocalTime(&tt, &tp, timeStr, sizeof(timeStr)) == NULL) {
break;
}
strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", &tp);