From c2e8aa9659e5e113251c637da44fd97baba2508a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sun, 12 Jun 2022 00:31:34 +0800 Subject: [PATCH] refactor: do some internal refactor. --- source/common/src/ttime.c | 4 ++-- source/libs/function/src/builtinsimpl.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index afae6b860c..0b59e9b6cc 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -338,7 +338,7 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePr struct tm tm = {0}; char* str = taosStrpTime(timestr, "%Y-%m-%d %H:%M:%S", &tm); - if (str == NULL || ((str - timestr) < len) || !validateTm(&tm)) { + if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { return -1; } @@ -373,7 +373,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim tm.tm_isdst = -1; char* str = taosStrpTime(timestr, "%Y-%m-%d %H:%M:%S", &tm); - if (str == NULL || ((str - timestr) < len) || !validateTm(&tm)) { + if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { return -1; } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index c7e2e3b9b5..b2b3714bec 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -4201,13 +4201,13 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { doReservoirSample(pInfo, data, tsList[i], i); } - for (int32_t i = alreadySampled; i < pInfo->numSampled; ++i) { + for (int32_t i = 0; i < pInfo->numSampled; ++i) { int32_t pos = startOffset + i; colDataAppend(pOutput, pos, pInfo->data + i * pInfo->colBytes, false); //TODO: handle ts output } - return pInfo->numSampled - alreadySampled; + return pInfo->numSampled; } bool getTailFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {