[td-1151] fix the coverity warnings
This commit is contained in:
parent
39618becb7
commit
58bad4cf38
|
@ -1166,7 +1166,8 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
|
|||
size_t numOfNode = taosArrayGetSize(colList);
|
||||
for(int32_t k = 0; k < numOfNode; ++k) {
|
||||
SColIndex* pIndex = taosArrayGet(colList, k);
|
||||
if (pIndex->flag == 1) {
|
||||
if (TSDB_COL_IS_TAG(pIndex->flag)) {
|
||||
tExprTreeDestroy(&pNode, NULL);
|
||||
taosTFree(arithmeticExprStr);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
@ -1366,7 +1367,8 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
|
|||
ids.num = 1;
|
||||
ids.ids[0] = *pIndex;
|
||||
|
||||
if (pIndex->columnIndex >= tscGetNumOfColumns(pTableMeta) || pIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
if (pIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX || pIndex->columnIndex == TSDB_UD_COLUMN_INDEX ||
|
||||
pIndex->columnIndex >= tscGetNumOfColumns(pTableMeta)) {
|
||||
ids.num = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -685,6 +685,9 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
|||
freeJoinSubqueryObj(pParentSql);
|
||||
pParentSql->res.code = code;
|
||||
tscQueueAsyncRes(pParentSql);
|
||||
|
||||
taosArrayDestroy(s1);
|
||||
taosArrayDestroy(s2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1284,8 +1287,14 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
|||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||
assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0);
|
||||
|
||||
|
||||
// todo add test
|
||||
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
||||
if (pState == NULL) {
|
||||
pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return pSql->res.code;
|
||||
}
|
||||
|
||||
pState->numOfTotal = pQueryInfo->numOfTables;
|
||||
pState->numOfRemain = pState->numOfTotal;
|
||||
|
||||
|
@ -1297,7 +1306,8 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
|||
tscError("%p tableIndex:%d, failed to allocate join support object, abort further query", pSql, i);
|
||||
pState->numOfRemain = i;
|
||||
pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
|
||||
taosTFree(pState);
|
||||
|
||||
return pSql->res.code;
|
||||
}
|
||||
|
||||
|
@ -1511,7 +1521,6 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in
|
|||
tstrerror(code), subqueryIndex, trsupport->numOfRetry);
|
||||
|
||||
SSqlObj *pNew = tscCreateSqlObjForSubquery(trsupport->pParentSql, trsupport, pSql);
|
||||
|
||||
if (pNew == NULL) {
|
||||
tscError("%p sub:%p failed to create new subquery due to error:%s, abort retry, vgId:%d, orderOfSub:%d",
|
||||
trsupport->pParentSql, pSql, tstrerror(terrno), pVgroup->vgId, trsupport->subqueryIndex);
|
||||
|
@ -1522,8 +1531,14 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in
|
|||
return pParentSql->res.code;
|
||||
}
|
||||
|
||||
taos_free_result(pSql);
|
||||
return tscProcessSql(pNew);
|
||||
int32_t ret = tscProcessSql(pNew);
|
||||
|
||||
// if failed to process sql, let following code handle the pSql
|
||||
if (ret == TSDB_CODE_SUCCESS) {
|
||||
taos_free_result(pSql);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
||||
|
@ -2063,39 +2078,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
|||
|
||||
doBuildResFromSubqueries(pSql);
|
||||
tsem_post(&pSql->rspSem);
|
||||
|
||||
return;
|
||||
|
||||
// continue retrieve data from vnode
|
||||
// if (!tscHasRemainDataInSubqueryResultSet(pSql)) {
|
||||
// tscDebug("%p at least one subquery exhausted, free all other %d subqueries", pSql, pSql->numOfSubs - 1);
|
||||
// SSubqueryState* pState = NULL;
|
||||
//
|
||||
// // free all sub sqlobj
|
||||
// for (int32_t i = 0; i < pSql->numOfSubs; ++i) {
|
||||
// SSqlObj* pChildObj = pSql->pSubs[i];
|
||||
// if (pChildObj == NULL) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// SJoinSupporter* pSupporter = (SJoinSupporter*)pChildObj->param;
|
||||
// pState = pSupporter->pState;
|
||||
//
|
||||
// tscDestroyJoinSupporter(pChildObj->param);
|
||||
// taos_free_result(pChildObj);
|
||||
// }
|
||||
//
|
||||
// free(pState);
|
||||
//
|
||||
// pRes->completed = true; // set query completed
|
||||
// tsem_post(&pSql->rspSem);
|
||||
// return;
|
||||
// }
|
||||
|
||||
tscFetchDatablockFromSubquery(pSql);
|
||||
if (pRes->code != TSDB_CODE_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (pSql->res.code == TSDB_CODE_SUCCESS) {
|
||||
|
|
|
@ -85,8 +85,8 @@ typedef struct STSBuf {
|
|||
uint32_t fileSize;
|
||||
|
||||
STSVnodeBlockInfoEx* pData;
|
||||
int32_t numOfAlloc;
|
||||
int32_t numOfVnodes;
|
||||
uint32_t numOfAlloc;
|
||||
uint32_t numOfVnodes;
|
||||
|
||||
char* assistBuf;
|
||||
int32_t bufSize;
|
||||
|
|
|
@ -967,6 +967,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
|
|||
|
||||
int32_t index = pWindowResInfo->curIndex;
|
||||
STimeWindow nextWin = win;
|
||||
assert(tsCols != NULL);
|
||||
|
||||
while (1) {
|
||||
int32_t prevEndPos = (forwardStep - 1) * step + startPos;
|
||||
|
@ -2730,7 +2731,8 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) {
|
|||
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||
int32_t bytes = pRuntimeEnv->pCtx[i].outputBytes;
|
||||
char * pDest = pQuery->sdata[i]->data;
|
||||
memcpy(pDest + offset * bytes, pData->data + pRuntimeEnv->offset[i] * pData->num, bytes * pData->num);
|
||||
|
||||
memcpy(pDest + offset * bytes, pData->data + pRuntimeEnv->offset[i] * pData->num, (size_t)(bytes * pData->num));
|
||||
}
|
||||
|
||||
offset += (int32_t)pData->num;
|
||||
|
@ -3298,7 +3300,8 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI
|
|||
pStatus->cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); // save the cursor
|
||||
if (pRuntimeEnv->pTSBuf) {
|
||||
SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order);
|
||||
tsBufNextPos(pRuntimeEnv->pTSBuf);
|
||||
bool ret = tsBufNextPos(pRuntimeEnv->pTSBuf);
|
||||
assert(ret);
|
||||
}
|
||||
|
||||
// reverse order time range
|
||||
|
@ -5225,7 +5228,7 @@ static int32_t getColumnIndexInSource(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pE
|
|||
|
||||
if (TSDB_COL_IS_TAG(pExprMsg->colInfo.flag)) {
|
||||
if (pExprMsg->colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
return -1;
|
||||
return TSDB_TBNAME_COLUMN_INDEX;
|
||||
}
|
||||
|
||||
while(j < pQueryMsg->numOfTags) {
|
||||
|
@ -5644,18 +5647,19 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
|
|||
|
||||
if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) {
|
||||
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
||||
assert(j < pQueryMsg->numOfCols);
|
||||
|
||||
SColumnInfo *pCol = &pQueryMsg->colList[j];
|
||||
|
||||
int32_t ret =
|
||||
getResultDataInfo(pCol->type, pCol->bytes, functId, (int32_t)pExprs[i].base.arg[0].argValue.i64,
|
||||
&pExprs[i].type, &pExprs[i].bytes, &pExprs[i].interBytes, tagLen, isSuperTable);
|
||||
assert(ret == TSDB_CODE_SUCCESS);
|
||||
if (j < 0 || j >= pQueryMsg->numOfCols) {
|
||||
assert(0);
|
||||
} else {
|
||||
SColumnInfo *pCol = &pQueryMsg->colList[j];
|
||||
int32_t ret =
|
||||
getResultDataInfo(pCol->type, pCol->bytes, functId, (int32_t)pExprs[i].base.arg[0].argValue.i64,
|
||||
&pExprs[i].type, &pExprs[i].bytes, &pExprs[i].interBytes, tagLen, isSuperTable);
|
||||
assert(ret == TSDB_CODE_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
*pExprInfo = pExprs;
|
||||
|
||||
*pExprInfo = pExprs;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -6194,14 +6198,16 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
|
|||
|
||||
// make sure file exist
|
||||
if (FD_VALID(fd)) {
|
||||
int32_t s = lseek(fd, 0, SEEK_END);
|
||||
UNUSED(s);
|
||||
qDebug("QInfo:%p ts comp data return, file:%s, size:%d", pQInfo, pQuery->sdata[0]->data, s);
|
||||
uint64_t s = lseek(fd, 0, SEEK_END);
|
||||
|
||||
qDebug("QInfo:%p ts comp data return, file:%s, size:%"PRId64, pQInfo, pQuery->sdata[0]->data, s);
|
||||
if (lseek(fd, 0, SEEK_SET) >= 0) {
|
||||
size_t sz = read(fd, data, s);
|
||||
UNUSED(sz);
|
||||
if(sz < s) { // todo handle error
|
||||
assert(0);
|
||||
}
|
||||
} else {
|
||||
// todo handle error
|
||||
UNUSED(s);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
|
|
@ -137,8 +137,15 @@ static char* doFlushPageToDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
|
|||
}
|
||||
|
||||
//3. write to disk.
|
||||
fseek(pResultBuf->file, pg->info.offset, SEEK_SET);
|
||||
fwrite(t, size, 1, pResultBuf->file);
|
||||
int32_t ret = fseek(pResultBuf->file, pg->info.offset, SEEK_SET);
|
||||
if (ret != 0) { // todo handle the error case
|
||||
|
||||
}
|
||||
|
||||
ret = fwrite(t, size, 1, pResultBuf->file);
|
||||
if (ret != size) { // todo handle the error case
|
||||
|
||||
}
|
||||
|
||||
if (pResultBuf->fileSize < pg->info.offset + pg->info.length) {
|
||||
pResultBuf->fileSize = pg->info.offset + pg->info.length;
|
||||
|
|
|
@ -75,7 +75,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if ((int32_t)header.numOfVnode > pTSBuf->numOfAlloc) {
|
||||
if (header.numOfVnode > pTSBuf->numOfAlloc) {
|
||||
pTSBuf->numOfAlloc = header.numOfVnode;
|
||||
STSVnodeBlockInfoEx* tmp = realloc(pTSBuf->pData, sizeof(STSVnodeBlockInfoEx) * pTSBuf->numOfAlloc);
|
||||
if (tmp == NULL) {
|
||||
|
|
|
@ -657,7 +657,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
|
|||
}
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
void *pNewEntryList = realloc(pHashObj->hashList, sizeof(void*) * newSize);
|
||||
void *pNewEntryList = realloc(pHashObj->hashList, sizeof(void *) * newSize);
|
||||
if (pNewEntryList == NULL) { // todo handle error
|
||||
// uDebug("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue