From 13ae4380cd994e2b4b7c0e4493ec7ad9f49cf7cb Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 27 Dec 2021 15:37:58 +0800 Subject: [PATCH] [TD-11983](query): elapsed function second param time_unit should not contain now keyword --- src/client/src/tscSQLParser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index f6144be85f..6bb93b35db 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2852,9 +2852,12 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col char val[8] = {0}; int64_t tickPerSec = 0; - if (pParamElem[1].pNode->exprToken.type == TK_NOW || strstr(pParamElem[1].pNode->exprToken.z, "now")) { + char *exprToken = tcalloc(pParamElem[1].pNode->exprToken.n + 1, sizeof(char)); + memcpy(exprToken, pParamElem[1].pNode->exprToken.z, pParamElem[1].pNode->exprToken.n); + if (pParamElem[1].pNode->exprToken.type == TK_NOW || strstr(exprToken, "now")) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } + tfree(exprToken); if ((TSDB_DATA_TYPE_NULL == pParamElem[1].pNode->value.nType) || tVariantDump(&pParamElem[1].pNode->value, (char*) &tickPerSec, TSDB_DATA_TYPE_BIGINT, true) < 0) { return TSDB_CODE_TSC_INVALID_OPERATION; -- GitLab