[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);
|
size_t numOfNode = taosArrayGetSize(colList);
|
||||||
for(int32_t k = 0; k < numOfNode; ++k) {
|
for(int32_t k = 0; k < numOfNode; ++k) {
|
||||||
SColIndex* pIndex = taosArrayGet(colList, k);
|
SColIndex* pIndex = taosArrayGet(colList, k);
|
||||||
if (pIndex->flag == 1) {
|
if (TSDB_COL_IS_TAG(pIndex->flag)) {
|
||||||
|
tExprTreeDestroy(&pNode, NULL);
|
||||||
taosTFree(arithmeticExprStr);
|
taosTFree(arithmeticExprStr);
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||||
}
|
}
|
||||||
|
@ -1366,7 +1367,8 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
|
||||||
ids.num = 1;
|
ids.num = 1;
|
||||||
ids.ids[0] = *pIndex;
|
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;
|
ids.num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -685,6 +685,9 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
||||||
freeJoinSubqueryObj(pParentSql);
|
freeJoinSubqueryObj(pParentSql);
|
||||||
pParentSql->res.code = code;
|
pParentSql->res.code = code;
|
||||||
tscQueueAsyncRes(pParentSql);
|
tscQueueAsyncRes(pParentSql);
|
||||||
|
|
||||||
|
taosArrayDestroy(s1);
|
||||||
|
taosArrayDestroy(s2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,7 +1288,13 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0);
|
assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0);
|
||||||
|
|
||||||
|
// todo add test
|
||||||
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
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->numOfTotal = pQueryInfo->numOfTables;
|
||||||
pState->numOfRemain = pState->numOfTotal;
|
pState->numOfRemain = pState->numOfTotal;
|
||||||
|
|
||||||
|
@ -1297,6 +1306,7 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
||||||
tscError("%p tableIndex:%d, failed to allocate join support object, abort further query", pSql, i);
|
tscError("%p tableIndex:%d, failed to allocate join support object, abort further query", pSql, i);
|
||||||
pState->numOfRemain = i;
|
pState->numOfRemain = i;
|
||||||
pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
taosTFree(pState);
|
||||||
|
|
||||||
return pSql->res.code;
|
return pSql->res.code;
|
||||||
}
|
}
|
||||||
|
@ -1511,7 +1521,6 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in
|
||||||
tstrerror(code), subqueryIndex, trsupport->numOfRetry);
|
tstrerror(code), subqueryIndex, trsupport->numOfRetry);
|
||||||
|
|
||||||
SSqlObj *pNew = tscCreateSqlObjForSubquery(trsupport->pParentSql, trsupport, pSql);
|
SSqlObj *pNew = tscCreateSqlObjForSubquery(trsupport->pParentSql, trsupport, pSql);
|
||||||
|
|
||||||
if (pNew == NULL) {
|
if (pNew == NULL) {
|
||||||
tscError("%p sub:%p failed to create new subquery due to error:%s, abort retry, vgId:%d, orderOfSub:%d",
|
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);
|
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;
|
return pParentSql->res.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
taos_free_result(pSql);
|
||||||
return tscProcessSql(pNew);
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
||||||
|
@ -2063,39 +2078,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
||||||
|
|
||||||
doBuildResFromSubqueries(pSql);
|
doBuildResFromSubqueries(pSql);
|
||||||
tsem_post(&pSql->rspSem);
|
tsem_post(&pSql->rspSem);
|
||||||
|
|
||||||
return;
|
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) {
|
if (pSql->res.code == TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -85,8 +85,8 @@ typedef struct STSBuf {
|
||||||
uint32_t fileSize;
|
uint32_t fileSize;
|
||||||
|
|
||||||
STSVnodeBlockInfoEx* pData;
|
STSVnodeBlockInfoEx* pData;
|
||||||
int32_t numOfAlloc;
|
uint32_t numOfAlloc;
|
||||||
int32_t numOfVnodes;
|
uint32_t numOfVnodes;
|
||||||
|
|
||||||
char* assistBuf;
|
char* assistBuf;
|
||||||
int32_t bufSize;
|
int32_t bufSize;
|
||||||
|
|
|
@ -967,6 +967,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
|
||||||
|
|
||||||
int32_t index = pWindowResInfo->curIndex;
|
int32_t index = pWindowResInfo->curIndex;
|
||||||
STimeWindow nextWin = win;
|
STimeWindow nextWin = win;
|
||||||
|
assert(tsCols != NULL);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int32_t prevEndPos = (forwardStep - 1) * step + startPos;
|
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) {
|
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||||
int32_t bytes = pRuntimeEnv->pCtx[i].outputBytes;
|
int32_t bytes = pRuntimeEnv->pCtx[i].outputBytes;
|
||||||
char * pDest = pQuery->sdata[i]->data;
|
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;
|
offset += (int32_t)pData->num;
|
||||||
|
@ -3298,7 +3300,8 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI
|
||||||
pStatus->cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); // save the cursor
|
pStatus->cur = tsBufGetCursor(pRuntimeEnv->pTSBuf); // save the cursor
|
||||||
if (pRuntimeEnv->pTSBuf) {
|
if (pRuntimeEnv->pTSBuf) {
|
||||||
SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order);
|
SWITCH_ORDER(pRuntimeEnv->pTSBuf->cur.order);
|
||||||
tsBufNextPos(pRuntimeEnv->pTSBuf);
|
bool ret = tsBufNextPos(pRuntimeEnv->pTSBuf);
|
||||||
|
assert(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverse order time range
|
// 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 (TSDB_COL_IS_TAG(pExprMsg->colInfo.flag)) {
|
||||||
if (pExprMsg->colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pExprMsg->colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
return -1;
|
return TSDB_TBNAME_COLUMN_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(j < pQueryMsg->numOfTags) {
|
while(j < pQueryMsg->numOfTags) {
|
||||||
|
@ -5644,18 +5647,19 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
|
||||||
|
|
||||||
if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) {
|
if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) {
|
||||||
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
||||||
assert(j < pQueryMsg->numOfCols);
|
if (j < 0 || j >= pQueryMsg->numOfCols) {
|
||||||
|
assert(0);
|
||||||
|
} else {
|
||||||
SColumnInfo *pCol = &pQueryMsg->colList[j];
|
SColumnInfo *pCol = &pQueryMsg->colList[j];
|
||||||
|
|
||||||
int32_t ret =
|
int32_t ret =
|
||||||
getResultDataInfo(pCol->type, pCol->bytes, functId, (int32_t)pExprs[i].base.arg[0].argValue.i64,
|
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);
|
&pExprs[i].type, &pExprs[i].bytes, &pExprs[i].interBytes, tagLen, isSuperTable);
|
||||||
assert(ret == TSDB_CODE_SUCCESS);
|
assert(ret == TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*pExprInfo = pExprs;
|
}
|
||||||
|
|
||||||
|
*pExprInfo = pExprs;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6194,14 +6198,16 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
|
||||||
|
|
||||||
// make sure file exist
|
// make sure file exist
|
||||||
if (FD_VALID(fd)) {
|
if (FD_VALID(fd)) {
|
||||||
int32_t s = lseek(fd, 0, SEEK_END);
|
uint64_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);
|
qDebug("QInfo:%p ts comp data return, file:%s, size:%"PRId64, pQInfo, pQuery->sdata[0]->data, s);
|
||||||
if (lseek(fd, 0, SEEK_SET) >= 0) {
|
if (lseek(fd, 0, SEEK_SET) >= 0) {
|
||||||
size_t sz = read(fd, data, s);
|
size_t sz = read(fd, data, s);
|
||||||
UNUSED(sz);
|
if(sz < s) { // todo handle error
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// todo handle error
|
UNUSED(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
@ -137,8 +137,15 @@ static char* doFlushPageToDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//3. write to disk.
|
//3. write to disk.
|
||||||
fseek(pResultBuf->file, pg->info.offset, SEEK_SET);
|
int32_t ret = fseek(pResultBuf->file, pg->info.offset, SEEK_SET);
|
||||||
fwrite(t, size, 1, pResultBuf->file);
|
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) {
|
if (pResultBuf->fileSize < pg->info.offset + pg->info.length) {
|
||||||
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int32_t)header.numOfVnode > pTSBuf->numOfAlloc) {
|
if (header.numOfVnode > pTSBuf->numOfAlloc) {
|
||||||
pTSBuf->numOfAlloc = header.numOfVnode;
|
pTSBuf->numOfAlloc = header.numOfVnode;
|
||||||
STSVnodeBlockInfoEx* tmp = realloc(pTSBuf->pData, sizeof(STSVnodeBlockInfoEx) * pTSBuf->numOfAlloc);
|
STSVnodeBlockInfoEx* tmp = realloc(pTSBuf->pData, sizeof(STSVnodeBlockInfoEx) * pTSBuf->numOfAlloc);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue