From 92e91c2032009d7cb965fa2af15d41209f9caac6 Mon Sep 17 00:00:00 2001 From: wangjiaming0909 <604227650@qq.com> Date: Tue, 16 Apr 2024 10:44:38 +0800 Subject: [PATCH] fix ci --- source/dnode/mnode/impl/src/mndSma.c | 2 +- source/libs/parser/src/parTranslater.c | 22 +++++++++++++++------- tests/system-test/2-query/tsma.py | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 62e4f1c5a6..dd569b4c59 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -1486,7 +1486,7 @@ static void mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) { f.bytes = pExprNode->resType.bytes; f.type = pExprNode->resType.type; f.flags = COL_SMA_ON; - strcpy(f.name, pExprNode->aliasName); + strcpy(f.name, pExprNode->userAlias); taosArrayPush(pCxt->pCreateStreamReq->pCols, &f); } } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index c788066aaf..43b67d44e1 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -7640,7 +7640,7 @@ static int32_t addWdurationToSampleProjects(SNodeList* pProjectionList) { return nodesListAppend(pProjectionList, (SNode*)pFunc); } -static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList) { +static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList, int32_t *pProjectionTotalLen) { SNodeList* pProjectionList = pInfo->pFuncs; pInfo->pFuncs = NULL; @@ -7654,7 +7654,11 @@ static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pLis if (TSDB_CODE_SUCCESS == code) { SNode* pProject = NULL; - FOREACH(pProject, pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); } + if (pProjectionTotalLen) *pProjectionTotalLen = 0; + FOREACH(pProject, pProjectionList) { + sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); + if (pProjectionTotalLen) *pProjectionTotalLen += ((SExprNode*)pProject)->resType.bytes; + } *pList = pProjectionList; } else { nodesDestroyList(pProjectionList); @@ -7682,7 +7686,7 @@ static int32_t buildIntervalForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) } static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, char** pAst, int32_t* pLen, char** pExpr, - int32_t* pExprLen) { + int32_t* pExprLen, int32_t* pProjectionTotalLen) { SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); if (NULL == pSelect) { return TSDB_CODE_OUT_OF_MEMORY; @@ -7691,7 +7695,7 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch int32_t code = buildTableForSampleAst(pInfo, &pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { - code = buildProjectsForSampleAst(pInfo, &pSelect->pProjectionList); + code = buildProjectsForSampleAst(pInfo, &pSelect->pProjectionList, pProjectionTotalLen); } if (TSDB_CODE_SUCCESS == code) { TSWAP(pInfo->pSubTable, pSelect->pSubtable); @@ -7843,7 +7847,7 @@ static int32_t getRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt, SR SSampleAstInfo info = {0}; int32_t code = buildSampleAstInfoByTable(pCxt, pStmt, pRetension, precision, &info); if (TSDB_CODE_SUCCESS == code) { - code = buildSampleAst(pCxt, &info, pAst, pLen, NULL, NULL); + code = buildSampleAst(pCxt, &info, pAst, pLen, NULL, NULL, NULL); } clearSampleAstInfo(&info); return code; @@ -8377,7 +8381,7 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SSampleAstInfo info = {0}; int32_t code = buildSampleAstInfoByIndex(pCxt, pStmt, &info); if (TSDB_CODE_SUCCESS == code) { - code = buildSampleAst(pCxt, &info, pAst, pLen, pExpr, pExprLen); + code = buildSampleAst(pCxt, &info, pAst, pLen, pExpr, pExprLen, NULL); } clearSampleAstInfo(&info); return code; @@ -10676,7 +10680,11 @@ static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMC code = fmCreateStateFuncs(info.pFuncs); if (code == TSDB_CODE_SUCCESS) { - code = buildSampleAst(pCxt, &info, &pReq->ast, &pReq->astLen, &pReq->expr, &pReq->exprLen); + int32_t pProjectionTotalLen = 0; + code = buildSampleAst(pCxt, &info, &pReq->ast, &pReq->astLen, &pReq->expr, &pReq->exprLen, &pProjectionTotalLen); + if (code == TSDB_CODE_SUCCESS && pProjectionTotalLen > TSDB_MAX_BYTES_PER_ROW) { + code = TSDB_CODE_PAR_INVALID_ROW_LENGTH; + } } clearSampleAstInfo(&info); return code; diff --git a/tests/system-test/2-query/tsma.py b/tests/system-test/2-query/tsma.py index e46fb4c489..6f9652a420 100644 --- a/tests/system-test/2-query/tsma.py +++ b/tests/system-test/2-query/tsma.py @@ -1260,7 +1260,7 @@ class TDTestCase: 'avg(c1)', 'avg(c2)'], '5m') self.create_recursive_tsma('tsma1', 'tsma2', 'nsdb', '10m', 'meters') tdSql.query('select avg(c1) from nsdb.meters', queryTimes=1) - tdSql.execute('drop database nsdb', queryTimes=1) + tdSql.execute('drop database nsdb') def test_tb_ddl_with_created_tsma(self): function_name = sys._getframe().f_code.co_name @@ -1472,7 +1472,7 @@ class TDTestCase: def generate_tsma_function_list_columns(self,max_column: int =4093): columns = [] - self.tsma_support_func = ["avg", "max", "min", "count", "sum", "first", "last", "spread", "stddev", "hyperloglog"] + self.tsma_support_func = ["max", "min", "count", "sum"] num_items = len(self.tsma_support_func) for i in range(max_column): random_index = secrets.randbelow(num_items)