From d9bbe0d888205e2635ee2f73227690f6b6ebe687 Mon Sep 17 00:00:00 2001 From: facetosea <285808407@qq.com> Date: Thu, 20 Feb 2025 19:15:22 +0800 Subject: [PATCH] return code --- source/libs/executor/src/executil.c | 4 +--- source/libs/nodes/src/nodesUtilFuncs.c | 2 +- source/libs/parser/src/parTranslater.c | 13 ++++++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 7a1cf4beb6..cf2dd0a283 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1955,6 +1955,7 @@ int32_t createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) { QUERY_CHECK_CODE(code, lino, _end); } } + pExp->pExpr->_function.bindExprID = ((SExprNode*)pNode)->bindExprID; } else if (type == QUERY_NODE_OPERATOR) { pExp->pExpr->nodeType = QUERY_NODE_OPERATOR; SOperatorNode* pOpNode = (SOperatorNode*)pNode; @@ -1992,9 +1993,6 @@ int32_t createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) { code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; QUERY_CHECK_CODE(code, lino, _end); } - if (type == QUERY_NODE_FUNCTION) { - pExp->pExpr->_function.bindExprID = ((SExprNode*)pNode)->bindExprID; - } pExp->pExpr->relatedTo = ((SExprNode*)pNode)->relatedTo; _end: if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 48e9f12c27..d581283a04 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -3241,7 +3241,7 @@ int32_t nodesListDeduplicate(SNodeList** ppList) { } void rewriteExprAliasName(SExprNode* pNode, int64_t num) { - tsnprintf(pNode->aliasName, TSDB_COL_NAME_LEN, "expr_%x", num); + (void)tsnprintf(pNode->aliasName, TSDB_COL_NAME_LEN, "expr_%x", num); return; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 51c13a5eee..26857403e2 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -7428,8 +7428,11 @@ static EDealRes pushDownBindSelectFunc(SNode** pNode, void* pContext) { if (nodesIsExprNode(*pNode)) { SExprNode* pExpr = (SExprNode*)*pNode; pExpr->relatedTo = pCxt->bindExprID; + if (nodeType(*pNode) != QUERY_NODE_COLUMN) { + return DEAL_RES_CONTINUE; + } - if (isRelatedToOtherExpr(pExpr) && *pNode != pCxt->root) { + if (*pNode != pCxt->root) { int len = strlen(pExpr->aliasName); if (len + TSDB_COL_NAME_EXLEN >= TSDB_COL_NAME_LEN) { char buffer[TSDB_COL_NAME_EXLEN + TSDB_COL_NAME_LEN + 1] = {0}; @@ -7609,6 +7612,7 @@ static int32_t rewriteColsFunction(STranslateContext* pCxt, SNodeList** nodeList } SNodeList* pNewNodeList = NULL; + SNode* pNewNode = NULL; if (needRewrite) { if (pCxt->createStream) { return TSDB_CODE_PAR_INVALID_COLS_FUNCTION; @@ -7625,7 +7629,6 @@ static int32_t rewriteColsFunction(STranslateContext* pCxt, SNodeList** nodeList } } - SNode* pNewNode = NULL; int32_t nums = 0; int32_t selectFuncCount = (*selectFuncList)->length; SNode* pTmpNode = NULL; @@ -7649,14 +7652,17 @@ static int32_t rewriteColsFunction(STranslateContext* pCxt, SNodeList** nodeList ++selectFuncCount; selectFuncIndex = selectFuncCount; code = nodesCloneNode(pSelectFunc, &pNewNode); + if(TSDB_CODE_SUCCESS != code) goto _end; ((SExprNode*)pNewNode)->bindExprID = selectFuncIndex; - nodesListMakeStrictAppend(selectFuncList, pNewNode); + code = nodesListMakeStrictAppend(selectFuncList, pNewNode); + if(TSDB_CODE_SUCCESS != code) goto _end; } // start from index 1, because the first parameter is select function which needn't to output. for (int i = 1; i < pFunc->pParameterList->length; ++i) { SNode* pExpr = nodesListGetNode(pFunc->pParameterList, i); code = nodesCloneNode(pExpr, &pNewNode); + if(TSDB_CODE_SUCCESS != code) goto _end; if (nodesIsExprNode(pNewNode)) { SBindTupleFuncCxt pCxt = {pNewNode, selectFuncIndex}; nodesRewriteExpr(&pNewNode, pushDownBindSelectFunc, &pCxt); @@ -7683,6 +7689,7 @@ static int32_t rewriteColsFunction(STranslateContext* pCxt, SNodeList** nodeList } _end: if (TSDB_CODE_SUCCESS != code) { + nodesDestroyNode(pNewNode); nodesDestroyList(pNewNodeList); } return code;