From d6f05d48c89d2aa145b58fc8cc77860ce58d97b5 Mon Sep 17 00:00:00 2001 From: facetosea <285808407@qq.com> Date: Thu, 20 Feb 2025 17:17:41 +0800 Subject: [PATCH] return code --- include/libs/nodes/querynodes.h | 2 +- source/libs/nodes/src/nodesUtilFuncs.c | 5 +++-- source/libs/parser/src/parTranslater.c | 18 +++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 5fae336d22..dab666a27b 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -700,7 +700,7 @@ char* getJoinSTypeString(EJoinSubType type); char* getFullJoinTypeString(EJoinType type, EJoinSubType stype); int32_t mergeJoinConds(SNode** ppDst, SNode** ppSrc); -int32_t rewriteExprAliasName(SExprNode* pNode, int64_t num); +void rewriteExprAliasName(SExprNode* pNode, int64_t num); bool isRelatedToOtherExpr(SExprNode* pExpr); #ifdef __cplusplus diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index b96a1d3a12..48e9f12c27 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -3240,8 +3240,9 @@ int32_t nodesListDeduplicate(SNodeList** ppList) { return code; } -int32_t rewriteExprAliasName(SExprNode* pNode, int64_t num) { - return tsnprintf(pNode->aliasName, TSDB_COL_NAME_LEN, "expr_%ld", num); +void rewriteExprAliasName(SExprNode* pNode, int64_t num) { + tsnprintf(pNode->aliasName, TSDB_COL_NAME_LEN, "expr_%x", num); + return; } bool isRelatedToOtherExpr(SExprNode* pExpr) { diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 342d5bdfa1..51c13a5eee 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -7433,11 +7433,11 @@ static EDealRes pushDownBindSelectFunc(SNode** pNode, void* pContext) { 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}; - tsnprintf(buffer, sizeof(buffer), "%s.%d", pExpr->aliasName, pExpr->relatedTo); + (void)tsnprintf(buffer, sizeof(buffer), "%s.%d", pExpr->aliasName, pExpr->relatedTo); uint64_t hashVal = MurmurHash3_64(buffer, TSDB_COL_NAME_EXLEN + TSDB_COL_NAME_LEN + 1); - tsnprintf(pExpr->aliasName, TSDB_COL_NAME_EXLEN, "%" PRIu64, hashVal); + (void)tsnprintf(pExpr->aliasName, TSDB_COL_NAME_EXLEN, "%" PRIu64, hashVal); } else { - tsnprintf(pExpr->aliasName + len, TSDB_COL_NAME_EXLEN, ".%d", pExpr->relatedTo); + (void)tsnprintf(pExpr->aliasName + len, TSDB_COL_NAME_EXLEN, ".%d", pExpr->relatedTo); } } } @@ -7533,9 +7533,9 @@ static EDealRes rewriteSingleColsFunc(SNode** pNode, void* pContext) { } } if(*pCxt->selectFuncList == NULL) { - nodesMakeList(pCxt->selectFuncList); + code = nodesMakeList(pCxt->selectFuncList); if (NULL == *pCxt->selectFuncList) { - pCxt->status = terrno; + pCxt->status = code; return DEAL_RES_ERROR; } } @@ -7546,12 +7546,15 @@ static EDealRes rewriteSingleColsFunc(SNode** pNode, void* pContext) { selectFuncIndex = selectFuncCount; SNode* pNewNode = NULL; code = nodesCloneNode(pSelectFunc, &pNewNode); + if(code) goto _end; ((SExprNode*)pNewNode)->bindExprID = selectFuncIndex; - nodesListMakeStrictAppend(pCxt->selectFuncList, pNewNode); + code = nodesListMakeStrictAppend(pCxt->selectFuncList, pNewNode); + if(code) goto _end; } SNode* pNewNode = NULL; code = nodesCloneNode(pExpr, &pNewNode); + if(code) goto _end; if (nodesIsExprNode(pNewNode)) { SBindTupleFuncCxt pCxt = {pNewNode, selectFuncIndex}; nodesRewriteExpr(&pNewNode, pushDownBindSelectFunc, &pCxt); @@ -7565,7 +7568,8 @@ static EDealRes rewriteSingleColsFunc(SNode** pNode, void* pContext) { } return DEAL_RES_CONTINUE; _end: - return code; + pCxt->status = code; + return DEAL_RES_ERROR; } static int32_t rewriteHavingColsNode(STranslateContext* pCxt, SNode** pNode, SNodeList** selectFuncList) {