From b6a8619d40bbeca1dee9fd0de0e3ee5cd43cb851 Mon Sep 17 00:00:00 2001 From: lyh250-666 Date: Wed, 4 Sep 2024 10:00:14 +0800 Subject: [PATCH 1/2] enh:modify error code passing in libs/ --- source/libs/geometry/src/geomFunc.c | 8 ++-- source/libs/geometry/src/geosWrapper.c | 2 +- source/libs/index/src/index.c | 2 +- source/libs/index/src/indexCache.c | 8 ++-- source/libs/index/src/indexComm.c | 24 ++++++------ source/libs/index/src/indexFilter.c | 8 ++-- source/libs/index/src/indexTfile.c | 8 ++-- source/libs/index/src/indexUtil.c | 2 +- source/libs/nodes/src/nodesCloneFuncs.c | 4 +- source/libs/nodes/src/nodesCodeFuncs.c | 8 ++-- source/libs/nodes/src/nodesMsgFuncs.c | 2 +- source/libs/nodes/src/nodesUtilFuncs.c | 6 +-- source/libs/parser/src/parInsertSml.c | 14 +++---- source/libs/parser/src/parInsertSql.c | 10 ++--- source/libs/parser/src/parInsertStmt.c | 12 +++--- source/libs/parser/src/parInsertUtil.c | 14 +++---- source/libs/parser/src/parTranslater.c | 52 ++++++++++++------------- source/libs/parser/src/parUtil.c | 4 +- source/libs/parser/src/parser.c | 6 +-- 19 files changed, 97 insertions(+), 97 deletions(-) diff --git a/source/libs/geometry/src/geomFunc.c b/source/libs/geometry/src/geomFunc.c index 1752493dff..2ce2d92fa7 100644 --- a/source/libs/geometry/src/geomFunc.c +++ b/source/libs/geometry/src/geomFunc.c @@ -43,7 +43,7 @@ int32_t doMakePointFunc(double x, double y, unsigned char **output) { *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } @@ -74,7 +74,7 @@ int32_t doGeomFromTextFunc(const char *input, unsigned char **output) { // make a zero ending string inputGeom = taosMemoryCalloc(1, varDataLen(input) + 1); if (inputGeom == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } (void)memcpy(inputGeom, varDataVal(input), varDataLen(input)); @@ -83,7 +83,7 @@ int32_t doGeomFromTextFunc(const char *input, unsigned char **output) { *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } @@ -114,7 +114,7 @@ int32_t doAsTextFunc(unsigned char *input, char **output) { size_t size = strlen(outputWKT); *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } diff --git a/source/libs/geometry/src/geosWrapper.c b/source/libs/geometry/src/geosWrapper.c index 5eeea54715..13c5f7208e 100644 --- a/source/libs/geometry/src/geosWrapper.c +++ b/source/libs/geometry/src/geosWrapper.c @@ -96,7 +96,7 @@ static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData int32_t code = 0; char *wktPatternWithSpace = taosMemoryCalloc(4, 1024); if (NULL == wktPatternWithSpace) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)sprintf( diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 0d834a68cb..b2fd0afd68 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -112,7 +112,7 @@ int32_t indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { int code = TSDB_CODE_SUCCESS; SIndex* idx = taosMemoryCalloc(1, sizeof(SIndex)); if (idx == NULL) { - TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, END); + TAOS_CHECK_GOTO(terrno, NULL, END); } idx->lru = taosLRUCacheInit(opts->cacheSize, -1, .5); diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index a89cc47925..1b31c1e50b 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -137,7 +137,7 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTRslt* CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm)); if (pCt == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pCt->colVal = term->colVal; @@ -206,7 +206,7 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm)); if (pCt == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pCt->colVal = term->colVal; @@ -584,7 +584,7 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { // encode data CacheTerm* ct = taosMemoryCalloc(1, sizeof(CacheTerm)); if (ct == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } // set up key ct->colType = term->colType; @@ -594,7 +594,7 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { ct->colVal = (char*)taosMemoryCalloc(1, sizeof(char) * (term->nColVal + 1)); if (ct->colVal == NULL) { taosMemoryFree(ct); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(ct->colVal, term->colVal, term->nColVal); } diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 8dc63ed105..2c681a1df3 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -323,7 +323,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_TIMESTAMP: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int64_t*)src, *dst, -1); tlen = strlen(*dst); @@ -332,7 +332,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UTINYINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint8_t*)src, *dst, 1); tlen = strlen(*dst); @@ -340,7 +340,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_TINYINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int8_t*)src, *dst, 1); tlen = strlen(*dst); @@ -348,7 +348,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_SMALLINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int16_t*)src, *dst, -1); tlen = strlen(*dst); @@ -361,7 +361,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_INT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int32_t*)src, *dst, -1); tlen = strlen(*dst); @@ -369,7 +369,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint32_t*)src, *dst, 1); tlen = strlen(*dst); @@ -377,7 +377,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_BIGINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%" PRIu64, *(uint64_t*)src); tlen = strlen(*dst); @@ -385,7 +385,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UBIGINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint64_t*)src, *dst, 1); tlen = strlen(*dst); @@ -393,7 +393,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_FLOAT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%.9lf", *(float*)src); tlen = strlen(*dst); @@ -401,7 +401,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_DOUBLE: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%.9lf", *(double*)src); tlen = strlen(*dst); @@ -410,7 +410,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); *dst = (char*)*dst - tlen; @@ -422,7 +422,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); *dst = (char*)*dst - tlen; diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 03474c0143..fa59fe23fe 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -197,7 +197,7 @@ static FORCE_INLINE int32_t sifGetValueFromNode(SNode *node, char **value) { } char *tv = taosMemoryCalloc(1, valLen + 1); if (tv == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(tv, pData, valLen); @@ -273,7 +273,7 @@ static int32_t sifInitParamValByCol(SNode *r, SNode *l, SIFParam *param, SIFCtx } char *tv = taosMemoryCalloc(1, valLen + 1); if (tv == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(tv, pData, valLen); @@ -373,7 +373,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam)); if (NULL == paramList) { - SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SIF_ERR_RET(terrno); } if (nodeType(node->pLeft) == QUERY_NODE_OPERATOR && @@ -405,7 +405,7 @@ static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx * SIFParam *tParams = taosMemoryCalloc(nodeList->length, sizeof(SIFParam)); if (tParams == NULL) { indexError("failed to calloc, nodeList: %p", nodeList); - SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SIF_ERR_RET(terrno); } SListCell *cell = nodeList->pHead; diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index 55a9bb06d9..405e899100 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -201,7 +201,7 @@ int32_t tfileReaderCreate(IFileCtx* ctx, TFileReader** pReader) { int32_t code = 0; TFileReader* reader = taosMemoryCalloc(1, sizeof(TFileReader)); if (reader == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } reader->ctx = ctx; reader->remove = false; @@ -609,7 +609,7 @@ int32_t tfileWriterCreate(IFileCtx* ctx, TFileHeader* header, TFileWriter** pWri int32_t code = 0; TFileWriter* tw = taosMemoryCalloc(1, sizeof(TFileWriter)); if (tw == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; indexError("index: %" PRIu64 " failed to alloc TFilerWriter since %s", header->suid, tstrerror(code)); return code; } @@ -661,7 +661,7 @@ int32_t tfileWriterPut(TFileWriter* tw, void* data, bool order) { int32_t cap = 4 * 1024; char* buf = taosMemoryCalloc(1, cap); if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (size_t i = 0; i < sz; i++) { @@ -1137,7 +1137,7 @@ static int32_t tfileGetFileList(const char* path, SArray** ppResult) { size_t len = strlen(path) + 1 + strlen(file) + 1; char* buf = taosMemoryCalloc(1, len); if (buf == NULL) { - TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _exception); + TAOS_CHECK_GOTO(terrno, NULL, _exception); } sprintf(buf, "%s/%s", path, file); diff --git a/source/libs/index/src/indexUtil.c b/source/libs/index/src/indexUtil.c index 6a52b7b5a4..aca1ec37fe 100644 --- a/source/libs/index/src/indexUtil.c +++ b/source/libs/index/src/indexUtil.c @@ -44,7 +44,7 @@ int32_t iIntersection(SArray *in, SArray *out) { } MergeIndex *mi = taosMemoryCalloc(sz, sizeof(MergeIndex)); if (mi == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (int i = 0; i < sz; i++) { SArray *t = taosArrayGetP(in, i); diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index e2c5b42e39..b76e4448d3 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -179,7 +179,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = pSrc->node.resType.bytes + 1; pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(pDst->datum.p, pSrc->datum.p, len); break; @@ -188,7 +188,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = getJsonValueLen(pSrc->datum.p); pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(pDst->datum.p, pSrc->datum.p, len); break; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 1425df5c5a..74879a53af 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -4083,14 +4083,14 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { case TSDB_DATA_TYPE_GEOMETRY: { pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } varDataSetLen(pNode->datum.p, pNode->node.resType.bytes - VARSTR_HEADER_SIZE); if (TSDB_DATA_TYPE_NCHAR == pNode->node.resType.type) { char* buf = taosMemoryCalloc(1, pNode->node.resType.bytes * 2 + VARSTR_HEADER_SIZE + 1); if (NULL == buf) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tjsonGetStringValue(pJson, jkValueDatum, buf); @@ -4112,12 +4112,12 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { case TSDB_DATA_TYPE_JSON: { pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } char* buf = taosMemoryCalloc(1, pNode->node.resType.bytes * 2 + 1); if (NULL == buf) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tjsonGetStringValue(pJson, jkValueDatum, buf); diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index b3568e914e..e71cfc47f8 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -952,7 +952,7 @@ static int32_t msgToDatum(STlv* pTlv, void* pObj) { } pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tlvDecodeBinary(pTlv, pNode->datum.p); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 1d6c19346a..d58ee8dbdd 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -120,7 +120,7 @@ static int32_t callocNodeChunk(SNodeAllocator* pAllocator, SNodeMemChunk** pOutC SNodeMemChunk* pNewChunk = taosMemoryCalloc(1, sizeof(SNodeMemChunk) + pAllocator->chunkSize); if (NULL == pNewChunk) { if (pOutChunk) *pOutChunk = NULL; - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pNewChunk->pBuf = (char*)(pNewChunk + 1); pNewChunk->availableSize = pAllocator->chunkSize; @@ -141,7 +141,7 @@ static int32_t callocNodeChunk(SNodeAllocator* pAllocator, SNodeMemChunk** pOutC static int32_t nodesCallocImpl(int32_t size, void** pOut) { if (NULL == g_pNodeAllocator) { *pOut = taosMemoryCalloc(1, size); - if (!*pOut) return TSDB_CODE_OUT_OF_MEMORY; + if (!*pOut) return terrno; return TSDB_CODE_SUCCESS; } @@ -180,7 +180,7 @@ void nodesFree(void* p) { static int32_t createNodeAllocator(int32_t chunkSize, SNodeAllocator** pAllocator) { *pAllocator = taosMemoryCalloc(1, sizeof(SNodeAllocator)); if (NULL == *pAllocator) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pAllocator)->chunkSize = chunkSize; int32_t code = callocNodeChunk(*pAllocator, NULL); diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index acd1851d76..23025dcab9 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -48,7 +48,7 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSchema* pSchema, bool isTag) { bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool)); if (NULL == pUseCols) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pBoundInfo->numOfBound = 0; @@ -139,7 +139,7 @@ static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchem int32_t output = 0; void* p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)(p), kv->length * TSDB_NCHAR_SIZE, &output)) { @@ -240,7 +240,7 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32 taosMemoryFree(tmp); } else { uError("SML smlBuildCol out of memory"); - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; } goto end; } @@ -253,7 +253,7 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32 } char* pUcs4 = taosMemoryCalloc(1, size); if (NULL == pUcs4) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, size, &len)) { @@ -315,7 +315,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pCreateTblReq) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } insBuildCreateTbReq(pCreateTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName, pTableMeta->tableInfo.numOfTags, @@ -323,7 +323,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc pCreateTblReq->ctb.stbName = taosMemoryCalloc(1, sTableNameLen + 1); if (pCreateTblReq->ctb.stbName == NULL){ - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } (void)memcpy(pCreateTblReq->ctb.stbName, sTableName, sTableNameLen); @@ -400,7 +400,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc int32_t len = 0; char* pUcs4 = taosMemoryCalloc(1, pColSchema->bytes - VARSTR_HEADER_SIZE); if (NULL == pUcs4) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, pColSchema->bytes - VARSTR_HEADER_SIZE, &len)) { diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index a8db514ee3..b87a1aabd0 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -182,7 +182,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, E bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool)); if (NULL == pUseCols) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pBoundInfo->numOfBound = 0; @@ -768,7 +768,7 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p } pStmt->pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pStmt->pCreateTblReq) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } insBuildCreateTbReq(pStmt->pCreateTblReq, pStmt->targetTableName.tname, pTag, pStmt->pTableMeta->suid, pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags, @@ -850,7 +850,7 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) { case TSDB_DATA_TYPE_NCHAR: pValue->datum.p = taosMemoryCalloc(1, pVal->nData + VARSTR_HEADER_SIZE); if (NULL == pValue->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pValue->datum.p, pVal->nData); memcpy(varDataVal(pValue->datum.p), pVal->pData, pVal->nData); @@ -1916,7 +1916,7 @@ static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnod pStbRowsCxt->pCreateCtbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (pStbRowsCxt->pCreateCtbReq == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } if (code == TSDB_CODE_SUCCESS) { insBuildCreateTbReq(pStbRowsCxt->pCreateCtbReq, pStbRowsCxt->ctbName.tname, pStbRowsCxt->pTag, @@ -2319,7 +2319,7 @@ static void destroyStbRowsDataContext(SStbRowsDataContext* pStbRowsCxt) { static int32_t constructStbRowsDataContext(SVnodeModifyOpStmt* pStmt, SStbRowsDataContext** ppStbRowsCxt) { SStbRowsDataContext* pStbRowsCxt = taosMemoryCalloc(1, sizeof(SStbRowsDataContext)); if (!pStbRowsCxt) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tNameAssign(&pStbRowsCxt->stbName, &pStmt->targetTableName); int32_t code = collectUseTable(&pStbRowsCxt->stbName, pStmt->pTableNameHashObj); diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index 025459a8c9..c1a228d572 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -32,7 +32,7 @@ typedef struct SKvParam { int32_t qCloneCurrentTbData(STableDataCxt* pDataBlock, SSubmitTbData** pData) { *pData = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == *pData) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SSubmitTbData* pNew = *pData; @@ -190,7 +190,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch int32_t output = 0; void* p = taosMemoryCalloc(1, colLen * TSDB_NCHAR_SIZE); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } if (!taosMbsToUcs4(bind[c].buffer, colLen, (TdUcs4*)(p), colLen * TSDB_NCHAR_SIZE, &output)) { @@ -224,7 +224,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch if (NULL == pDataBlock->pData->pCreateTbReq) { pDataBlock->pData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pDataBlock->pData->pCreateTbReq) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } } @@ -465,7 +465,7 @@ int32_t buildBoundFields(int32_t numOfBound, int16_t* boundColumns, SSchema* pSc if (fields) { *fields = taosMemoryCalloc(numOfBound, sizeof(TAOS_FIELD_E)); if (NULL == *fields) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SSchema* schema = &pSchema[boundColumns[0]]; @@ -572,7 +572,7 @@ int32_t qCloneStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, bool rese *pDst = taosMemoryCalloc(1, sizeof(STableDataCxt)); if (NULL == *pDst) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } STableDataCxt* pNewCxt = (STableDataCxt*)*pDst; @@ -650,7 +650,7 @@ int32_t qRebuildStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, uint64_ if (rebuildCreateTb && NULL == pBlock->pData->pCreateTbReq) { pBlock->pData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pBlock->pData->pCreateTbReq) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } } diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index b0581d2fd3..e77678fb69 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -188,7 +188,7 @@ int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo* pInfo) { pInfo->hasBoundCols = false; pInfo->pColIndex = taosMemoryCalloc(numOfBound, sizeof(int16_t)); if (NULL == pInfo->pColIndex) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (int32_t i = 0; i < numOfBound; ++i) { pInfo->pColIndex[i] = i; @@ -230,7 +230,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat STableDataCxt* pTableCxt = taosMemoryCalloc(1, sizeof(STableDataCxt)); if (NULL == pTableCxt) { *pOutput = NULL; - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = TSDB_CODE_SUCCESS; @@ -264,7 +264,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat if (TSDB_CODE_SUCCESS == code) { pTableCxt->pData = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == pTableCxt->pData) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } else { pTableCxt->pData->flags = (pCreateTbReq != NULL && NULL != *pCreateTbReq) ? SUBMIT_REQ_AUTO_CREATE_TABLE : 0; pTableCxt->pData->flags |= colMode ? SUBMIT_REQ_COLUMN_DATA_FORMAT : 0; @@ -300,7 +300,7 @@ static int32_t rebuildTableData(SSubmitTbData* pSrc, SSubmitTbData** pDst) { int32_t code = TSDB_CODE_SUCCESS; SSubmitTbData* pTmp = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == pTmp) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } else { pTmp->flags = pSrc->flags; pTmp->suid = pSrc->suid; @@ -477,12 +477,12 @@ static int32_t createVgroupDataCxt(STableDataCxt* pTableCxt, SHashObj* pVgroupHa SVgroupDataCxt** pOutput) { SVgroupDataCxt* pVgCxt = taosMemoryCalloc(1, sizeof(SVgroupDataCxt)); if (NULL == pVgCxt) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgCxt->pData = taosMemoryCalloc(1, sizeof(SSubmitReq2)); if (NULL == pVgCxt->pData) { insDestroyVgroupDataCxt(pVgCxt); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgCxt->vgId = pTableCxt->pMeta->vgId; @@ -840,7 +840,7 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList, } SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == dst) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } if (TSDB_CODE_SUCCESS == code) { dst->numOfTables = taosArrayGetSize(src->pData->aSubmitTbData); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 6c86a6c12f..d79a880e72 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2928,7 +2928,7 @@ static int32_t rewriteQueryTimeFunc(STranslateContext* pCxt, int64_t val, SNode* char* pStr = taosMemoryCalloc(1, 20); if (NULL == pStr) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } snprintf(pStr, 20, "%" PRId64 "", val); int32_t code = rewriteFuncToValue(pCxt, &pStr, pNode); @@ -3768,7 +3768,7 @@ static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) { size_t vgroupNum = taosArrayGetSize(pVgs); *pVgsInfo = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupNum); if (NULL == *pVgsInfo) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pVgsInfo)->numOfVgroups = vgroupNum; for (int32_t i = 0; i < vgroupNum; ++i) { @@ -3797,7 +3797,7 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) { size_t ndnode = taosArrayGetSize(pDnodes); *pVgsInfo = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * ndnode); if (NULL == *pVgsInfo) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pVgsInfo)->numOfVgroups = ndnode; for (int32_t i = 0; i < ndnode; ++i) { @@ -3925,7 +3925,7 @@ static int32_t setSuperTableVgroupList(STranslateContext* pCxt, SName* pName, SR static int32_t setNormalTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { pRealTable->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); if (NULL == pRealTable->pVgroupList) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pRealTable->pVgroupList->numOfVgroups = 1; return getTableHashVgroupImpl(pCxt, pName, pRealTable->pVgroupList->vgroups); @@ -4033,7 +4033,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo } SVgroupsInfo* pVgpsInfo = taosMemoryCalloc(1, sizeof(int32_t) + sizeof(SVgroupInfo)); if (!pVgpsInfo) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } pVgpsInfo->numOfVgroups = 1; @@ -6346,7 +6346,7 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* const char* pTbName = taosArrayGetP(pInfo->aTbnames, k); char* pNewTbName = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1); if (!pNewTbName) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } if (NULL == taosArrayPush(pTbNames, &pNewTbName)) { @@ -8670,7 +8670,7 @@ static int32_t createRollupTableMeta(SCreateTableStmt* pStmt, int8_t precision, int32_t numOfField = LIST_LENGTH(pStmt->pCols) + LIST_LENGTH(pStmt->pTags); STableMeta* pMeta = taosMemoryCalloc(1, sizeof(STableMeta) + numOfField * sizeof(SSchema)); if (NULL == pMeta) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pMeta->tableType = TSDB_SUPER_TABLE; pMeta->tableInfo.numOfTags = LIST_LENGTH(pStmt->pTags); @@ -9466,7 +9466,7 @@ static int32_t checkCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pS static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { int32_t code = checkCreateSmaIndex(pCxt, pStmt); pStmt->pReq = taosMemoryCalloc(1, sizeof(SMCreateSmaReq)); - if (pStmt->pReq == NULL) code = TSDB_CODE_OUT_OF_MEMORY; + if (pStmt->pReq == NULL) code = terrno; if (TSDB_CODE_SUCCESS == code) { code = buildCreateSmaReq(pCxt, pStmt, pStmt->pReq); } @@ -11376,7 +11376,7 @@ static int32_t readFromFile(char* pName, int32_t* len, char** buf) { *buf = taosMemoryCalloc(1, *len); if (*buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } TdFilePtr tfile = taosOpenFile(pName, O_RDONLY | O_BINARY); @@ -11636,7 +11636,7 @@ static int32_t translateShowVariables(STranslateContext* pCxt, SShowStmt* pStmt) static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateDatabaseStmt* pStmt) { pStmt->pCfg = taosMemoryCalloc(1, sizeof(SDbCfgInfo)); if (NULL == pStmt->pCfg) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SName name; @@ -11650,7 +11650,7 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTableStmt* pStmt) { pStmt->pDbCfg = taosMemoryCalloc(1, sizeof(SDbCfgInfo)); if (NULL == pStmt->pDbCfg) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = getDBCfg(pCxt, pStmt->dbName, (SDbCfgInfo*)pStmt->pDbCfg); if (TSDB_CODE_SUCCESS == code) { @@ -12074,7 +12074,7 @@ static int32_t translateCreateTSMA(STranslateContext* pCxt, SCreateTSMAStmt* pSt SName useTbName = {0}; if (code == TSDB_CODE_SUCCESS) { pStmt->pReq = taosMemoryCalloc(1, sizeof(SMCreateSmaReq)); - if (!pStmt->pReq) return TSDB_CODE_OUT_OF_MEMORY; + if (!pStmt->pReq) return terrno; } if (code == TSDB_CODE_SUCCESS) { code = buildCreateTSMAReq(pCxt, pStmt, pStmt->pReq, &useTbName); @@ -12382,7 +12382,7 @@ static int32_t extractQueryResultSchema(const SNodeList* pProjections, int32_t* *numOfCols = LIST_LENGTH(pProjections); *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SNode* pNode; @@ -12414,7 +12414,7 @@ static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) *numOfCols = 1; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[0].bytes = TSDB_EXPLAIN_RESULT_ROW_SIZE; @@ -12427,7 +12427,7 @@ static int32_t extractDescribeResultSchema(STableMeta* pMeta, int32_t* numOfCols if (pMeta && useCompress(pMeta->tableType)) *numOfCols = DESCRIBE_RESULT_COLS_COMPRESS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12467,7 +12467,7 @@ static int32_t extractShowCreateDatabaseResultSchema(int32_t* numOfCols, SSchema *numOfCols = 2; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12485,7 +12485,7 @@ static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema** *numOfCols = 2; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12503,7 +12503,7 @@ static int32_t extractShowCreateViewResultSchema(int32_t* numOfCols, SSchema** p *numOfCols = SHOW_CREATE_VIEW_RESULT_COLS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12521,7 +12521,7 @@ static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pS *numOfCols = 3; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12543,7 +12543,7 @@ static int32_t extractCompactDbResultSchema(int32_t* numOfCols, SSchema** pSchem *numOfCols = COMPACT_DB_RESULT_COLS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -13269,7 +13269,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* req.ntb.schemaRow.pSchema = taosMemoryCalloc(req.ntb.schemaRow.nCols, sizeof(SSchema)); if (NULL == req.name || NULL == req.ntb.schemaRow.pSchema) { tdDestroySVCreateTbReq(&req); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } if (pStmt->ignoreExists) { req.flags |= TD_CREATE_IF_NOT_EXISTS; @@ -13346,7 +13346,7 @@ static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFreeClear(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = pTbBatch->info; pVgData->pData = buf; @@ -14069,7 +14069,7 @@ static int32_t prepareReadCsvFile(STranslateContext* pCxt, SCreateSubTableFromFi { pCreateInfo = taosMemoryCalloc(1, sizeof(SCreateTbInfo)); if (NULL == pCreateInfo) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _ERR; } @@ -14379,7 +14379,7 @@ static int32_t serializeVgroupDropTableBatch(SVgroupDropTableBatch* pTbBatch, SA SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFreeClear(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = pTbBatch->info; pVgData->pData = buf; @@ -14829,7 +14829,7 @@ static int32_t serializeAlterTbReq(STranslateContext* pCxt, SAlterTableStmt* pSt SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFree(pMsg); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = vg; pVgData->pData = pMsg; @@ -14934,7 +14934,7 @@ static int32_t serializeFlushVgroup(SVgroupInfo* pVg, SArray* pBufArray) { SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFree(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = *pVg; pVgData->pData = buf; diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 250e9385b4..5c4ced7004 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -463,7 +463,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi int32_t valLen = (int32_t)strlen(jsonValue); char* tmp = taosMemoryCalloc(1, valLen * TSDB_NCHAR_SIZE); if (!tmp) { - retCode = TSDB_CODE_OUT_OF_MEMORY; + retCode = terrno; goto end; } val.type = TSDB_DATA_TYPE_NCHAR; @@ -1039,7 +1039,7 @@ int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, S int32_t buildTableMetaFromViewMeta(STableMeta** pMeta, SViewMeta* pViewMeta) { *pMeta = taosMemoryCalloc(1, sizeof(STableMeta) + pViewMeta->numOfCols * sizeof(SSchema)); if (NULL == *pMeta) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pMeta)->uid = pViewMeta->viewId; (*pMeta)->vgId = MNODE_HANDLE; diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index e96aaf52ed..17f62ac157 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -172,7 +172,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { case TSDB_DATA_TYPE_VARBINARY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); memcpy(varDataVal(pVal->datum.p), pParam->buffer, pVal->node.resType.bytes); @@ -182,7 +182,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { case TSDB_DATA_TYPE_GEOMETRY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); strncpy(varDataVal(pVal->datum.p), (const char*)pParam->buffer, pVal->node.resType.bytes); @@ -192,7 +192,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { pVal->node.resType.bytes *= TSDB_NCHAR_SIZE; pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t output = 0; From 6cbb0cf17228b14a37163f30dbc0436f902f2399 Mon Sep 17 00:00:00 2001 From: lyh250-666 Date: Wed, 11 Sep 2024 09:58:41 +0800 Subject: [PATCH 2/2] enh:modify error code passing libs/ --- source/libs/planner/src/planLogicCreater.c | 2 +- source/libs/planner/src/planOptimizer.c | 12 ++-- source/libs/planner/src/planScaleOut.c | 2 +- source/libs/qcom/src/queryUtil.c | 2 +- source/libs/qworker/src/qworker.c | 4 +- source/libs/scalar/src/filter.c | 42 +++++++------- source/libs/scalar/src/scalar.c | 11 ++-- source/libs/scalar/src/sclfunc.c | 36 ++++++------ source/libs/scalar/src/sclvector.c | 16 +++--- source/libs/scheduler/src/schJob.c | 2 +- source/libs/scheduler/src/schRemote.c | 30 +++++----- source/libs/scheduler/src/schTask.c | 2 +- source/libs/stream/src/streamBackendRocksdb.c | 56 +++++++++---------- source/libs/stream/src/streamCheckpoint.c | 6 +- source/libs/stream/src/streamDispatch.c | 2 +- source/libs/stream/src/streamHb.c | 2 +- source/libs/stream/src/streamMeta.c | 6 +- source/libs/stream/src/streamQueue.c | 4 +- source/libs/stream/src/streamSnapshot.c | 6 +- source/libs/stream/src/streamStartHistory.c | 2 +- source/libs/stream/src/streamState.c | 2 +- source/libs/stream/src/streamTask.c | 6 +- source/libs/stream/src/streamTaskSm.c | 2 +- source/libs/stream/src/streamUpdate.c | 6 +- source/libs/stream/src/tstreamFileState.c | 2 +- 25 files changed, 130 insertions(+), 133 deletions(-) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 3d13ad4c62..6886260d0a 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -202,7 +202,7 @@ static int32_t rewriteExprsForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ES if (NULL != pRewriteExprs) { cxt.pOutputs = taosMemoryCalloc(LIST_LENGTH(pExprs), sizeof(bool)); if (NULL == cxt.pOutputs) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } } nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 988440227b..1296986e7f 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2883,7 +2883,7 @@ static int32_t smaIndexOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pSmaScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); if (!pSmaScan->pVgroupList) { nodesDestroyNode((SNode*)pSmaScan); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } code = nodesCloneList(pCols, &pSmaScan->node.pTargets); if (NULL == pSmaScan->node.pTargets) { @@ -4297,7 +4297,7 @@ static void lastRowScanOptRemoveUslessTargets(SNodeList* pTargets, SNodeList* pL static int32_t lastRowScanBuildFuncTypes(SScanLogicNode* pScan, SColumnNode* pColNode, int32_t funcType) { SFunctParam* pFuncTypeParam = taosMemoryCalloc(1, sizeof(SFunctParam)); if (NULL == pFuncTypeParam) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pFuncTypeParam->type = funcType; if (NULL == pScan->pFuncTypes) { @@ -4311,7 +4311,7 @@ static int32_t lastRowScanBuildFuncTypes(SScanLogicNode* pScan, SColumnNode* pCo pFuncTypeParam->pCol = taosMemoryCalloc(1, sizeof(SColumn)); if (NULL == pFuncTypeParam->pCol) { taosMemoryFree(pFuncTypeParam); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pFuncTypeParam->pCol->colId = pColNode->colId; strcpy(pFuncTypeParam->pCol->name, pColNode->colName); @@ -6671,7 +6671,7 @@ static int32_t fillTSMAOptCtx(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pScan) { if (nodeType(pTsmaOptCtx->pParent) == QUERY_NODE_LOGIC_PLAN_WINDOW) { pTsmaOptCtx->queryInterval = taosMemoryCalloc(1, sizeof(SInterval)); - if (!pTsmaOptCtx->queryInterval) return TSDB_CODE_OUT_OF_MEMORY; + if (!pTsmaOptCtx->queryInterval) return terrno; SWindowLogicNode* pWindow = (SWindowLogicNode*)pTsmaOptCtx->pParent; pTsmaOptCtx->queryInterval->interval = pWindow->interval; @@ -7076,7 +7076,7 @@ static int32_t tsmaOptRewriteTbname(const STSMAOptCtx* pTsmaOptCtx, SNode** pTbN pValue->node.resType = ((SExprNode*)(*pTbNameNode))->resType; pValue->literal = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + 1); pValue->datum.p = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + 1 + VARSTR_HEADER_SIZE); - if (!pValue->literal || !pValue->datum.p) code = TSDB_CODE_OUT_OF_MEMORY; + if (!pValue->literal || !pValue->datum.p) code = terrno; } if (code == TSDB_CODE_SUCCESS) { @@ -7204,7 +7204,7 @@ static int32_t tsmaOptRewriteScan(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pNew int32_t len = sizeof(int32_t) + sizeof(SVgroupInfo) * pVgpsInfo->numOfVgroups; pNewScan->pVgroupList = taosMemoryCalloc(1, len); if (!pNewScan->pVgroupList) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } memcpy(pNewScan->pVgroupList, pVgpsInfo, len); diff --git a/source/libs/planner/src/planScaleOut.c b/source/libs/planner/src/planScaleOut.c index bcac7ddd7e..4027056c69 100644 --- a/source/libs/planner/src/planScaleOut.c +++ b/source/libs/planner/src/planScaleOut.c @@ -47,7 +47,7 @@ static int32_t doSetScanVgroup(SLogicNode* pNode, const SVgroupInfo* pVgroup, bo SScanLogicNode* pScan = (SScanLogicNode*)pNode; pScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); if (NULL == pScan->pVgroupList) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(pScan->pVgroupList->vgroups, pVgroup, sizeof(SVgroupInfo)); *pFound = true; diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 7c7439eac3..30902269c3 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -623,7 +623,7 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) { *pDst = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == *pDst) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pDst)->flags = pSrc->flags; diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 1a9d3e7ba9..9c6ca18d97 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -436,7 +436,7 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes output.pData = taosMemoryCalloc(1, len); if (NULL == output.pData) { - QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + QW_ERR_RET(terrno); } code = dsGetDataBlock(ctx->sinkHandle, &output); @@ -1324,7 +1324,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S if (NULL == mgmt) { qError("calloc %d failed", (int32_t)sizeof(SQWorker)); (void)atomic_sub_fetch_32(&gQwMgmt.qwNum, 1); - QW_RET(TSDB_CODE_OUT_OF_MEMORY); + QW_RET(terrno); } mgmt->cfg.maxSchedulerNum = QW_DEFAULT_SCHEDULER_NUMBER; diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index ec48dd50ae..c62833a3f5 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -468,20 +468,20 @@ int32_t filterInitUnitsFields(SFilterInfo *info) { info->unitSize = FILTER_DEFAULT_UNIT_SIZE; info->units = taosMemoryCalloc(info->unitSize, sizeof(SFilterUnit)); if (info->units == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } info->fields[FLD_TYPE_COLUMN].num = 0; info->fields[FLD_TYPE_COLUMN].size = FILTER_DEFAULT_FIELD_SIZE; info->fields[FLD_TYPE_COLUMN].fields = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].size, sizeof(SFilterField)); if (info->fields[FLD_TYPE_COLUMN].fields == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } info->fields[FLD_TYPE_VALUE].num = 0; info->fields[FLD_TYPE_VALUE].size = FILTER_DEFAULT_FIELD_SIZE; info->fields[FLD_TYPE_VALUE].fields = taosMemoryCalloc(info->fields[FLD_TYPE_VALUE].size, sizeof(SFilterField)); if (info->fields[FLD_TYPE_VALUE].fields == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } return TSDB_CODE_SUCCESS; @@ -497,7 +497,7 @@ static FORCE_INLINE int32_t filterNewRange(SFilterRangeCtx *ctx, SFilterRange *r } else { *r = taosMemoryCalloc(1, sizeof(SFilterRangeNode)); if (*r == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } } @@ -516,7 +516,7 @@ int32_t filterInitRangeCtx(int32_t type, int32_t options, SFilterRangeCtx **ctx) *ctx = taosMemoryCalloc(1, sizeof(SFilterRangeCtx)); if (*ctx == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*ctx)->type = type; (*ctx)->options = options; @@ -961,7 +961,7 @@ int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray *group gp.unitNum = gp1->unitNum + gp2->unitNum; gp.unitIdxs = taosMemoryCalloc(gp.unitNum, sizeof(*gp.unitIdxs)); if (NULL == gp.unitIdxs) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } (void)memcpy(gp.unitIdxs, gp1->unitIdxs, gp1->unitNum * sizeof(*gp.unitIdxs)); (void)memcpy(gp.unitIdxs + gp1->unitNum, gp2->unitIdxs, gp2->unitNum * sizeof(*gp.unitIdxs)); @@ -1300,7 +1300,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) { SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; if (out.columnData == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } out.columnData->info.type = type; out.columnData->info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; // reserved space for simple_copy @@ -1330,7 +1330,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) { } else { void *data = taosMemoryCalloc(1, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); // reserved space for simple_copy if (NULL == data) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } (void)memcpy(data, nodesGetValueFromNode(valueNode), tDataTypes[type].bytes); @@ -2203,13 +2203,13 @@ int32_t fltInitValFieldData(SFilterInfo *info) { size_t bufBytes = TMAX(dType->bytes, sizeof(int64_t)); fi->data = taosMemoryCalloc(1, bufBytes); if (fi->data == NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } assignVal(fi->data, nodesGetValueFromNode(var), dType->bytes, type); } else { SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; if (out.columnData == NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } out.columnData->info.type = type; out.columnData->info.precision = precision; @@ -2230,7 +2230,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { : TMAX(out.columnData->info.bytes, sizeof(int64_t)); fi->data = taosMemoryCalloc(1, bufBytes); if (fi->data== NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } size_t valBytes = IS_VAR_DATA_TYPE(type) ? varDataTLen(out.columnData->pData) : out.columnData->info.bytes; @@ -2446,7 +2446,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gRes[gResIdx] = taosMemoryCalloc(1, sizeof(SFilterGroupCtx)); if (gRes[gResIdx] == NULL) { - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo)); if (gRes[gResIdx]->colInfo == NULL) { @@ -2876,7 +2876,7 @@ int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray *group) { info->groups = taosMemoryCalloc(info->groupNum, sizeof(*info->groups)); if (info->groups == NULL) { info->groupNum = 0; - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } } @@ -2888,7 +2888,7 @@ int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray *group) { pg->unitFlags = taosMemoryCalloc(pg->unitNum, sizeof(*pg->unitFlags)); if (pg->unitFlags == NULL) { pg->unitNum = 0; - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } info->groups[i] = *pg; } @@ -3005,7 +3005,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ int32_t code = TSDB_CODE_SUCCESS; uint32_t *idxNum = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxNum)); if (idxNum == NULL) { - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } for (int32_t i = 0; i < gResNum; ++i) { for (uint32_t m = 0; m < gRes[i]->colNum; ++m) { @@ -3031,7 +3031,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ if (idxs == NULL) { idxs = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxs)); if (idxs == NULL) { - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } } @@ -3044,7 +3044,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ info->colRange = taosMemoryCalloc(colNum, POINTER_BYTES); if (info->colRange == NULL) { info->colRangeNum = 0; - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } for (int32_t i = 0; i < gResNum; ++i) { @@ -3584,7 +3584,7 @@ int32_t filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *p (info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)) { char *newColData = taosMemoryCalloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); if (newColData == NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); if (len < 0) { @@ -3659,7 +3659,7 @@ int32_t filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, (cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NMATCH)) { char *newColData = taosMemoryCalloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); if (newColData == NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); if (len < 0) { @@ -3740,7 +3740,7 @@ int32_t filterPreprocess(SFilterInfo *info) { int32_t gResNum = 0; SFilterGroupCtx **gRes = taosMemoryCalloc(info->groupNum, sizeof(SFilterGroupCtx *)); if (gRes == NULL) { - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } FLT_ERR_JRET(filterMergeGroupUnits(info, gRes, &gResNum)); @@ -5218,7 +5218,7 @@ int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pInfo, uint32_t options) *pInfo = taosMemoryCalloc(1, sizeof(SFilterInfo)); if (NULL == *pInfo) { fltError("taosMemoryCalloc %d failed", (int32_t)sizeof(SFilterInfo)); - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index b9a95a3216..3b2450906a 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -41,7 +41,6 @@ int32_t sclConvertToTsValueNode(int8_t precision, SValueNode *valueNode) { int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarParam *pParam) { SColumnInfoData *pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData)); if (pColumnData == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } @@ -99,7 +98,7 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL int32_t code = TSDB_CODE_SUCCESS; if (NULL == pLeft) { sclError("calloc %d failed", (int32_t)sizeof(SScalarParam)); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } pLeft->numOfRows = pb->info.rows; @@ -131,7 +130,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { SListCell *cell = nodeList->pNodeList->pHead; SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; if (out.columnData == NULL) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } int32_t len = 0; void *buf = NULL; @@ -485,7 +484,7 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList *pParamList, SScalarC SScalarParam *paramList = taosMemoryCalloc(*paramNum, sizeof(SScalarParam)); if (NULL == paramList) { sclError("calloc %d failed", (int32_t)((*paramNum) * sizeof(SScalarParam))); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } if (pParamList) { @@ -581,7 +580,7 @@ int32_t sclInitOperatorParams(SScalarParam **pParams, SOperatorNode *node, SScal SScalarParam *paramList = taosMemoryCalloc(paramNum, sizeof(SScalarParam)); if (NULL == paramList) { sclError("calloc %d failed", (int32_t)(paramNum * sizeof(SScalarParam))); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } SCL_ERR_JRET(sclSetOperatorValueType(node, ctx)); @@ -608,7 +607,7 @@ int32_t sclGetNodeRes(SNode *node, SScalarCtx *ctx, SScalarParam **res) { int32_t rowNum = 0; *res = taosMemoryCalloc(1, sizeof(**res)); if (NULL == *res) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } SCL_ERR_RET(sclInitParam(node, *res, ctx, &rowNum)); diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 5fc7c06d57..4e8107a5b2 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -618,7 +618,7 @@ static int32_t trimHelper(char *orgStr, char* remStr, int32_t orgLen, int32_t re static int32_t convVarcharToNchar(char *input, char **output, int32_t inputLen, int32_t *outputLen) { *output = taosMemoryCalloc(inputLen * TSDB_NCHAR_SIZE, 1); if (NULL == *output) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } bool ret = taosMbsToUcs4(input, inputLen, (TdUcs4 *)*output, inputLen * TSDB_NCHAR_SIZE, outputLen); if (!ret) { @@ -631,7 +631,7 @@ static int32_t convVarcharToNchar(char *input, char **output, int32_t inputLen, static int32_t convNcharToVarchar(char *input, char **output, int32_t inputLen, int32_t *outputLen) { *output = taosMemoryCalloc(inputLen, 1); if (NULL == *output) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } *outputLen = taosUcs4ToMbs((TdUcs4 *)input, inputLen, *output); if (*outputLen < 0) { @@ -814,7 +814,7 @@ static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar, if (hasNchar && type == TSDB_DATA_TYPE_VARCHAR) { TdUcs4 *newBuf = taosMemoryCalloc((varDataLen(input) + 1) * TSDB_NCHAR_SIZE, 1); if (NULL == newBuf) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t len = varDataLen(input); bool ret = taosMbsToUcs4(varDataVal(input), len, newBuf, (varDataLen(input) + 1) * TSDB_NCHAR_SIZE, &len); @@ -853,10 +853,10 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu char *outputBuf = NULL; if (NULL == pInputData) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } if (NULL == input) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } int32_t inputLen = 0; @@ -882,7 +882,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu outputBuf = taosMemoryCalloc(outputLen, 1); if (NULL == outputBuf) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } for (int32_t k = 0; k < numOfRows; ++k) { @@ -928,7 +928,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p char *outputBuf = NULL; if (NULL == pInputData) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } int32_t inputLen = 0; @@ -960,7 +960,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p outputBuf = taosMemoryCalloc(outputLen, 1); if (NULL == outputBuf) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } for (int32_t k = 0; k < numOfRows; ++k) { @@ -1016,7 +1016,7 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala int32_t outputLen = pInputData->varmeta.length; char *outputBuf = taosMemoryCalloc(outputLen, 1); if (outputBuf == NULL) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } char *output = outputBuf; @@ -1070,7 +1070,7 @@ static int32_t doTrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarPar } char *outputBuf = taosMemoryCalloc(outputLen, 1); if (outputBuf == NULL) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } char *output = outputBuf; @@ -1528,7 +1528,7 @@ int32_t replaceFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pO char *outputBuf = taosMemoryCalloc(outputLen + VARSTR_HEADER_SIZE, 1); if (NULL == outputBuf) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } for (int32_t i = 0; i < numOfRows; ++i) { @@ -1643,7 +1643,7 @@ int32_t substrIdxFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * } char *outputBuf = taosMemoryCalloc(outputLen + VARSTR_HEADER_SIZE, 1); if (NULL == outputBuf) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } for (int32_t k = 0; k < numOfRows; ++k) { @@ -1741,7 +1741,7 @@ int32_t repeatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows); char *outputBuf = taosMemoryCalloc(outputLen, 1); if (outputBuf == NULL) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } char *output = outputBuf; @@ -1834,7 +1834,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp char *buf = taosMemoryMalloc(bufSize); if (convBuf == NULL || output == NULL || buf == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _end; } @@ -2403,7 +2403,7 @@ int32_t toCharFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOu int32_t code = 0; if (format == NULL || out == NULL) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) { @@ -4230,7 +4230,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char * intervals = taosMemoryCalloc(numOfBins, sizeof(double)); if (NULL == intervals) { cJSON_Delete(binDesc); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } if (cJSON_IsNumber(width) && factor == NULL && binType == LINEAR_BIN) { // linear bin process @@ -4295,7 +4295,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char * intervals = taosMemoryCalloc(numOfBins, sizeof(double)); if (NULL == intervals) { cJSON_Delete(binDesc); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } cJSON *bin = binDesc->child; if (bin == NULL) { @@ -4327,7 +4327,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char * *binNum = numOfBins - 1; *bins = taosMemoryCalloc(numOfBins, sizeof(SHistoFuncBin)); if (NULL == bins) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } for (int32_t i = 0; i < *binNum; ++i) { (*bins)[i].lower = intervals[i] < intervals[i + 1] ? intervals[i] : intervals[i + 1]; diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index ead6053505..d8cc620b1e 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -124,7 +124,7 @@ int32_t convertBinaryToDouble(const void *inData, void *outData) { char *tmp = taosMemoryCalloc(1, varDataTLen(inData)); if (tmp == NULL) { *((double *)outData) = 0.; - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } (void)memcpy(tmp, varDataVal(inData), varDataLen(inData)); double ret = taosStr2Double(tmp, NULL); @@ -370,7 +370,7 @@ static FORCE_INLINE int32_t varToVarbinary(char *buf, SScalarParam *pOut, int32_ if (t == NULL) { sclError("Out of memory"); taosMemoryFree(data); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } varDataSetLen(t, size); (void)memcpy(varDataVal(t), data, size); @@ -383,7 +383,7 @@ static FORCE_INLINE int32_t varToVarbinary(char *buf, SScalarParam *pOut, int32_ char *t = taosMemoryCalloc(1, inputLen); if (t == NULL) { sclError("Out of memory"); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } (void)memcpy(t, buf, inputLen); int32_t code = colDataSetVal(pOut->columnData, rowIndex, t, false); @@ -401,7 +401,7 @@ static FORCE_INLINE int32_t varToNchar(char *buf, SScalarParam *pOut, int32_t ro char *t = taosMemoryCalloc(1, outputMaxLen); if (NULL == t) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } int32_t ret = taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4 *)varDataVal(t), outputMaxLen - VARSTR_HEADER_SIZE, &len); @@ -424,7 +424,7 @@ static FORCE_INLINE int32_t ncharToVar(char *buf, SScalarParam *pOut, int32_t ro char *t = taosMemoryCalloc(1, inputLen + VARSTR_HEADER_SIZE); if (NULL == t) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(t)); if (len < 0) { @@ -457,7 +457,7 @@ static FORCE_INLINE int32_t varToGeometry(char *buf, SScalarParam *pOut, int32_t output = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE); if (NULL == output) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } (void)memcpy(output + VARSTR_HEADER_SIZE, t, len); varDataSetLen(output, len); @@ -2155,7 +2155,7 @@ int32_t vectorJsonContains(SScalarParam *pLeft, SScalarParam *pRight, SScalarPar char *pRightData = colDataGetVarData(pRight->columnData, 0); char *jsonKey = taosMemoryCalloc(1, varDataLen(pRightData) + 1); if (NULL == jsonKey) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } (void)memcpy(jsonKey, varDataVal(pRightData), varDataLen(pRightData)); for (; i >= 0 && i < pLeft->numOfRows; i += step) { @@ -2189,7 +2189,7 @@ int32_t vectorJsonArrow(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam char *pRightData = colDataGetVarData(pRight->columnData, 0); char *jsonKey = taosMemoryCalloc(1, varDataLen(pRightData) + 1); if (NULL == jsonKey) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } (void)memcpy(jsonKey, varDataVal(pRightData), varDataLen(pRightData)); for (; i >= 0 && i < pLeft->numOfRows; i += step) { diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 8e2fbb878d..2dbbdeca44 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -810,7 +810,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); if (NULL == pJob) { qError("qid:0x%" PRIx64 " calloc %d failed", pReq->pDag->queryId, (int32_t)sizeof(SSchJob)); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } pJob->attr.explainMode = pReq->pDag->explainInfo.mode; diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index bf88248259..40391cea7e 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -583,7 +583,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchTaskCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchTaskCallbackParam)); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } param->queryId = pJob->queryId; @@ -600,7 +600,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchHbCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam)); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } param->head.isHbParam = true; @@ -625,7 +625,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchTaskCallbackParam)); if (NULL == param) { qError("calloc SSchTaskCallbackParam failed"); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } param->pTrans = trans->pTrans; @@ -640,7 +640,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3 SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == msgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } msgSendInfo->paramFreeFp = taosMemoryFree; @@ -797,13 +797,13 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam)); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } int32_t msgType = TDMT_SCH_QUERY_HEARTBEAT_RSP; @@ -927,7 +927,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) { SMsgSendInfo *pDst = taosMemoryCalloc(1, sizeof(*pSrc)); if (NULL == pDst) { qError("malloc SMsgSendInfo for rpcCtx failed, len:%d", (int32_t)sizeof(*pSrc)); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } TAOS_MEMCPY(pDst, pSrc, sizeof(*pSrc)); @@ -1059,7 +1059,7 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray *taskAction) { void *msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { qError("calloc hb req %d failed", msgSize); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) { @@ -1116,7 +1116,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } TAOS_MEMCPY(msg, pTask->msg, msgSize); @@ -1142,7 +1142,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } msgSize = tSerializeSVDeleteReq(msg, msgSize, &req); @@ -1190,7 +1190,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSSubQueryMsg(msg, msgSize, &qMsg) < 0) { @@ -1228,7 +1228,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSResFetchReq(msg, msgSize, &req) < 0) { @@ -1256,7 +1256,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSTaskDropReq(msg, msgSize, &qMsg) < 0) { @@ -1283,7 +1283,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_JOB_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) { SCH_JOB_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); @@ -1314,7 +1314,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSTaskNotifyReq(msg, msgSize, &qMsg) < 0) { diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index 59b8954a48..9ba2c7ea5c 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -1237,7 +1237,7 @@ _return: int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) { SSchTaskCtx *param = taosMemoryCalloc(1, sizeof(SSchTaskCtx)); if (NULL == param) { - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } param->jobRid = pJob->refId; diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index ced62ba82e..845dabcf11 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -213,7 +213,7 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) { char* state = taosMemoryCalloc(1, cap); if (state == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(state, cap, "%s%s%s", path, TD_DIRSEP, "state"); @@ -226,7 +226,7 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) { char* chkp = taosMemoryCalloc(1, cap); if (chkp == NULL) { taosMemoryFree(state); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(chkp, cap, "%s%s%s%scheckpoint%" PRId64 "", path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId); @@ -279,7 +279,7 @@ int32_t remoteChkp_readMetaData(char* path, SSChkpMetaOnS3** pMeta) { char* metaPath = taosMemoryCalloc(1, cap); if (metaPath == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t n = snprintf(metaPath, cap, "%s%s%s", path, TD_DIRSEP, "META"); @@ -302,7 +302,7 @@ int32_t remoteChkp_readMetaData(char* path, SSChkpMetaOnS3** pMeta) { SSChkpMetaOnS3* p = taosMemoryCalloc(1, sizeof(SSChkpMetaOnS3)); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } n = sscanf(buf, META_ON_S3_FORMATE, p->pCurrName, &p->currChkptId, p->pManifestName, &p->manifestChkptId, @@ -334,7 +334,7 @@ int32_t remoteChkp_validAndCvtMeta(char* path, SSChkpMetaOnS3* pMeta, int64_t ch char* src = taosMemoryCalloc(1, cap); char* dst = taosMemoryCalloc(1, cap); if (src == NULL || dst == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -400,7 +400,7 @@ int32_t remoteChkpGetDelFile(char* path, SArray* toDel) { char* p = taosMemoryCalloc(1, cap); if (p == NULL) { taosMemoryFree(pMeta); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(p, cap, "%s_%" PRId64 "", key, pMeta->currChkptId); @@ -494,7 +494,7 @@ int32_t rebuildFromRemoteChkp_s3(const char* key, char* chkpPath, int64_t chkpId char* defaultTmp = taosMemoryCalloc(1, cap); if (defaultTmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t nBytes = snprintf(defaultPath, cap, "%s%s", defaultPath, "_tmp"); @@ -592,8 +592,7 @@ int32_t backendFileCopyFilesImpl(const char* src, const char* dst) { if (srcName == NULL || dstName == NULL) { taosMemoryFree(srcName); taosMemoryFree(dstName); - code = TSDB_CODE_OUT_OF_MEMORY; - return code; + return terrno; } // copy file to dst @@ -711,7 +710,7 @@ int32_t restoreCheckpointData(const char* path, const char* key, int64_t chkptId checkpointPath = taosMemoryCalloc(1, cap); checkpointRoot = taosMemoryCalloc(1, cap); if (prefixPath == NULL || defaultPath == NULL || checkpointPath == NULL || checkpointRoot == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -1343,7 +1342,7 @@ int32_t chkpGetAllDbCfHandle2(STaskDbWrapper* pBackend, rocksdb_column_family_ha rocksdb_column_family_handle_t** ppCf = taosMemoryCalloc(nCf, sizeof(rocksdb_column_family_handle_t*)); if (ppCf == NULL) { - TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _exception); + TAOS_CHECK_GOTO(terrno, NULL, _exception); } for (int i = 0; i < nCf; i++) { ppCf[i] = taosArrayGetP(pHandle, i); @@ -1410,7 +1409,7 @@ int32_t chkpPreBuildDir(char* path, int64_t chkpId, char** chkpDir, char** chkpI char* pChkpDir = taosMemoryCalloc(1, cap); char* pChkpIdDir = taosMemoryCalloc(1, cap); if (pChkpDir == NULL || pChkpIdDir == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -1587,7 +1586,7 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId) int32_t cap = len + 64; char* pDst = taosMemoryCalloc(1, cap); if (pDst == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; stError("failed to alloc memory to load extra info, dir:%s", pChkpIdDir); goto _EXIT; } @@ -1643,7 +1642,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) { int32_t cap = len + 64; char* pDst = taosMemoryCalloc(1, cap); if (pDst == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; stError("failed to alloc memory to add extra info, dir:%s", pChkpIdDir); goto _EXIT; } @@ -2119,7 +2118,7 @@ int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) { if (vlen > 512) { dst = taosMemoryCalloc(1, vlen + 128); if (dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t dstCap = vlen + 128; int32_t compressedSize = LZ4_compress_default((char*)value, dst, vlen, dstCap); @@ -2134,7 +2133,7 @@ int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) { size_t size = sizeof(key.unixTimestamp) + sizeof(key.len) + sizeof(key.rawLen) + sizeof(key.compress) + key.len; char* p = taosMemoryCalloc(1, size); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exception; } char* buf = p; @@ -2210,7 +2209,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) { } pOutput = taosMemoryCalloc(1, key.rawLen); if (pOutput == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXCEPT; } @@ -2530,7 +2529,7 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta int32_t code = 0; char* statePath = taosMemoryCalloc(1, strlen(path) + 128); if (statePath == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(statePath, "%s%s%s", path, TD_DIRSEP, key); @@ -2547,7 +2546,7 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta char* dbPath = taosMemoryCalloc(1, strlen(statePath) + 128); if (dbPath == NULL) { taosMemoryFree(statePath); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(dbPath, "%s%s%s", statePath, TD_DIRSEP, "state"); @@ -2765,7 +2764,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char char* buf = taosMemoryCalloc(1, cap); if (buf == NULL) { (void)taosReleaseRef(taskDbWrapperId, refId); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = @@ -2795,7 +2794,7 @@ int32_t taskDbGenChkpUploadData__s3(STaskDbWrapper* pDb, void* bkdChkpMgt, int64 char* temp = taosMemoryCalloc(1, cap); if (temp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t nBytes = snprintf(temp, cap, "%s%s%s%" PRId64, pDb->path, TD_DIRSEP, "tmp", chkpId); @@ -4555,7 +4554,7 @@ int32_t compareHashTableImpl(SHashObj* p1, SHashObj* p2, SArray* diff) { if (!isBkdDataMeta(name, len) && !taosHashGet(p1, name, len)) { char* fname = taosMemoryCalloc(1, len + 1); if (fname == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)strncpy(fname, name, len); if (taosArrayPush(diff, &fname) == NULL) { @@ -4716,7 +4715,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { char* fname = taosMemoryCalloc(1, len + 1); if (fname == NULL) { (void)taosThreadRwlockUnlock(&p->rwLock); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)strncpy(fname, name, len); @@ -4767,7 +4766,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) { int32_t code = 0; SDbChkp* p = taosMemoryCalloc(1, sizeof(SDbChkp)); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -4784,7 +4783,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) { p->len = strlen(path) + 128; p->buf = taosMemoryCalloc(1, p->len); if (p->buf == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -4861,7 +4860,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) { char* buffer = taosMemoryCalloc(4, cap); if (buffer == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _ERROR; } @@ -5026,8 +5025,7 @@ int32_t bkdMgtCreate(char* path, SBkdMgt** mgt) { int32_t code = 0; SBkdMgt* p = taosMemoryCalloc(1, sizeof(SBkdMgt)); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - return code; + return terrno; } p->pDbChkpTbl = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); @@ -5081,7 +5079,7 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* path = taosMemoryCalloc(1, cap); if (path == NULL) { (void)taosThreadRwlockUnlock(&bm->rwLock); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId); diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index 242e12f591..fa2bc65194 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -49,7 +49,7 @@ int32_t createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int6 SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); if (pBlock == NULL) { taosFreeQitem(pChkpoint); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pBlock->info.type = STREAM_CHECKPOINT; @@ -704,7 +704,7 @@ static int32_t getCheckpointDataMeta(const char* id, const char* path, SArray* l char* filePath = taosMemoryCalloc(1, cap); if (filePath == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t nBytes = snprintf(filePath, cap, "%s%s%s", path, TD_DIRSEP, "META_TMP"); @@ -1296,7 +1296,7 @@ int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char char* buf = taosMemoryCalloc(1, cap); if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(buf, cap, "%s/%s", id, fname); diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 4926dcb69d..9bdb2348ae 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -143,7 +143,7 @@ static int32_t buildStreamRetrieveReq(SStreamTask* pTask, const SSDataBlock* pBl int32_t len = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock) + PAYLOAD_PREFIX_LEN; pRetrieve = taosMemoryCalloc(1, len); - if (pRetrieve == NULL) return TSDB_CODE_OUT_OF_MEMORY; + if (pRetrieve == NULL) return terrno; int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); pRetrieve->useconds = 0; diff --git a/source/libs/stream/src/streamHb.c b/source/libs/stream/src/streamHb.c index 1fd3106cff..4e35cb718c 100644 --- a/source/libs/stream/src/streamHb.c +++ b/source/libs/stream/src/streamHb.c @@ -314,7 +314,7 @@ int32_t createMetaHbInfo(int64_t* pRid, SMetaHbInfo** pRes) { *pRes = NULL; SMetaHbInfo* pInfo = taosMemoryCalloc(1, sizeof(SMetaHbInfo)); if (pInfo == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pInfo->hbTmr = taosTmrStart(streamMetaHbToMnode, META_HB_CHECK_INTERVAL, pRid, streamTimer); diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 36d0086ac6..bc902ccf29 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -357,13 +357,13 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn, SStreamMeta* pMeta = taosMemoryCalloc(1, sizeof(SStreamMeta)); if (pMeta == NULL) { stError("vgId:%d failed to prepare stream meta, alloc size:%" PRIzu ", out of memory", vgId, sizeof(SStreamMeta)); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t len = strlen(path) + 64; char* tpath = taosMemoryCalloc(1, len); if (tpath == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _err; } @@ -630,7 +630,7 @@ int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) { buf = taosMemoryCalloc(1, len); if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER) { diff --git a/source/libs/stream/src/streamQueue.c b/source/libs/stream/src/streamQueue.c index 3765d0f9d3..cfa49fd92e 100644 --- a/source/libs/stream/src/streamQueue.c +++ b/source/libs/stream/src/streamQueue.c @@ -51,7 +51,7 @@ int32_t streamQueueOpen(int64_t cap, SStreamQueue** pQ) { SStreamQueue* pQueue = taosMemoryCalloc(1, sizeof(SStreamQueue)); if (pQueue == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } code = taosOpenQueue(&pQueue->pQueue); @@ -372,7 +372,7 @@ int32_t streamTaskPutTranstateIntoInputQ(SStreamTask* pTask) { pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); if (pBlock == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _err; } diff --git a/source/libs/stream/src/streamSnapshot.c b/source/libs/stream/src/streamSnapshot.c index 0390422623..68ca60cbf1 100644 --- a/source/libs/stream/src/streamSnapshot.c +++ b/source/libs/stream/src/streamSnapshot.c @@ -347,7 +347,7 @@ int32_t streamBackendSnapInitFile(char* metaPath, SStreamTaskSnap* pSnap, SBacke char* path = taosMemoryCalloc(1, cap); if (path == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(path, cap, "%s%s%s%s%s%" PRId64 "", pSnap->dbPrefixPath, TD_DIRSEP, "checkpoints", TD_DIRSEP, @@ -492,7 +492,7 @@ int32_t streamSnapReaderOpen(void* pMeta, int64_t sver, int64_t chkpId, char* pa // impl later SStreamSnapReader* pReader = taosMemoryCalloc(1, sizeof(SStreamSnapReader)); if (pReader == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = streamSnapHandleInit(&pReader->handle, (char*)path, pMeta); @@ -632,7 +632,7 @@ int32_t streamSnapWriterOpen(void* pMeta, int64_t sver, int64_t ever, char* path int32_t code = 0; SStreamSnapWriter* pWriter = taosMemoryCalloc(1, sizeof(SStreamSnapWriter)); if (pWriter == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SStreamSnapHandle* pHandle = &pWriter->handle; diff --git a/source/libs/stream/src/streamStartHistory.c b/source/libs/stream/src/streamStartHistory.c index a8c76d3f52..941b8f5145 100644 --- a/source/libs/stream/src/streamStartHistory.c +++ b/source/libs/stream/src/streamStartHistory.c @@ -432,7 +432,7 @@ int32_t createHTaskLaunchInfo(SStreamMeta* pMeta, STaskId* pTaskId, int64_t hStr SLaunchHTaskInfo** pInfo) { *pInfo = taosMemoryCalloc(1, sizeof(SLaunchHTaskInfo)); if ((*pInfo) == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pInfo)->id.streamId = pTaskId->streamId; diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index c6ecaf9c2b..e6754d7bfd 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -483,7 +483,7 @@ int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal } *pVal = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN); if (!(*pVal)) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 355a586e52..5d6cf39e40 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -111,7 +111,7 @@ int32_t tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, bool if (pTask == NULL) { stError("s-task:0x%" PRIx64 " failed malloc new stream task, size:%d, code:%s", streamId, (int32_t)sizeof(SStreamTask), tstrerror(terrno)); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pTask->ver = SSTREAM_TASK_VER; @@ -489,7 +489,7 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i if (pOutputInfo->pTokenBucket == NULL) { stError("s-task:%s failed to prepare the tokenBucket, code:%s", pTask->id.idStr, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } // 2MiB per second for sink task @@ -1196,7 +1196,7 @@ void streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t c int32_t streamTaskCreateActiveChkptInfo(SActiveCheckpointInfo** pRes) { SActiveCheckpointInfo* pInfo = taosMemoryCalloc(1, sizeof(SActiveCheckpointInfo)); if (pInfo == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = taosThreadMutexInit(&pInfo->lock, NULL); diff --git a/source/libs/stream/src/streamTaskSm.c b/source/libs/stream/src/streamTaskSm.c index 968a737ec7..c4ab48827c 100644 --- a/source/libs/stream/src/streamTaskSm.c +++ b/source/libs/stream/src/streamTaskSm.c @@ -286,7 +286,7 @@ int32_t streamCreateStateMachine(SStreamTask* pTask) { if (pSM == NULL) { stError("s-task:%s failed to create task stateMachine, size:%d, code:%s", id, (int32_t)sizeof(SStreamTaskSM), tstrerror(terrno)); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pSM->pTask = pTask; diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index 58ed50da65..40de393570 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -150,7 +150,7 @@ int32_t updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, b int32_t lino = 0; SUpdateInfo* pInfo = taosMemoryCalloc(1, sizeof(SUpdateInfo)); if (pInfo == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } pInfo->pTsBuckets = NULL; @@ -203,12 +203,12 @@ int32_t updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, b pInfo->pkColType = pkType; pInfo->pKeyBuff = taosMemoryCalloc(1, sizeof(TSKEY) + sizeof(int64_t) + pkLen); if (!pInfo->pKeyBuff) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } pInfo->pValueBuff = taosMemoryCalloc(1, sizeof(TSKEY) + pkLen); if (!pInfo->pValueBuff) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } if (pkLen != 0) { diff --git a/source/libs/stream/src/tstreamFileState.c b/source/libs/stream/src/tstreamFileState.c index cbaaec0964..aa237efd04 100644 --- a/source/libs/stream/src/tstreamFileState.c +++ b/source/libs/stream/src/tstreamFileState.c @@ -626,7 +626,7 @@ int32_t getRowBuffByPos(SStreamFileState* pFileState, SRowBuffPos* pPos, void** if (pFileState->curRowCount < pFileState->maxRowCount) { pPos->pRowBuff = taosMemoryCalloc(1, pFileState->rowSize); if (!pPos->pRowBuff) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } pFileState->curRowCount++;