fix: handle coverity scan
This commit is contained in:
parent
510a745832
commit
601f0f3edf
|
@ -30,7 +30,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct STSRow {
|
||||||
TSKEY ts;
|
TSKEY ts;
|
||||||
union {
|
union {
|
||||||
uint32_t info;
|
uint32_t info;
|
||||||
|
|
|
@ -186,8 +186,8 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
||||||
STscObj* pTscObj = (*pRequest)->pTscObj;
|
STscObj* pTscObj = (*pRequest)->pTscObj;
|
||||||
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
||||||
sizeof((*pRequest)->self))) {
|
sizeof((*pRequest)->self))) {
|
||||||
tscError("%" PRIx64 " failed to add to request container, reqId:0x%" PRIu64 ", conn:%" PRIx64 ", %s", (*pRequest)->self,
|
tscError("%" PRIx64 " failed to add to request container, reqId:0x%" PRIu64 ", conn:%" PRIx64 ", %s",
|
||||||
(*pRequest)->requestId, pTscObj->id, sql);
|
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||||
|
|
||||||
taosMemoryFree(param);
|
taosMemoryFree(param);
|
||||||
destroyRequest(*pRequest);
|
destroyRequest(*pRequest);
|
||||||
|
@ -199,8 +199,8 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
||||||
if (tsQueryUseNodeAllocator && !qIsInsertValuesSql((*pRequest)->sqlstr, (*pRequest)->sqlLen)) {
|
if (tsQueryUseNodeAllocator && !qIsInsertValuesSql((*pRequest)->sqlstr, (*pRequest)->sqlLen)) {
|
||||||
if (TSDB_CODE_SUCCESS !=
|
if (TSDB_CODE_SUCCESS !=
|
||||||
nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) {
|
nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) {
|
||||||
tscError("%d failed to create node allocator, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s", (*pRequest)->self,
|
tscError("%" PRId64 " failed to create node allocator, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
||||||
(*pRequest)->requestId, pTscObj->id, sql);
|
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||||
|
|
||||||
destroyRequest(*pRequest);
|
destroyRequest(*pRequest);
|
||||||
*pRequest = NULL;
|
*pRequest = NULL;
|
||||||
|
@ -1040,39 +1040,39 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat
|
||||||
SSqlCallbackWrapper* pWrapper) {
|
SSqlCallbackWrapper* pWrapper) {
|
||||||
pRequest->type = pQuery->msgType;
|
pRequest->type = pQuery->msgType;
|
||||||
|
|
||||||
SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad));
|
SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad));
|
||||||
|
|
||||||
SPlanContext cxt = {.queryId = pRequest->requestId,
|
SPlanContext cxt = {.queryId = pRequest->requestId,
|
||||||
.acctId = pRequest->pTscObj->acctId,
|
.acctId = pRequest->pTscObj->acctId,
|
||||||
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
||||||
.pAstRoot = pQuery->pRoot,
|
.pAstRoot = pQuery->pRoot,
|
||||||
.showRewrite = pQuery->showRewrite,
|
.showRewrite = pQuery->showRewrite,
|
||||||
.pMsg = pRequest->msgBuf,
|
.pMsg = pRequest->msgBuf,
|
||||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||||
.pUser = pRequest->pTscObj->user,
|
.pUser = pRequest->pTscObj->user,
|
||||||
.sysInfo = pRequest->pTscObj->sysInfo,
|
.sysInfo = pRequest->pTscObj->sysInfo,
|
||||||
.allocatorId = pRequest->allocatorRefId};
|
.allocatorId = pRequest->allocatorRefId};
|
||||||
|
|
||||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||||
SQueryPlan* pDag = NULL;
|
SQueryPlan* pDag = NULL;
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
int32_t code = qCreateQueryPlan(&cxt, &pDag, pMnodeList);
|
int32_t code = qCreateQueryPlan(&cxt, &pDag, pMnodeList);
|
||||||
if (code) {
|
if (code) {
|
||||||
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
} else {
|
} else {
|
||||||
pRequest->body.subplanNum = pDag->numOfSubplans;
|
pRequest->body.subplanNum = pDag->numOfSubplans;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->metric.planEnd = taosGetTimestampUs();
|
pRequest->metric.planEnd = taosGetTimestampUs();
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
tscDebug("0x%" PRIx64 " create query plan success, elapsed time:%.2f ms, 0x%" PRIx64, pRequest->self,
|
tscDebug("0x%" PRIx64 " create query plan success, elapsed time:%.2f ms, 0x%" PRIx64, pRequest->self,
|
||||||
(pRequest->metric.planEnd - st)/1000.0, pRequest->requestId);
|
(pRequest->metric.planEnd - st) / 1000.0, pRequest->requestId);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) {
|
if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) {
|
||||||
SArray* pNodeList = NULL;
|
SArray* pNodeList = NULL;
|
||||||
buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta);
|
buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta);
|
||||||
|
|
||||||
SRequestConnInfo conn = {.pTrans = getAppInfo(pRequest)->pTransporter,
|
SRequestConnInfo conn = {.pTrans = getAppInfo(pRequest)->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
|
@ -2262,7 +2262,7 @@ void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp,
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fp(param, NULL, terrno);
|
fp(param, NULL, terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,7 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
|
||||||
|
|
||||||
SDataDeleterBuf* pBuf = NULL;
|
SDataDeleterBuf* pBuf = NULL;
|
||||||
taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf);
|
taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf);
|
||||||
|
ASSERT(NULL != pBuf);
|
||||||
memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf));
|
memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf));
|
||||||
taosFreeQitem(pBuf);
|
taosFreeQitem(pBuf);
|
||||||
|
|
||||||
|
|
|
@ -84,13 +84,12 @@ static void endTlvEncode(STlvEncoder* pEncoder, char** pMsg, int32_t* pLen) {
|
||||||
*pMsg = pEncoder->pBuf;
|
*pMsg = pEncoder->pBuf;
|
||||||
pEncoder->pBuf = NULL;
|
pEncoder->pBuf = NULL;
|
||||||
*pLen = pEncoder->offset;
|
*pLen = pEncoder->offset;
|
||||||
// nodesWarn("encode tlv count = %d, tl size = %d", pEncoder->tlvCount, sizeof(STlv) * pEncoder->tlvCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tlvEncodeImpl(STlvEncoder* pEncoder, int16_t type, const void* pValue, int32_t len) {
|
static int32_t tlvEncodeImpl(STlvEncoder* pEncoder, int16_t type, const void* pValue, int32_t len) {
|
||||||
int32_t tlvLen = sizeof(STlv) + len;
|
int32_t tlvLen = sizeof(STlv) + len;
|
||||||
if (pEncoder->offset + tlvLen > pEncoder->allocSize) {
|
if (pEncoder->offset + tlvLen > pEncoder->allocSize) {
|
||||||
pEncoder->allocSize = TMAX(pEncoder->allocSize * 2, pEncoder->allocSize + pEncoder->offset + tlvLen);
|
pEncoder->allocSize = TMAX(pEncoder->allocSize * 2, pEncoder->allocSize + tlvLen);
|
||||||
void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize);
|
void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize);
|
||||||
if (NULL == pNewBuf) {
|
if (NULL == pNewBuf) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -241,6 +240,15 @@ static int32_t tlvEncodeObj(STlvEncoder* pEncoder, int16_t type, FToMsg func, co
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pEncoder->offset + sizeof(STlv) > pEncoder->allocSize) {
|
||||||
|
pEncoder->allocSize = TMAX(pEncoder->allocSize * 2, pEncoder->allocSize + sizeof(STlv));
|
||||||
|
void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize);
|
||||||
|
if (NULL == pNewBuf) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
pEncoder->pBuf = pNewBuf;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t start = pEncoder->offset;
|
int32_t start = pEncoder->offset;
|
||||||
pEncoder->offset += sizeof(STlv);
|
pEncoder->offset += sizeof(STlv);
|
||||||
int32_t code = func(pObj, pEncoder);
|
int32_t code = func(pObj, pEncoder);
|
||||||
|
@ -307,7 +315,7 @@ static int32_t tlvDecodeImpl(STlv* pTlv, void* pValue, int32_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tlvDecodeValueImpl(STlvDecoder* pDecoder, void* pValue, int32_t len) {
|
static int32_t tlvDecodeValueImpl(STlvDecoder* pDecoder, void* pValue, int32_t len) {
|
||||||
if (pDecoder->offset + len > pDecoder->bufSize) {
|
if (len > pDecoder->bufSize - pDecoder->offset) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
memcpy(pValue, pDecoder->pBuf + pDecoder->offset, len);
|
memcpy(pValue, pDecoder->pBuf + pDecoder->offset, len);
|
||||||
|
@ -911,6 +919,10 @@ static int32_t msgToDatum(STlv* pTlv, void* pObj) {
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
|
if (pTlv->len > pNode->node.resType.bytes + VARSTR_HEADER_SIZE) {
|
||||||
|
code = TSDB_CODE_FAILED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
|
pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
|
||||||
if (NULL == pNode->datum.p) {
|
if (NULL == pNode->datum.p) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -190,14 +190,23 @@ int32_t nodesReleaseAllocator(int64_t allocatorId) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == g_pNodeAllocator) {
|
SNodeAllocator* pAllocator = taosAcquireRef(g_allocatorReqRefPool, allocatorId);
|
||||||
|
if (NULL == pAllocator) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = taosThreadMutexTryLock(&pAllocator->mutex);
|
||||||
|
if (EBUSY != code) {
|
||||||
nodesError("allocator id %" PRIx64
|
nodesError("allocator id %" PRIx64
|
||||||
" release failed: The nodesReleaseAllocator function needs to be called after the nodesAcquireAllocator "
|
" release failed: The nodesReleaseAllocator function needs to be called after the nodesAcquireAllocator "
|
||||||
"function is called!",
|
"function is called!",
|
||||||
allocatorId);
|
allocatorId);
|
||||||
|
if (0 == code) {
|
||||||
|
taosThreadMutexUnlock(&pAllocator->mutex);
|
||||||
|
}
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
SNodeAllocator* pAllocator = g_pNodeAllocator;
|
|
||||||
g_pNodeAllocator = NULL;
|
g_pNodeAllocator = NULL;
|
||||||
taosThreadMutexUnlock(&pAllocator->mutex);
|
taosThreadMutexUnlock(&pAllocator->mutex);
|
||||||
return taosReleaseRef(g_allocatorReqRefPool, allocatorId);
|
return taosReleaseRef(g_allocatorReqRefPool, allocatorId);
|
||||||
|
@ -1826,7 +1835,7 @@ static EDealRes collectFuncs(SNode* pNode, void* pContext) {
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId) &&
|
if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId) &&
|
||||||
!(((SExprNode*)pNode)->orderAlias)) {
|
!(((SExprNode*)pNode)->orderAlias)) {
|
||||||
SExprNode* pExpr = (SExprNode*)pNode;
|
SExprNode* pExpr = (SExprNode*)pNode;
|
||||||
if (NULL == taosHashGet(pCxt->pFuncsSet, &pExpr, POINTER_BYTES)) {
|
if (NULL == taosHashGet(pCxt->pFuncsSet, &pExpr, sizeof(SExprNode*))) {
|
||||||
pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode));
|
pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode));
|
||||||
taosHashPut(pCxt->pFuncsSet, &pExpr, POINTER_BYTES, &pExpr, POINTER_BYTES);
|
taosHashPut(pCxt->pFuncsSet, &pExpr, POINTER_BYTES, &pExpr, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1365,8 +1365,12 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, TdFilePtr fp, STableDataB
|
||||||
strtolower(pLine, pLine);
|
strtolower(pLine, pLine);
|
||||||
char* pRawSql = pCxt->pSql;
|
char* pRawSql = pCxt->pSql;
|
||||||
pCxt->pSql = pLine;
|
pCxt->pSql = pLine;
|
||||||
bool gotRow = false;
|
bool gotRow = false;
|
||||||
CHECK_CODE(parseOneRow(pCxt, pDataBlock, tinfo.precision, &gotRow, tmpTokenBuf));
|
int32_t code = parseOneRow(pCxt, pDataBlock, tinfo.precision, &gotRow, tmpTokenBuf);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
pCxt->pSql = pRawSql;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
if (gotRow) {
|
if (gotRow) {
|
||||||
pDataBlock->size += extendedRowSize; // len;
|
pDataBlock->size += extendedRowSize; // len;
|
||||||
(*numOfRows)++;
|
(*numOfRows)++;
|
||||||
|
|
|
@ -222,6 +222,21 @@ int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq)
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroyDataBlock(STableDataBlocks* pDataBlock) {
|
||||||
|
if (pDataBlock == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pDataBlock->pData);
|
||||||
|
// if (!pDataBlock->cloned) {
|
||||||
|
// free the refcount for metermeta
|
||||||
|
taosMemoryFreeClear(pDataBlock->pTableMeta);
|
||||||
|
|
||||||
|
destroyBoundColumnInfo(&pDataBlock->boundColumnInfo);
|
||||||
|
// }
|
||||||
|
taosMemoryFreeClear(pDataBlock);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t getDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32_t size, int32_t startOffset,
|
int32_t getDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32_t size, int32_t startOffset,
|
||||||
int32_t rowSize, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList,
|
int32_t rowSize, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList,
|
||||||
SVCreateTbReq* pCreateTbReq) {
|
SVCreateTbReq* pCreateTbReq) {
|
||||||
|
@ -240,11 +255,13 @@ int32_t getDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32
|
||||||
if (NULL != pCreateTbReq && NULL != pCreateTbReq->ctb.pTag) {
|
if (NULL != pCreateTbReq && NULL != pCreateTbReq->ctb.pTag) {
|
||||||
ret = buildCreateTbMsg(*dataBlocks, pCreateTbReq);
|
ret = buildCreateTbMsg(*dataBlocks, pCreateTbReq);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
destroyDataBlock(*dataBlocks);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashPut(pHashList, id, idLen, dataBlocks, POINTER_BYTES);
|
// converting to 'const char*' is to handle coverity scan errors
|
||||||
|
taosHashPut(pHashList, (const char*)id, idLen, (const char*)dataBlocks, POINTER_BYTES);
|
||||||
if (pBlockList) {
|
if (pBlockList) {
|
||||||
taosArrayPush(pBlockList, dataBlocks);
|
taosArrayPush(pBlockList, dataBlocks);
|
||||||
}
|
}
|
||||||
|
@ -266,21 +283,6 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyDataBlock(STableDataBlocks* pDataBlock) {
|
|
||||||
if (pDataBlock == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(pDataBlock->pData);
|
|
||||||
// if (!pDataBlock->cloned) {
|
|
||||||
// free the refcount for metermeta
|
|
||||||
taosMemoryFreeClear(pDataBlock->pTableMeta);
|
|
||||||
|
|
||||||
destroyBoundColumnInfo(&pDataBlock->boundColumnInfo);
|
|
||||||
// }
|
|
||||||
taosMemoryFreeClear(pDataBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroyBlockArrayList(SArray* pDataBlockList) {
|
void destroyBlockArrayList(SArray* pDataBlockList) {
|
||||||
if (pDataBlockList == NULL) {
|
if (pDataBlockList == NULL) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -248,8 +248,11 @@ int32_t getNumOfTags(const STableMeta* pTableMeta) { return getTableInfo(pTableM
|
||||||
STableComInfo getTableInfo(const STableMeta* pTableMeta) { return pTableMeta->tableInfo; }
|
STableComInfo getTableInfo(const STableMeta* pTableMeta) { return pTableMeta->tableInfo; }
|
||||||
|
|
||||||
STableMeta* tableMetaDup(const STableMeta* pTableMeta) {
|
STableMeta* tableMetaDup(const STableMeta* pTableMeta) {
|
||||||
size_t size = TABLE_META_SIZE(pTableMeta);
|
if (TABLE_TOTAL_COL_NUM(pTableMeta) > TSDB_MAX_COLUMNS || TABLE_TOTAL_COL_NUM(pTableMeta) < TSDB_MIN_COLUMNS) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size = TABLE_META_SIZE(pTableMeta);
|
||||||
STableMeta* p = taosMemoryMalloc(size);
|
STableMeta* p = taosMemoryMalloc(size);
|
||||||
memcpy(p, pTableMeta, size);
|
memcpy(p, pTableMeta, size);
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -423,13 +423,14 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pSrc->tableInfo.numOfColumns + pSrc->tableInfo.numOfTags) > TSDB_MAX_COL_TAG_NUM) {
|
int32_t numOfField = pSrc->tableInfo.numOfColumns + pSrc->tableInfo.numOfTags;
|
||||||
|
if (numOfField > TSDB_MAX_COL_TAG_NUM || numOfField < TSDB_MIN_COLUMNS) {
|
||||||
*pDst = NULL;
|
*pDst = NULL;
|
||||||
qError("too many column and tag num:%d,%d", pSrc->tableInfo.numOfColumns, pSrc->tableInfo.numOfTags);
|
qError("too many column and tag num:%d,%d", pSrc->tableInfo.numOfColumns, pSrc->tableInfo.numOfTags);
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaSize = sizeof(STableMeta) + (pSrc->tableInfo.numOfColumns + pSrc->tableInfo.numOfTags) * sizeof(SSchema);
|
int32_t metaSize = sizeof(STableMeta) + numOfField * sizeof(SSchema);
|
||||||
*pDst = taosMemoryMalloc(metaSize);
|
*pDst = taosMemoryMalloc(metaSize);
|
||||||
if (NULL == *pDst) {
|
if (NULL == *pDst) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
|
Loading…
Reference in New Issue