From f790003eeb06513e5152bbe0e54371a427556cd6 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 5 Aug 2020 18:36:38 +0800 Subject: [PATCH] TD-1057 --- src/client/src/tscFunctionImpl.c | 44 +++++++++---------- src/client/src/tscLocalMerge.c | 42 +++++++++--------- src/client/src/tscParseInsert.c | 18 ++++---- src/client/src/tscProfile.c | 2 +- src/client/src/tscSQLParser.c | 74 ++++++++++++++++---------------- src/client/src/tscSchemaUtil.c | 4 +- src/client/src/tscServer.c | 32 +++++++------- src/client/src/tscSql.c | 20 ++++----- src/client/src/tscStream.c | 10 ++--- src/os/inc/osMath.h | 1 + src/os/inc/osWindows.h | 2 - src/query/src/qFill.c | 4 +- 12 files changed, 126 insertions(+), 127 deletions(-) diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 568d15660e..5e00f7e534 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -2225,7 +2225,7 @@ static void top_function(SQLFunctionCtx *pCtx) { } notNullElems++; - do_top_function_add(pRes, pCtx->param[0].i64Key, data, pCtx->ptsList[i], pCtx->inputType, &pCtx->tagInfo, NULL, 0); + do_top_function_add(pRes, (int32_t)pCtx->param[0].i64Key, data, pCtx->ptsList[i], pCtx->inputType, &pCtx->tagInfo, NULL, 0); } if (!pCtx->hasNull) { @@ -2251,7 +2251,7 @@ static void top_function_f(SQLFunctionCtx *pCtx, int32_t index) { assert(pRes->num >= 0); SET_VAL(pCtx, 1, 1); - do_top_function_add(pRes, pCtx->param[0].i64Key, pData, pCtx->ptsList[index], pCtx->inputType, &pCtx->tagInfo, NULL, + do_top_function_add(pRes, (int32_t)pCtx->param[0].i64Key, pData, pCtx->ptsList[index], pCtx->inputType, &pCtx->tagInfo, NULL, 0); SResultInfo *pResInfo = GET_RES_INFO(pCtx); @@ -2275,7 +2275,7 @@ static void top_func_merge(SQLFunctionCtx *pCtx) { STopBotInfo *pOutput = getTopBotOutputInfo(pCtx); for (int32_t i = 0; i < pInput->num; ++i) { - do_top_function_add(pOutput, pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, + do_top_function_add(pOutput, (int32_t)pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, pCtx->inputType, &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->currentStage); } } @@ -2291,7 +2291,7 @@ static void top_func_second_merge(SQLFunctionCtx *pCtx) { // the intermediate result is binary, we only use the output data type for (int32_t i = 0; i < pInput->num; ++i) { int16_t type = (pCtx->outputType == TSDB_DATA_TYPE_FLOAT)? TSDB_DATA_TYPE_DOUBLE:pCtx->outputType; - do_top_function_add(pOutput, pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, + do_top_function_add(pOutput, (int32_t)pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, type, &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->currentStage); } @@ -2315,7 +2315,7 @@ static void bottom_function(SQLFunctionCtx *pCtx) { } notNullElems++; - do_bottom_function_add(pRes, pCtx->param[0].i64Key, data, pCtx->ptsList[i], pCtx->inputType, &pCtx->tagInfo, NULL, + do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64Key, data, pCtx->ptsList[i], pCtx->inputType, &pCtx->tagInfo, NULL, 0); } @@ -2340,7 +2340,7 @@ static void bottom_function_f(SQLFunctionCtx *pCtx, int32_t index) { STopBotInfo *pRes = getTopBotOutputInfo(pCtx); SET_VAL(pCtx, 1, 1); - do_bottom_function_add(pRes, pCtx->param[0].i64Key, pData, pCtx->ptsList[index], pCtx->inputType, &pCtx->tagInfo, + do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64Key, pData, pCtx->ptsList[index], pCtx->inputType, &pCtx->tagInfo, NULL, 0); SResultInfo *pResInfo = GET_RES_INFO(pCtx); @@ -2364,7 +2364,7 @@ static void bottom_func_merge(SQLFunctionCtx *pCtx) { STopBotInfo *pOutput = getTopBotOutputInfo(pCtx); for (int32_t i = 0; i < pInput->num; ++i) { - do_bottom_function_add(pOutput, pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, + do_bottom_function_add(pOutput, (int32_t)pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, pCtx->inputType, &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->currentStage); } } @@ -2380,7 +2380,7 @@ static void bottom_func_second_merge(SQLFunctionCtx *pCtx) { // the intermediate result is binary, we only use the output data type for (int32_t i = 0; i < pInput->num; ++i) { int16_t type = (pCtx->outputType == TSDB_DATA_TYPE_FLOAT) ? TSDB_DATA_TYPE_DOUBLE : pCtx->outputType; - do_bottom_function_add(pOutput, pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, type, + do_bottom_function_add(pOutput, (int32_t)pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, type, &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->currentStage); } @@ -2430,7 +2430,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) { } SResultInfo *pResInfo = GET_RES_INFO(pCtx); - SSchema field[1] = {{pCtx->inputType, "dummyCol", 0, pCtx->inputBytes}}; + SSchema field[1] = { { pCtx->inputType, "dummyCol", 0, (uint8_t)pCtx->inputBytes } }; SColumnModel *pModel = createColumnModel(field, 1, 1000); int32_t orderIdx = 0; @@ -2543,7 +2543,7 @@ static void apercentile_function(SQLFunctionCtx *pCtx) { v = GET_INT16_VAL(data); break; case TSDB_DATA_TYPE_BIGINT: - v = GET_INT64_VAL(data); + v = (double)(GET_INT64_VAL(data)); break; case TSDB_DATA_TYPE_FLOAT: v = GET_FLOAT_VAL(data); @@ -2588,7 +2588,7 @@ static void apercentile_function_f(SQLFunctionCtx *pCtx, int32_t index) { v = GET_INT16_VAL(pData); break; case TSDB_DATA_TYPE_BIGINT: - v = GET_INT64_VAL(pData); + v = (double)(GET_INT64_VAL(pData)); break; case TSDB_DATA_TYPE_FLOAT: v = GET_FLOAT_VAL(pData); @@ -3027,13 +3027,13 @@ static void diff_function(SQLFunctionCtx *pCtx) { pCtx->param[1].i64Key = pData[i]; pCtx->param[1].nType = pCtx->inputType; } else if ((i == 0 && pCtx->order == TSDB_ORDER_ASC) || (i == pCtx->size - 1 && pCtx->order == TSDB_ORDER_DESC)) { - *pOutput = pData[i] - pCtx->param[1].i64Key; + *pOutput = (int32_t)(pData[i] - pCtx->param[1].i64Key); *pTimestamp = pCtx->ptsList[i]; pOutput += 1; pTimestamp += 1; } else { - *pOutput = pData[i] - pCtx->param[1].i64Key; // direct previous may be null + *pOutput = (int32_t)(pData[i] - pCtx->param[1].i64Key); // direct previous may be null *pTimestamp = pCtx->ptsList[i]; pOutput += 1; @@ -3121,13 +3121,13 @@ static void diff_function(SQLFunctionCtx *pCtx) { pCtx->param[1].dKey = pData[i]; pCtx->param[1].nType = pCtx->inputType; } else if ((i == 0 && pCtx->order == TSDB_ORDER_ASC) || (i == pCtx->size - 1 && pCtx->order == TSDB_ORDER_DESC)) { - *pOutput = pData[i] - pCtx->param[1].dKey; + *pOutput = (float)(pData[i] - pCtx->param[1].dKey); *pTimestamp = pCtx->ptsList[i]; pOutput += 1; pTimestamp += 1; } else { - *pOutput = pData[i] - pCtx->param[1].dKey; + *pOutput = (float)(pData[i] - pCtx->param[1].dKey); *pTimestamp = pCtx->ptsList[i]; pOutput += 1; @@ -3154,12 +3154,12 @@ static void diff_function(SQLFunctionCtx *pCtx) { pCtx->param[1].i64Key = pData[i]; pCtx->param[1].nType = pCtx->inputType; } else if ((i == 0 && pCtx->order == TSDB_ORDER_ASC) || (i == pCtx->size - 1 && pCtx->order == TSDB_ORDER_DESC)) { - *pOutput = pData[i] - pCtx->param[1].i64Key; + *pOutput = (int16_t)(pData[i] - pCtx->param[1].i64Key); *pTimestamp = pCtx->ptsList[i]; pOutput += 1; pTimestamp += 1; } else { - *pOutput = pData[i] - pCtx->param[1].i64Key; + *pOutput = (int16_t)(pData[i] - pCtx->param[1].i64Key); *pTimestamp = pCtx->ptsList[i]; pOutput += 1; @@ -3185,13 +3185,13 @@ static void diff_function(SQLFunctionCtx *pCtx) { pCtx->param[1].i64Key = pData[i]; pCtx->param[1].nType = pCtx->inputType; } else if ((i == 0 && pCtx->order == TSDB_ORDER_ASC) || (i == pCtx->size - 1 && pCtx->order == TSDB_ORDER_DESC)) { - *pOutput = pData[i] - pCtx->param[1].i64Key; + *pOutput = (int8_t)(pData[i] - pCtx->param[1].i64Key); *pTimestamp = pCtx->ptsList[i]; pOutput += 1; pTimestamp += 1; } else { - *pOutput = pData[i] - pCtx->param[1].i64Key; + *pOutput = (int8_t)(pData[i] - pCtx->param[1].i64Key); *pTimestamp = pCtx->ptsList[i]; pOutput += 1; @@ -3256,7 +3256,7 @@ static void diff_function_f(SQLFunctionCtx *pCtx, int32_t index) { pCtx->param[1].nType = pCtx->inputType; pCtx->param[1].i64Key = *(int32_t *)pData; } else { - *(int32_t *)pCtx->aOutputBuf = *(int32_t *)pData - pCtx->param[1].i64Key; + *(int32_t *)pCtx->aOutputBuf = *(int32_t *)pData - (int32_t)pCtx->param[1].i64Key; pCtx->param[1].i64Key = *(int32_t *)pData; *(int64_t *)pCtx->ptsOutputBuf = pCtx->ptsList[index]; } @@ -3383,11 +3383,11 @@ static void spread_function(SQLFunctionCtx *pCtx) { if ((pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) || (pCtx->inputType == TSDB_DATA_TYPE_TIMESTAMP)) { if (pInfo->min > pCtx->preAggVals.statis.min) { - pInfo->min = pCtx->preAggVals.statis.min; + pInfo->min = (double)pCtx->preAggVals.statis.min; } if (pInfo->max < pCtx->preAggVals.statis.max) { - pInfo->max = pCtx->preAggVals.statis.max; + pInfo->max = (double)pCtx->preAggVals.statis.max; } } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE || pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { if (pInfo->min > GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.min))) { diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c index 394b725781..b7d8a0b7b2 100644 --- a/src/client/src/tscLocalMerge.c +++ b/src/client/src/tscLocalMerge.c @@ -133,7 +133,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc } static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) { - int32_t numOfCols = tscSqlExprNumOfExprs(pQueryInfo); + int32_t numOfCols = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); int32_t offset = 0; SFillColInfo* pFillCol = calloc(numOfCols, sizeof(SFillColInfo)); @@ -141,7 +141,7 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); pFillCol[i].col.bytes = pExpr->resBytes; - pFillCol[i].col.type = pExpr->resType; + pFillCol[i].col.type = (int8_t)pExpr->resType; pFillCol[i].flag = pExpr->colInfo.flag; pFillCol[i].col.offset = offset; pFillCol[i].functionId = pExpr->functionId; @@ -361,7 +361,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd pQueryInfo->limit.offset = pQueryInfo->prjOffset; } - pReducer->offset = pQueryInfo->limit.offset; + pReducer->offset = (int32_t)pQueryInfo->limit.offset; pRes->pLocalReducer = pReducer; pRes->numOfGroups = 0; @@ -376,7 +376,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd if (pQueryInfo->fillType != TSDB_FILL_NONE) { SFillColInfo* pFillCol = createFillColInfo(pQueryInfo); pReducer->pFillInfo = taosInitFillInfo(pQueryInfo->order.order, revisedSTime, pQueryInfo->groupbyExpr.numOfGroupCols, - 4096, numOfCols, pQueryInfo->slidingTime, pQueryInfo->slidingTimeUnit, + 4096, (int32_t)numOfCols, pQueryInfo->slidingTime, pQueryInfo->slidingTimeUnit, tinfo.precision, pQueryInfo->fillType, pFillCol); } @@ -405,7 +405,7 @@ static int32_t tscFlushTmpBufferImpl(tExtMemBuffer *pMemoryBuf, tOrderDescriptor // sort before flush to disk, the data must be consecutively put on tFilePage. if (pDesc->orderInfo.numOfCols > 0) { - tColDataQSort(pDesc, pPage->num, 0, pPage->num - 1, pPage->data, orderType); + tColDataQSort(pDesc, (int32_t)pPage->num, 0, (int32_t)pPage->num - 1, pPage->data, orderType); } #ifdef _DEBUG_VIEW @@ -414,7 +414,7 @@ static int32_t tscFlushTmpBufferImpl(tExtMemBuffer *pMemoryBuf, tOrderDescriptor #endif // write to cache after being sorted - if (tExtMemBufferPut(pMemoryBuf, pPage->data, pPage->num) < 0) { + if (tExtMemBufferPut(pMemoryBuf, pPage->data, (int32_t)pPage->num) < 0) { tscError("failed to save data in temporary buffer"); return -1; } @@ -446,7 +446,7 @@ int32_t saveToBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tFilePa } // current buffer is overflow, flush data to extensive buffer - int32_t numOfRemainEntries = pModel->capacity - pPage->num; + int32_t numOfRemainEntries = pModel->capacity - (int32_t)pPage->num; tColModelAppend(pModel, pPage, data, 0, numOfRemainEntries, numOfRows); // current buffer is full, need to flushed to disk @@ -679,7 +679,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i); pSchema[i].bytes = pExpr->resBytes; - pSchema[i].type = pExpr->resType; + pSchema[i].type = (int8_t)pExpr->resType; rlen += pExpr->resBytes; } @@ -689,7 +689,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr capacity = nBufferSizes / rlen; } - pModel = createColumnModel(pSchema, size, capacity); + pModel = createColumnModel(pSchema, (int32_t)size, capacity); int32_t pg = DEFAULT_PAGE_SIZE; int32_t overhead = sizeof(tFilePage); @@ -740,12 +740,12 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr getResultDataInfo(p1->type, p1->bytes, functionId, 0, &type, &bytes, &inter, 0, false); } - pSchema[i].type = type; + pSchema[i].type = (uint8_t)type; pSchema[i].bytes = bytes; strcpy(pSchema[i].name, pModel->pFields[i].field.name); } - *pFinalModel = createColumnModel(pSchema, size, capacity); + *pFinalModel = createColumnModel(pSchema, (int32_t)size, capacity); taosTFree(pSchema); return TSDB_CODE_SUCCESS; @@ -780,7 +780,7 @@ int32_t loadNewDataFromDiskFor(SLocalReducer *pLocalReducer, SLocalDataSource *p pOneInterDataSrc->rowIdx = 0; pOneInterDataSrc->pageId += 1; - if (pOneInterDataSrc->pageId < + if ((uint32_t)pOneInterDataSrc->pageId < pOneInterDataSrc->pMemBuffer->fileMeta.flushoutData.pFlushoutInfo[pOneInterDataSrc->flushoutIdx].numOfPages) { tExtMemBufferLoadData(pOneInterDataSrc->pMemBuffer, &(pOneInterDataSrc->filePage), pOneInterDataSrc->flushoutIdx, pOneInterDataSrc->pageId); @@ -924,8 +924,8 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO if (pQueryInfo->limit.offset > 0) { if (pQueryInfo->limit.offset < pRes->numOfRows) { - int32_t prevSize = pFinalDataPage->num; - tColModelErase(pLocalReducer->resColModel, pFinalDataPage, prevSize, 0, pQueryInfo->limit.offset - 1); + int32_t prevSize = (int32_t)pFinalDataPage->num; + tColModelErase(pLocalReducer->resColModel, pFinalDataPage, prevSize, 0, (int32_t)pQueryInfo->limit.offset - 1); /* remove the hole in column model */ tColModelCompact(pLocalReducer->resColModel, pFinalDataPage, prevSize); @@ -942,8 +942,8 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO if (pQueryInfo->limit.limit >= 0 && pRes->numOfClauseTotal > pQueryInfo->limit.limit) { /* impose the limitation of output rows on the final result */ - int32_t prevSize = pFinalDataPage->num; - int32_t overflow = pRes->numOfClauseTotal - pQueryInfo->limit.limit; + int32_t prevSize = (int32_t)pFinalDataPage->num; + int32_t overflow = (int32_t)(pRes->numOfClauseTotal - pQueryInfo->limit.limit); assert(overflow < pRes->numOfRows); pRes->numOfClauseTotal = pQueryInfo->limit.limit; @@ -1001,7 +1001,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO } /* all output for current group are completed */ - int32_t totalRemainRows = getFilledNumOfRes(pFillInfo, actualETime, pLocalReducer->resColModel->capacity); + int32_t totalRemainRows = (int32_t)getFilledNumOfRes(pFillInfo, actualETime, pLocalReducer->resColModel->capacity); if (totalRemainRows <= 0) { break; } @@ -1011,7 +1011,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO if (pRes->numOfRows > 0) { if (pQueryInfo->limit.limit >= 0 && pRes->numOfClauseTotal > pQueryInfo->limit.limit) { - int32_t overflow = pRes->numOfClauseTotal - pQueryInfo->limit.limit; + int32_t overflow = (int32_t)(pRes->numOfClauseTotal - pQueryInfo->limit.limit); pRes->numOfRows -= overflow; assert(pRes->numOfRows >= 0); @@ -1279,7 +1279,7 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no SFillInfo* pFillInfo = pLocalReducer->pFillInfo; if (pFillInfo != NULL) { - taosFillSetStartInfo(pFillInfo, pResBuf->num, pQueryInfo->window.ekey); + taosFillSetStartInfo(pFillInfo, (int32_t)pResBuf->num, pQueryInfo->window.ekey); taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf); } @@ -1338,7 +1338,7 @@ static bool doBuildFilledResultForGroup(SSqlObj *pSql) { int64_t etime = *(int64_t *)(pFinalDataBuf->data + TSDB_KEYSIZE * (pFillInfo->numOfRows - 1)); // the first column must be the timestamp column - int32_t rows = getFilledNumOfRes(pFillInfo, etime, pLocalReducer->resColModel->capacity); + int32_t rows = (int32_t)getFilledNumOfRes(pFillInfo, etime, pLocalReducer->resColModel->capacity); if (rows > 0) { // do fill gap doFillResult(pSql, pLocalReducer, false); } @@ -1367,7 +1367,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) { int64_t etime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.ekey : pQueryInfo->window.skey; assert(pFillInfo->numOfRows == 0); - int32_t rows = getFilledNumOfRes(pFillInfo, etime, pLocalReducer->resColModel->capacity); + int32_t rows = (int32_t)getFilledNumOfRes(pFillInfo, etime, pLocalReducer->resColModel->capacity); if (rows > 0) { // do interpo doFillResult(pSql, pLocalReducer, true); } diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 2f245ee513..33c8799624 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -61,7 +61,7 @@ static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) { if (v > INT64_MAX || v <= INT64_MIN) { errno = ERANGE; } else { - *value = v; + *value = (int64_t)v; } } @@ -426,7 +426,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ *str += index; if (sToken.type == TK_QUESTION) { - uint32_t offset = start - pDataBlocks->pData; + uint32_t offset = (uint32_t)(start - pDataBlocks->pData); if (tscAddParamToDataBlock(pDataBlocks, pSchema->type, (uint8_t)timePrec, pSchema->bytes, offset) != NULL) { continue; } @@ -450,7 +450,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ char delim = sToken.z[0]; int32_t cnt = 0; int32_t j = 0; - for (int32_t k = 1; k < sToken.n - 1; ++k) { + for (uint32_t k = 1; k < sToken.n - 1; ++k) { if (sToken.z[k] == delim || sToken.z[k] == '\\') { if (sToken.z[k + 1] == delim) { cnt++; @@ -504,7 +504,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ ptr += schema[i].bytes; } - rowSize = ptr - payload; + rowSize = (int32_t)(ptr - payload); } return rowSize; @@ -846,7 +846,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { if (TK_STRING == sToken.type) { strdequote(sToken.z); - sToken.n = strtrim(sToken.z); + sToken.n = (uint32_t)strtrim(sToken.z); } if (sToken.type == TK_RP) { @@ -972,7 +972,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { } } - int32_t len = cend - cstart + 1; + int32_t len = (int32_t)(cend - cstart + 1); if (cstart != NULL && createTable == true) { /* move the column list to start position of the next accessed points */ memmove(sql - len, cstart, len); @@ -1188,7 +1188,7 @@ int tsParseInsertSql(SSqlObj *pSql) { if (TK_STRING == sToken.type) { strdequote(sToken.z); - sToken.n = strtrim(sToken.z); + sToken.n = (uint32_t)strtrim(sToken.z); } if (sToken.type == TK_RP) { @@ -1426,7 +1426,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) { char *tokenBuf = calloc(1, 4096); - while ((readLen = getline(&line, &n, fp)) != -1) { + while ((readLen = taosGetline(&line, &n, fp)) != -1) { if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) { line[--readLen] = 0; } @@ -1471,7 +1471,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) { pParentSql->fp = pParentSql->fetchFp; // all data has been sent to vnode, call user function - int32_t v = (pParentSql->res.code != TSDB_CODE_SUCCESS) ? pParentSql->res.code : pParentSql->res.numOfRows; + int32_t v = (pParentSql->res.code != TSDB_CODE_SUCCESS) ? pParentSql->res.code : (int32_t)pParentSql->res.numOfRows; (*pParentSql->fp)(pParentSql->param, pParentSql, v); } } diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 363243b1d7..f48e7b7691 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -96,7 +96,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) { } tscDebug("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr); - int32_t sqlSize = TSDB_SLOW_QUERY_SQL_LEN + size; + int32_t sqlSize = (int32_t)(TSDB_SLOW_QUERY_SQL_LEN + size); char *sql = malloc(sqlSize); if (sql == NULL) { diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 4e0c238ac0..bc33aac174 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -161,7 +161,7 @@ static int32_t handlePassword(SSqlCmd* pCmd, SSQLToken* pPwd) { } strdequote(pPwd->z); - pPwd->n = strtrim(pPwd->z); // trim space before and after passwords + pPwd->n = (uint32_t)strtrim(pPwd->z); // trim space before and after passwords if (pPwd->n <= 0) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); @@ -1029,12 +1029,12 @@ static char* getAccountId(SSqlObj* pSql) { return pSql->pTscObj->acctId; } static void getCurrentDBName(SSqlObj* pSql, SSQLToken* pDBToken) { pDBToken->z = pSql->pTscObj->db; - pDBToken->n = strlen(pSql->pTscObj->db); + pDBToken->n = (uint32_t)strlen(pSql->pTscObj->db); } /* length limitation, strstr cannot be applied */ static bool hasSpecifyDB(SSQLToken* pTableName) { - for (int32_t i = 0; i < pTableName->n; ++i) { + for (uint32_t i = 0; i < pTableName->n; ++i) { if (pTableName->z[i] == TS_PATH_DELIMITER[0]) { return true; } @@ -1047,7 +1047,7 @@ int32_t setObjFullName(char* fullName, const char* account, SSQLToken* pDB, SSQL int32_t totalLen = 0; if (account != NULL) { - int32_t len = strlen(account); + int32_t len = (int32_t)strlen(account); strcpy(fullName, account); fullName[len] = TS_PATH_DELIMITER[0]; totalLen += (len + 1); @@ -1122,7 +1122,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel } for (int32_t i = 0; i < pSelection->nExpr; ++i) { - int32_t outputIndex = tscSqlExprNumOfExprs(pQueryInfo); + int32_t outputIndex = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); tSQLExprItem* pItem = &pSelection->a[i]; // project on all fields @@ -1205,7 +1205,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel char* c = tbufGetData(&bw, true); // set the serialized binary string as the parameter of arithmetic expression - addExprParams(pExpr, c, TSDB_DATA_TYPE_BINARY, len, index.tableIndex); + addExprParams(pExpr, c, TSDB_DATA_TYPE_BINARY, (int32_t)len, index.tableIndex); insertResultField(pQueryInfo, i, &columnList, sizeof(double), TSDB_DATA_TYPE_DOUBLE, pExpr->aliasName, pExpr); @@ -1332,7 +1332,7 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn ids.num = 0; } - insertResultField(pQueryInfo, startPos, &ids, pExpr->resBytes, pExpr->resType, pExpr->aliasName, pExpr); + insertResultField(pQueryInfo, startPos, &ids, pExpr->resBytes, (int8_t)pExpr->resType, pExpr->aliasName, pExpr); } void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId, @@ -1395,7 +1395,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t const char* msg0 = "invalid column name"; const char* msg1 = "tag for normal table query is not allowed"; - int32_t startPos = tscSqlExprNumOfExprs(pQueryInfo); + int32_t startPos = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); if (pItem->pNode->nSQLOptr == TK_ALL) { // project on all fields SColumnIndex index = COLUMN_INDEX_INITIALIZER; @@ -1486,7 +1486,7 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS tscColumnListInsert(pQueryInfo->colList, &index); SColumnList ids = getColumnList(1, pColIndex->tableIndex, pColIndex->columnIndex); - insertResultField(pQueryInfo, resColIdx, &ids, bytes, type, columnName, pExpr); + insertResultField(pQueryInfo, resColIdx, &ids, bytes, (int8_t)type, columnName, pExpr); return TSDB_CODE_SUCCESS; } @@ -1684,7 +1684,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col if (finalResult) { int32_t numOfOutput = tscNumOfFields(pQueryInfo); - insertResultField(pQueryInfo, numOfOutput, &ids, pExpr->resBytes, pExpr->resType, pExpr->aliasName, pExpr); + insertResultField(pQueryInfo, numOfOutput, &ids, pExpr->resBytes, (int32_t)pExpr->resType, pExpr->aliasName, pExpr); } else { for (int32_t i = 0; i < ids.num; ++i) { tscColumnListInsert(pQueryInfo->colList, &(ids.ids[i])); @@ -1981,7 +1981,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col int32_t ret = getResultDataInfo(s.type, s.bytes, TSDB_FUNC_TID_TAG, 0, &type, &bytes, &inter, 0, 0); assert(ret == TSDB_CODE_SUCCESS); - s.type = type; + s.type = (uint8_t)type; s.bytes = bytes; TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY); @@ -2014,7 +2014,7 @@ void getColumnName(tSQLExprItem* pItem, char* resultFieldName, int32_t nameLengt if (pItem->aliasName != NULL) { strncpy(resultFieldName, pItem->aliasName, nameLength); } else { - int32_t len = (pItem->pNode->operand.n < nameLength) ? pItem->pNode->operand.n : nameLength; + int32_t len = ((int32_t)pItem->pNode->operand.n < nameLength) ? (int32_t)pItem->pNode->operand.n : nameLength; strncpy(resultFieldName, pItem->pNode->operand.z, len); } } @@ -2383,7 +2383,7 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) { if ((functionId >= TSDB_FUNC_SUM && functionId <= TSDB_FUNC_TWA) || (functionId >= TSDB_FUNC_FIRST_DST && functionId <= TSDB_FUNC_LAST_DST) || (functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_AVG_IRATE)) { - if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, pExpr->param[0].i64Key, &type, &bytes, + if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, (int32_t)pExpr->param[0].i64Key, &type, &bytes, &interBytes, 0, true) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_SQL; } @@ -3144,7 +3144,7 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQuer return TSDB_CODE_TSC_INVALID_SQL; } - int32_t outputIndex = tscSqlExprNumOfExprs(pQueryInfo); + int32_t outputIndex = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); tSQLExprItem item = {.pNode = pExpr, .aliasName = NULL}; @@ -3633,7 +3633,7 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, num = j; char* name = extractDBName(pTableMetaInfo->name, db); - SSQLToken dbToken = {.type = TK_STRING, .z = name, .n = strlen(name)}; + SSQLToken dbToken = { .type = TK_STRING, .z = name, .n = (uint32_t)strlen(name) }; for (int32_t i = 0; i < num; ++i) { if (i >= 1) { @@ -3641,7 +3641,7 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, } char idBuf[TSDB_TABLE_ID_LEN] = {0}; - int32_t xlen = strlen(segments[i]); + int32_t xlen = (int32_t)strlen(segments[i]); SSQLToken t = {.z = segments[i], .n = xlen, .type = TK_STRING}; int32_t ret = setObjFullName(idBuf, account, &dbToken, &t, &xlen); @@ -4110,10 +4110,10 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery startPos = 0; if (numOfFillVal > size) { - numOfFillVal = size; + numOfFillVal = (int32_t)size; } } else { - numOfFillVal = (pFillToken->nExpr > size) ? size : pFillToken->nExpr; + numOfFillVal = (pFillToken->nExpr > (int32_t)size) ? (int32_t)size : pFillToken->nExpr; } int32_t j = 1; @@ -4776,7 +4776,7 @@ int32_t validateLocalConfig(tDCLSQL* pOptions) { } int32_t validateColumnName(char* name) { - bool ret = isKeyWord(name, strlen(name)); + bool ret = isKeyWord(name, (int32_t)strlen(name)); if (ret) { return TSDB_CODE_TSC_INVALID_SQL; } @@ -4790,7 +4790,7 @@ int32_t validateColumnName(char* name) { if (token.type == TK_STRING) { strdequote(token.z); - token.n = strtrim(token.z); + token.n = (uint32_t)strtrim(token.z); int32_t k = tSQLGetToken(token.z, &token.type); if (k != token.n) { @@ -4935,17 +4935,17 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCMCreateDbMsg* pMsg, SCreateDBInfo* if (pKeep != NULL) { switch (pKeep->nExpr) { case 1: - pMsg->daysToKeep = htonl(pKeep->a[0].pVar.i64Key); + pMsg->daysToKeep = htonl((int32_t)pKeep->a[0].pVar.i64Key); break; case 2: { - pMsg->daysToKeep = htonl(pKeep->a[0].pVar.i64Key); - pMsg->daysToKeep1 = htonl(pKeep->a[1].pVar.i64Key); + pMsg->daysToKeep = htonl((int32_t)pKeep->a[0].pVar.i64Key); + pMsg->daysToKeep1 = htonl((int32_t)pKeep->a[1].pVar.i64Key); break; } case 3: { - pMsg->daysToKeep = htonl(pKeep->a[0].pVar.i64Key); - pMsg->daysToKeep1 = htonl(pKeep->a[1].pVar.i64Key); - pMsg->daysToKeep2 = htonl(pKeep->a[2].pVar.i64Key); + pMsg->daysToKeep = htonl((int32_t)pKeep->a[0].pVar.i64Key); + pMsg->daysToKeep1 = htonl((int32_t)pKeep->a[1].pVar.i64Key); + pMsg->daysToKeep2 = htonl((int32_t)pKeep->a[2].pVar.i64Key); break; } default: { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } @@ -4984,7 +4984,7 @@ static void setCreateDBOption(SCMCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) { pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize); pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks); pMsg->daysPerFile = htonl(pCreateDb->daysPerFile); - pMsg->commitTime = htonl(pCreateDb->commitTime); + pMsg->commitTime = htonl((int32_t)pCreateDb->commitTime); pMsg->minRowsPerFileBlock = htonl(pCreateDb->minRowsPerBlock); pMsg->maxRowsPerFileBlock = htonl(pCreateDb->maxRowsPerBlock); pMsg->fsyncPeriod = htonl(pCreateDb->fsyncPeriod); @@ -5041,7 +5041,7 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, subClauseIndex); size_t size = taosArrayGetSize(pQueryInfo->exprList); - SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, size - 1); + SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, (int32_t)size - 1); if (pExpr->functionId != TSDB_FUNC_TAG) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex); @@ -5058,7 +5058,7 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau // NOTE: tag column does not add to source column list SColumnList ids = {0}; - insertResultField(pQueryInfo, size, &ids, bytes, type, name, pExpr); + insertResultField(pQueryInfo, (int32_t)size, &ids, bytes, (int8_t)type, name, pExpr); int32_t relIndex = index.columnIndex; @@ -5088,9 +5088,9 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) { SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pColIndex->colIndex); SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pColIndex->colIndex}; - tscAddSpecialColumnForSelect(pQueryInfo, size, TSDB_FUNC_PRJ, &colIndex, pSchema, TSDB_COL_NORMAL); + tscAddSpecialColumnForSelect(pQueryInfo, (int32_t)size, TSDB_FUNC_PRJ, &colIndex, pSchema, TSDB_COL_NORMAL); - SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, size); + SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, (int32_t)size); doLimitOutputNormalColOfGroupby(pInfo->pSqlExpr); pInfo->visible = false; } @@ -5118,7 +5118,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); if (pExpr->functionId != TSDB_FUNC_TAG_DUMMY && pExpr->functionId != TSDB_FUNC_TS_DUMMY) { SSchema* pColSchema = &pSchema[pExpr->colInfo.colIndex]; - getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, pExpr->param[0].i64Key, &pExpr->resType, + getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, (int32_t)pExpr->param[0].i64Key, &pExpr->resType, &pExpr->resBytes, &pExpr->interBytes, tagLength, true); } } @@ -5343,7 +5343,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo // NOTE: tag column does not add to source column list SColumnList ids = getColumnList(1, 0, pColIndex->colIndex); - insertResultField(pQueryInfo, size, &ids, bytes, type, name, pExpr); + insertResultField(pQueryInfo, (int32_t)size, &ids, bytes, (int8_t)type, name, pExpr); } else { // if this query is "group by" normal column, interval is not allowed if (pQueryInfo->intervalTime > 0) { @@ -5584,7 +5584,7 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate) { void tscPrintSelectClause(SSqlObj* pSql, int32_t subClauseIndex) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, subClauseIndex); - int32_t size = tscSqlExprNumOfExprs(pQueryInfo); + int32_t size = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); if (size == 0) { return; } @@ -6028,7 +6028,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { // in case of join query, time range is required. if (QUERY_IS_JOIN_QUERY(pQueryInfo->type)) { - int64_t timeRange = labs(pQueryInfo->window.skey - pQueryInfo->window.ekey); + int64_t timeRange = ABS(pQueryInfo->window.skey - pQueryInfo->window.ekey); if (timeRange == 0 && pQueryInfo->window.skey == 0) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); @@ -6055,7 +6055,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { } if (pQueryInfo->intervalTime > 0) { - int64_t timeRange = labs(pQueryInfo->window.skey - pQueryInfo->window.ekey); + int64_t timeRange = ABS(pQueryInfo->window.skey - pQueryInfo->window.ekey); // number of result is not greater than 10,000,000 if ((timeRange == 0) || (timeRange / pQueryInfo->intervalTime) > MAX_RETRIEVE_ROWS_IN_INTERVAL_QUERY) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); @@ -6111,7 +6111,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS SSqlExpr* p1 = taosArrayGetP(pExprInfo, i); if (strcmp((*pExpr)->pSchema->name, p1->aliasName) == 0) { - (*pExpr)->pSchema->type = p1->resType; + (*pExpr)->pSchema->type = (uint8_t)p1->resType; (*pExpr)->pSchema->bytes = p1->resBytes; break; } diff --git a/src/client/src/tscSchemaUtil.c b/src/client/src/tscSchemaUtil.c index 63607b7a86..244bb81164 100644 --- a/src/client/src/tscSchemaUtil.c +++ b/src/client/src/tscSchemaUtil.c @@ -208,7 +208,7 @@ char* tsGetTagsValue(STableMeta* pTableMeta) { } // todo refactor -__attribute__ ((unused))static FORCE_INLINE char* skipSegments(char* input, char delim, int32_t num) { +UNUSED_FUNC static FORCE_INLINE char* skipSegments(char* input, char delim, int32_t num) { for (int32_t i = 0; i < num; ++i) { while (*input != 0 && *input++ != delim) { }; @@ -216,7 +216,7 @@ __attribute__ ((unused))static FORCE_INLINE char* skipSegments(char* input, char return input; } -__attribute__ ((unused)) static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) { +UNUSED_FUNC static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) { size_t len = 0; while (*src != delimiter && *src != 0) { *dst++ = *src++; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index a040b3ef55..05ed8ccf7e 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -377,7 +377,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { } if (rpcMsg->code != TSDB_CODE_TSC_ACTION_IN_PROGRESS) { - rpcMsg->code = (pRes->code == TSDB_CODE_SUCCESS)? pRes->numOfRows: pRes->code; + rpcMsg->code = (pRes->code == TSDB_CODE_SUCCESS) ? (int32_t)pRes->numOfRows : pRes->code; bool shouldFree = tscShouldBeFreed(pSql); (*pSql->fp)(pSql->param, pSql, rpcMsg->code); @@ -569,10 +569,10 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) { const static int32_t MIN_QUERY_MSG_PKT_SIZE = TSDB_MAX_BYTES_PER_ROW * 5; SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, clauseIndex); - int32_t srcColListSize = taosArrayGetSize(pQueryInfo->colList) * sizeof(SColumnInfo); + int32_t srcColListSize = (int32_t)(taosArrayGetSize(pQueryInfo->colList) * sizeof(SColumnInfo)); size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo); - int32_t exprSize = sizeof(SSqlFuncMsg) * numOfExprs; + int32_t exprSize = (int32_t)(sizeof(SSqlFuncMsg) * numOfExprs); return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + exprSize + 4096; } @@ -612,7 +612,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char pMsg += sizeof(STableIdInfo); } else { // it is a subquery of the super table query, this EP info is acquired from vgroupInfo int32_t index = pTableMetaInfo->vgroupIndex; - int32_t numOfVgroups = taosArrayGetSize(pTableMetaInfo->pVgroupTables); + int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTableMetaInfo->pVgroupTables); assert(index >= 0 && index < numOfVgroups); tscDebug("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, numOfVgroups); @@ -623,7 +623,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char tscSetDnodeEpSet(pSql, &pTableIdList->vgInfo); pQueryMsg->head.vgId = htonl(pTableIdList->vgInfo.vgId); - int32_t numOfTables = taosArrayGetSize(pTableIdList->itemList); + int32_t numOfTables = (int32_t)taosArrayGetSize(pTableIdList->itemList); pQueryMsg->numOfTables = htonl(numOfTables); // set the number of tables // serialize each table id info @@ -675,7 +675,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SQueryTableMsg *pQueryMsg = (SQueryTableMsg *)pCmd->payload; - int32_t numOfTags = taosArrayGetSize(pTableMetaInfo->tagColList); + int32_t numOfTags = (int32_t)taosArrayGetSize(pTableMetaInfo->tagColList); if (pQueryInfo->order.order == TSDB_ORDER_ASC) { pQueryMsg->window.skey = htobe64(pQueryInfo->window.skey); @@ -690,7 +690,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pQueryMsg->fillType = htons(pQueryInfo->fillType); pQueryMsg->limit = htobe64(pQueryInfo->limit.limit); pQueryMsg->offset = htobe64(pQueryInfo->limit.offset); - pQueryMsg->numOfCols = htons(taosArrayGetSize(pQueryInfo->colList)); + pQueryMsg->numOfCols = htons((int16_t)taosArrayGetSize(pQueryInfo->colList)); pQueryMsg->intervalTime = htobe64(pQueryInfo->intervalTime); pQueryMsg->slidingTime = htobe64(pQueryInfo->slidingTime); pQueryMsg->slidingTimeUnit = pQueryInfo->slidingTimeUnit; @@ -700,7 +700,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pQueryMsg->queryType = htonl(pQueryInfo->type); size_t numOfOutput = tscSqlExprNumOfExprs(pQueryInfo); - pQueryMsg->numOfOutput = htons(numOfOutput); + pQueryMsg->numOfOutput = htons((int16_t)numOfOutput); // set column list ids size_t numOfCols = taosArrayGetSize(pQueryInfo->colList); @@ -872,7 +872,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } // compressed ts block - pQueryMsg->tsOffset = htonl(pMsg - pCmd->payload); + pQueryMsg->tsOffset = htonl((int32_t)(pMsg - pCmd->payload)); int32_t tsLen = 0; int32_t numOfBlocks = 0; @@ -905,7 +905,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pQueryMsg->tsOrder = htonl(pQueryInfo->tsBuf->tsOrder); } - int32_t msgLen = pMsg - pCmd->payload; + int32_t msgLen = (int32_t)(pMsg - pCmd->payload); tscDebug("%p msg built success,len:%d bytes", pSql, msgLen); pCmd->payloadLen = msgLen; @@ -1005,7 +1005,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SUserInfo *pUser = &pInfo->pDCLInfo->user; strncpy(pAlterMsg->user, pUser->user.z, pUser->user.n); - pAlterMsg->flag = pUser->type; + pAlterMsg->flag = (int8_t)pUser->type; if (pUser->type == TSDB_ALTER_USER_PRIVILEGES) { pAlterMsg->privilege = (char)pCmd->count; @@ -1280,7 +1280,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { tscFieldInfoClear(&pQueryInfo->fieldsInfo); - msgLen = pMsg - (char*)pCreateTableMsg; + msgLen = (int32_t)(pMsg - (char*)pCreateTableMsg); pCreateTableMsg->contLen = htonl(msgLen); pCmd->payloadLen = msgLen; pCmd->msgType = TSDB_MSG_TYPE_CM_CREATE_TABLE; @@ -1333,7 +1333,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { memcpy(pMsg, pAlterInfo->tagData.data, pAlterInfo->tagData.dataLen); pMsg += pAlterInfo->tagData.dataLen; - msgLen = pMsg - (char*)pAlterTableMsg; + msgLen = (int32_t)(pMsg - (char*)pAlterTableMsg); pCmd->payloadLen = msgLen; pCmd->msgType = TSDB_MSG_TYPE_CM_ALTER_TABLE; @@ -1534,12 +1534,12 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pMsg += len; } - pCmd->payloadLen = pMsg - (char*)pInfoMsg; + pCmd->payloadLen = (int32_t)(pMsg - (char*)pInfoMsg); pCmd->msgType = TSDB_MSG_TYPE_CM_TABLE_META; taosTFree(tmpData); - assert(msgLen + minMsgSize() <= pCmd->allocSize); + assert(msgLen + minMsgSize() <= (int32_t)pCmd->allocSize); return TSDB_CODE_SUCCESS; } @@ -1631,7 +1631,7 @@ int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_VGROUP; - pCmd->payloadLen = (pMsg - pCmd->payload); + pCmd->payloadLen = (int32_t)(pMsg - pCmd->payload); return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 10720874e2..3e5280401f 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -85,7 +85,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con taosEncryptPass((uint8_t *)pass, strlen(pass), pObj->pass); if (db) { - int32_t len = strlen(db); + int32_t len = (int32_t)strlen(db); /* db name is too long */ if (len >= TSDB_DB_NAME_LEN) { terrno = TSDB_CODE_TSC_INVALID_DB_LENGTH; @@ -240,7 +240,7 @@ TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) { return NULL; } - int32_t sqlLen = strlen(sqlstr); + int32_t sqlLen = (int32_t)strlen(sqlstr); if (sqlLen > tsMaxSQLStringLen) { tscError("sql string exceeds max length:%d", tsMaxSQLStringLen); terrno = TSDB_CODE_TSC_INVALID_SQL; @@ -269,7 +269,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen) { return NULL; } - if (sqlLen > tsMaxSQLStringLen) { + if (sqlLen > (uint32_t)tsMaxSQLStringLen) { tscError("sql string exceeds max length:%d", tsMaxSQLStringLen); terrno = TSDB_CODE_TSC_INVALID_SQL; return NULL; @@ -328,7 +328,7 @@ int taos_affected_rows(TAOS_RES *tres) { SSqlObj* pSql = (SSqlObj*) tres; if (pSql == NULL || pSql->signature != pSql) return 0; - return (pSql->res.numOfRows); + return (int)(pSql->res.numOfRows); } TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { @@ -363,7 +363,7 @@ int taos_retrieve(TAOS_RES *res) { } tscProcessSql(pSql); - return pRes->numOfRows; + return (int)pRes->numOfRows; } int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) { @@ -404,7 +404,7 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) { *rows = pRes->tsrow; - return (pQueryInfo->order.order == TSDB_ORDER_DESC) ? pRes->numOfRows : -pRes->numOfRows; + return (int)((pQueryInfo->order.order == TSDB_ORDER_DESC) ? pRes->numOfRows : -pRes->numOfRows); } TAOS_ROW taos_fetch_row(TAOS_RES *res) { @@ -749,7 +749,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) { tscDebug("%p Valid SQL: %s pObj:%p", pSql, sql, pObj); - int32_t sqlLen = strlen(sql); + int32_t sqlLen = (int32_t)strlen(sql); if (sqlLen > tsMaxSQLStringLen) { tscError("%p sql too long", pSql); pRes->code = TSDB_CODE_TSC_INVALID_SQL; @@ -822,11 +822,11 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t } memcpy(tblName, str, nextStr - str); - int32_t len = nextStr - str; + int32_t len = (int32_t)(nextStr - str); tblName[len] = '\0'; str = nextStr + 1; - len = strtrim(tblName); + len = (int32_t)strtrim(tblName); SSQLToken sToken = {.n = len, .type = TK_ID, .z = tblName}; tSQLGetToken(tblName, &sToken.type); @@ -892,7 +892,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { assert(pSql->fp == NULL); tscDebug("%p tableNameList: %s pObj:%p", pSql, tableNameList, pObj); - int32_t tblListLen = strlen(tableNameList); + int32_t tblListLen = (int32_t)strlen(tableNameList); if (tblListLen > MAX_TABLE_NAME_LENGTH) { tscError("%p tableNameList too long, length:%d, maximum allowed:%d", pSql, tblListLen, MAX_TABLE_NAME_LENGTH); pRes->code = TSDB_CODE_TSC_INVALID_SQL; diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 6235e0aeba..d0591de011 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -47,14 +47,14 @@ static bool isProjectStream(SQueryInfo* pQueryInfo) { } static int64_t tscGetRetryDelayTime(int64_t slidingTime, int16_t prec) { - float retryRangeFactor = 0.3; + float retryRangeFactor = 0.3f; // change to ms if (prec == TSDB_TIME_PRECISION_MICRO) { slidingTime = slidingTime / 1000; } - int64_t retryDelta = (int64_t)tsStreamCompRetryDelay * retryRangeFactor; + int64_t retryDelta = (int64_t)(tsStreamCompRetryDelay * retryRangeFactor); retryDelta = ((rand() % retryDelta) + tsStreamCompRetryDelay) * 1000L; if (slidingTime < retryDelta) { @@ -299,7 +299,7 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer) pSql->cmd.command = TSDB_SQL_SELECT; // start timer for next computing - taosTmrReset(tscProcessStreamTimer, timer, pStream, tscTmr, &pStream->pTimer); + taosTmrReset(tscProcessStreamTimer, (int32_t)timer, pStream, tscTmr, &pStream->pTimer); } static int64_t getLaunchTimeDelay(const SSqlStream* pStream) { @@ -314,7 +314,7 @@ static int64_t getLaunchTimeDelay(const SSqlStream* pStream) { int64_t remainTimeWindow = pStream->slidingTime - delayDelta; if (maxDelay > remainTimeWindow) { - maxDelay = (remainTimeWindow / 1.5); + maxDelay = (int64_t)(remainTimeWindow / 1.5f); } int64_t currentDelay = (rand() % maxDelay); // a random number @@ -505,7 +505,7 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) { int64_t starttime = tscGetLaunchTimestamp(pStream); pCmd->command = TSDB_SQL_SELECT; - taosTmrReset(tscProcessStreamTimer, starttime, pStream, tscTmr, &pStream->pTimer); + taosTmrReset(tscProcessStreamTimer, (int32_t)starttime, pStream, tscTmr, &pStream->pTimer); tscDebug("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql, pStream, pTableMetaInfo->name, pStream->interval, pStream->slidingTime, starttime, pSql->sqlstr); diff --git a/src/os/inc/osMath.h b/src/os/inc/osMath.h index 168f6607f0..99c2d4bca2 100644 --- a/src/os/inc/osMath.h +++ b/src/os/inc/osMath.h @@ -21,6 +21,7 @@ extern "C" { #endif #define POW2(x) ((x) * (x)) +#define ABS(x) ((x) > 0 ? (x) : (-x)) #ifndef TAOS_OS_FUNC_MATH #define SWAP(a, b, c) \ diff --git a/src/os/inc/osWindows.h b/src/os/inc/osWindows.h index 933e927d14..bf07035ef8 100644 --- a/src/os/inc/osWindows.h +++ b/src/os/inc/osWindows.h @@ -90,11 +90,9 @@ extern "C" { #define taosWriteSocket(fd, buf, len) send((SOCKET)fd, buf, len, 0) #define taosReadSocket(fd, buf, len) recv((SOCKET)fd, buf, len, 0) #define taosCloseSocket(fd) closesocket((SOCKET)fd) - typedef SOCKET eventfd_t; #define eventfd(a, b) -1 - #define TAOS_OS_FUNC_STRING_WCHAR int twcslen(const wchar_t *wcs); #define TAOS_OS_FUNC_STRING_GETLINE diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c index e65d793dc9..e65c515100 100644 --- a/src/query/src/qFill.c +++ b/src/query/src/qFill.c @@ -155,14 +155,14 @@ int64_t getFilledNumOfRes(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set. TSKEY lastKey = tsList[pFillInfo->numOfRows - 1]; - numOfRes = (int64_t)(labs(lastKey - pFillInfo->start) / pFillInfo->slidingTime) + 1; + numOfRes = (int64_t)(ABS(lastKey - pFillInfo->start) / pFillInfo->slidingTime) + 1; assert(numOfRes >= numOfRows); } else { // reach the end of data if ((ekey1 < pFillInfo->start && FILL_IS_ASC_FILL(pFillInfo)) || (ekey1 > pFillInfo->start && !FILL_IS_ASC_FILL(pFillInfo))) { return 0; } else { // the numOfRes rows are all filled with specified policy - numOfRes = (labs(ekey1 - pFillInfo->start) / pFillInfo->slidingTime) + 1; + numOfRes = (ABS(ekey1 - pFillInfo->start) / pFillInfo->slidingTime) + 1; } } -- GitLab