From d35bdba180cf20b3f79b1dcbcc3a0e5c24c22e4b Mon Sep 17 00:00:00 2001 From: wangjiaming0909 <604227650@qq.com> Date: Tue, 23 Jul 2024 19:04:01 +0800 Subject: [PATCH] fix parser/planner/nodes ret check ci --- source/libs/function/src/builtins.c | 4 ++-- source/libs/function/src/functionMgt.c | 2 +- source/libs/parser/src/parInsertSql.c | 8 ++++---- source/libs/parser/test/mockCatalogService.cpp | 2 +- source/libs/parser/test/parInitialCTest.cpp | 2 +- source/libs/parser/test/parTestUtil.cpp | 1 + source/libs/planner/test/planTestUtil.cpp | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 72e6ab7b42..8c809a5052 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -239,7 +239,7 @@ static int32_t addTimezoneParam(SNodeList* pList) { varDataSetLen(pVal->datum.p, len); (void)strncpy(varDataVal(pVal->datum.p), pVal->literal, len); - int32_t code = nodesListAppend(pList, (SNode*)pVal); + code = nodesListAppend(pList, (SNode*)pVal); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)pVal); return code; @@ -263,7 +263,7 @@ static int32_t addDbPrecisonParam(SNodeList** pList, uint8_t precision) { pVal->datum.i = (int64_t)precision; pVal->typeData = (int64_t)precision; - int32_t code = nodesListMakeAppend(pList, (SNode*)pVal); + code = nodesListMakeAppend(pList, (SNode*)pVal); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)pVal); return code; diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 1a3a137aea..92754de4ce 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -400,7 +400,7 @@ int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNo } static int32_t createColumnByFunc(const SFunctionNode* pFunc, SColumnNode** ppCol) { - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&ppCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)ppCol); if (NULL == *ppCol) { return code; } diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 020eb028de..70bd43559c 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -1243,10 +1243,7 @@ static int32_t collectUseTable(const SName* pName, SHashObj* pTable) { static int32_t collectUseDatabase(const SName* pName, SHashObj* pDbs) { char dbFName[TSDB_DB_FNAME_LEN] = {0}; - int32_t code = tNameGetFullDbName(pName, dbFName); - if (TSDB_CODE_SUCCESS != code) { - return code; - } + (void)tNameGetFullDbName(pName, dbFName); return taosHashPut(pDbs, dbFName, strlen(dbFName), dbFName, sizeof(dbFName)); } @@ -2217,6 +2214,9 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt // init only for file if (NULL == pStmt->pTableCxtHashObj) { pStmt->pTableCxtHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (!pStmt->pTableCxtHashObj) { + return TSDB_CODE_OUT_OF_MEMORY; + } } int32_t numOfRows = 0; int32_t code = parseCsvFile(pCxt, pStmt, rowsDataCxt, &numOfRows); diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 528ae2d2dd..3a364bf8c0 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -48,7 +48,7 @@ class TableBuilder : public ITableBuilder { SVgroupInfo vgroup = {vgid, 0, 0, {0}, 0}; assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030)); assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030)); - assert(TSDB_CODE_FAILED == addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030)); + assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030)); vgroup.epSet.inUse = 0; (void)meta_->vgs.emplace_back(vgroup); diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 4d314a6edf..3422ebe028 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -685,7 +685,7 @@ TEST_F(ParserInitialCTest, createSmaIndex) { pCmdMsg->msgLen = tSerializeSMCreateSmaReq(NULL, 0, pStmt->pReq); pCmdMsg->pMsg = taosMemoryMalloc(pCmdMsg->msgLen); if (!pCmdMsg->pMsg) FAIL(); - ASSERT_EQ(TSDB_CODE_SUCCESS, tSerializeSMCreateSmaReq(pCmdMsg->pMsg, pCmdMsg->msgLen, pStmt->pReq)); + ASSERT_TRUE(0 < tSerializeSMCreateSmaReq(pCmdMsg->pMsg, pCmdMsg->msgLen, pStmt->pReq)); ((SQuery*)pQuery)->pCmdMsg = pCmdMsg; ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); diff --git a/source/libs/parser/test/parTestUtil.cpp b/source/libs/parser/test/parTestUtil.cpp index 854036bcd0..5ca2cea409 100644 --- a/source/libs/parser/test/parTestUtil.cpp +++ b/source/libs/parser/test/parTestUtil.cpp @@ -66,6 +66,7 @@ int32_t getLogLevel() { return g_logLevel; } class ParserTestBaseImpl { public: ParserTestBaseImpl(ParserTestBase* pBase) : pBase_(pBase), sqlNo_(0), sqlNum_(0) { + assert(TSDB_CODE_SUCCESS == qInitKeywordsTable()); caseEnv_.numOfSkipSql_ = g_skipSql; caseEnv_.numOfLimitSql_ = g_limitSql; } diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index 901ab7e131..da38a72953 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -93,7 +93,7 @@ int32_t getLogLevel() { return g_logLevel; } class PlannerTestBaseImpl { public: - PlannerTestBaseImpl() : sqlNo_(0), sqlNum_(0) {} + PlannerTestBaseImpl() : sqlNo_(0), sqlNum_(0) { assert(qInitKeywordsTable() == 0); } void useDb(const string& user, const string& db) { caseEnv_.acctId_ = 0; @@ -448,7 +448,7 @@ class PlannerTestBaseImpl { pCmdMsg->msgLen = tSerializeSMCreateSmaReq(NULL, 0, pStmt->pReq); pCmdMsg->pMsg = taosMemoryMalloc(pCmdMsg->msgLen); if (!pCmdMsg->pMsg) FAIL(); - ASSERT_EQ(TSDB_CODE_SUCCESS, tSerializeSMCreateSmaReq(pCmdMsg->pMsg, pCmdMsg->msgLen, pStmt->pReq)); + ASSERT_TRUE(0 < tSerializeSMCreateSmaReq(pCmdMsg->pMsg, pCmdMsg->msgLen, pStmt->pReq)); ((SQuery*)pQuery)->pCmdMsg = pCmdMsg; ASSERT_EQ(TSDB_CODE_SUCCESS, tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));