diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c index 5955515bbd58f2f5a5b1d520c1c1d258615b7997..8436777ddfd1563c4a9d7db131a256de65896022 100644 --- a/src/client/src/tscLocalMerge.c +++ b/src/client/src/tscLocalMerge.c @@ -914,8 +914,8 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO if (pQueryInfo->limit.limit >= 0 && pRes->numOfRowsGroup > pQueryInfo->limit.limit) { /* impose the limitation of output rows on the final result */ - int32_t prevSize = pFinalDataPage->num; - int32_t overflow = pRes->numOfRowsGroup - pQueryInfo->limit.limit; + int32_t prevSize = (int32_t)pFinalDataPage->num; + int32_t overflow = (int32_t)(pRes->numOfRowsGroup - pQueryInfo->limit.limit); assert(overflow < pRes->numOfRows); pRes->numOfRowsGroup = pQueryInfo->limit.limit; @@ -984,7 +984,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO if (pRes->numOfRows > 0) { if (pQueryInfo->limit.limit >= 0 && pRes->numOfRows > pQueryInfo->limit.limit) { - int32_t overflow = pRes->numOfRows - pQueryInfo->limit.limit; + int32_t overflow = (int32_t)(pRes->numOfRows - pQueryInfo->limit.limit); pRes->numOfRows -= overflow; pFinalDataPage->num -= overflow; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 1a97a9a997920d7afc3be0e40b0fdd985002c403..8e398fbf1fe63207254caed0f1918761373bce8f 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1182,7 +1182,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t 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, exprIndex, &columnList, sizeof(double), TSDB_DATA_TYPE_DOUBLE, pExpr->aliasName, pExpr); @@ -1237,7 +1237,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 @@ -3144,7 +3144,7 @@ static int32_t arithmeticExprToString(tSQLExpr* pExpr, char** str) { int32_t code = doArithmeticExprToString(pExpr, str); if (code == TSDB_CODE_SUCCESS) { // remove out the parenthesis - int32_t len = strlen(start); + int32_t len = (int32_t)strlen(start); memmove(start, start + 1, len - 2); start[len - 2] = 0; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 18859a770faac24680f1f8a8b2b44e5e9fd9ede9..2c48c76b1ccdca0f78fa0ba627773eff9423d353 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -263,7 +263,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen) { } TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) { - return taos_query_c(taos, sqlstr, strlen(sqlstr)); + return taos_query_c(taos, sqlstr, (uint32_t)strlen(sqlstr)); } int taos_result_precision(TAOS_RES *res) { diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 98f07933f73a53dbc33b51cb293c27a1fd18b9d1..75644c355cd15385b96b072c2b90ecc58d395d73 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1027,7 +1027,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - int32_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo); + int32_t numOfExprs = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); pRes->pColumnIndex = calloc(1, sizeof(SColumnIndex) * numOfExprs); for (int32_t i = 0; i < numOfExprs; ++i) { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index e4dcf852ec8e7bf9c3b46732ad31821b4fee2232..60723676df295ce38cc4f6e60fab47ccaab5f1c0 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1683,7 +1683,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm // current sql function is not direct output result, so create a dummy output field static void doSetNewFieldInfo(SQueryInfo* pNewQueryInfo, SSqlExpr* pExpr) { - TAOS_FIELD f = {.type = pExpr->resType, .bytes = pExpr->resBytes}; + TAOS_FIELD f = {.type = (uint8_t)pExpr->resType, .bytes = pExpr->resBytes}; tstrncpy(f.name, pExpr->aliasName, sizeof(f.name)); SFieldSupInfo* pInfo1 = tscFieldInfoAppend(&pNewQueryInfo->fieldsInfo, &f); @@ -1693,7 +1693,7 @@ static void doSetNewFieldInfo(SQueryInfo* pNewQueryInfo, SSqlExpr* pExpr) { } static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* pNewQueryInfo, int64_t uid) { - int32_t numOfOutput = tscSqlExprNumOfExprs(pNewQueryInfo); + int32_t numOfOutput = (int32_t)tscSqlExprNumOfExprs(pNewQueryInfo); if (numOfOutput == 0) { return; } @@ -2044,7 +2044,7 @@ bool hasMoreVnodesToTry(SSqlObj* pSql) { int32_t numOfVgroups = pTableMetaInfo->vgroupList->numOfVgroups; if (pTableMetaInfo->pVgroupTables != NULL) { - numOfVgroups = taosArrayGetSize(pTableMetaInfo->pVgroupTables); + numOfVgroups = (int32_t)taosArrayGetSize(pTableMetaInfo->pVgroupTables); } return tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && @@ -2249,6 +2249,6 @@ bool tscSetSqlOwner(SSqlObj* pSql) { } void tscClearSqlOwner(SSqlObj* pSql) { - assert(pSql->owner != 0); + assert(taosCheckPthreadValid(pSql->owner)); atomic_store_64(&pSql->owner, 0); } \ No newline at end of file diff --git a/src/os/inc/osSemphone.h b/src/os/inc/osSemphone.h index c4fc98988a98b751ce0ec4cd49e90f2d013d40dc..fd88d2d7981a4e0f9dc397e73bf242eb7e059cf7 100644 --- a/src/os/inc/osSemphone.h +++ b/src/os/inc/osSemphone.h @@ -32,6 +32,7 @@ extern "C" { bool taosCheckPthreadValid(pthread_t thread); int64_t taosGetPthreadId(); void taosResetPthread(pthread_t *thread); +bool taosComparePthread(pthread_t first, pthread_t second); #ifdef __cplusplus } diff --git a/src/os/src/detail/osSemphone.c b/src/os/src/detail/osSemphone.c index 1f1ef268c61c86e11ef67fa588fc0b2f5bffebfa..74f8859029f95c67a2f298a0dbfa983978b4b78f 100644 --- a/src/os/src/detail/osSemphone.c +++ b/src/os/src/detail/osSemphone.c @@ -21,5 +21,6 @@ bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; } int64_t taosGetPthreadId() { return (int64_t)pthread_self(); } void taosResetPthread(pthread_t *thread) { *thread = 0; } +bool taosComparePthread(pthread_t first, pthread_t second) { return first == second; } #endif \ No newline at end of file diff --git a/src/os/src/windows/w64Semphone.c b/src/os/src/windows/w64Semphone.c index 7ed6228228afe555ad970b5daf7cb1e2f2b21554..ded7e418430be2674b82761771579c7b84a65007 100644 --- a/src/os/src/windows/w64Semphone.c +++ b/src/os/src/windows/w64Semphone.c @@ -32,3 +32,7 @@ int64_t taosGetPthreadId() { return (int64_t)pthread_self(); #endif } + +bool taosComparePthread(pthread_t first, pthread_t second) { + return first.p == second.p; +} diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index c7026b45c6260ec2e8b68a5bc2226fc08617932f..b5487561b29f1b61465a47c1a13cd17cf40acd73 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -186,7 +186,7 @@ enum { typedef struct SQInfo { void* signature; int32_t code; // error code to returned to client - pthread_t owner; // if it is in execution + int64_t owner; // if it is in execution void* tsdb; int32_t vgId; STableGroupInfo tableGroupInfo; // table id list < only includes the STable list> diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index bf9e8374bb6f427d0302ead947685c8bacf4761a..34700a33f3e7e393dbec5e09713b1879c3c304ac 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -130,8 +130,8 @@ static void finalizeQueryResult(SQueryRuntimeEnv *pRuntimeEnv); (tw)->ekey = (tw)->skey + ((_q)->intervalTime - 1); \ } while (0) -#define SET_STABLE_QUERY_OVER(_q) ((_q)->tableIndex = (_q)->tableqinfoGroupInfo.numOfTables) -#define IS_STASBLE_QUERY_OVER(_q) ((_q)->tableIndex >= (_q)->tableqinfoGroupInfo.numOfTables) +#define SET_STABLE_QUERY_OVER(_q) ((_q)->tableIndex = (int32_t)((_q)->tableqinfoGroupInfo.numOfTables)) +#define IS_STASBLE_QUERY_OVER(_q) ((_q)->tableIndex >= (int32_t)((_q)->tableqinfoGroupInfo.numOfTables)) // todo move to utility static int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *group); @@ -405,9 +405,9 @@ static SWindowResult *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWin if (pWindowResInfo->size >= pWindowResInfo->capacity) { int64_t newCap = 0; if (pWindowResInfo->capacity > 10000) { - newCap = pWindowResInfo->capacity * 1.25; + newCap = (int64_t)(pWindowResInfo->capacity * 1.25); } else { - newCap = pWindowResInfo->capacity * 1.5; + newCap = (int64_t)(pWindowResInfo->capacity * 1.5); } char *t = realloc(pWindowResInfo->pResult, newCap * sizeof(SWindowResult)); @@ -2725,7 +2725,7 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) { memcpy(pDest + offset * bytes, pData->data + pRuntimeEnv->offset[i] * pData->num, bytes * pData->num); } - offset += pData->num; + offset += (int32_t)pData->num; } assert(pQuery->rec.rows == 0); @@ -3051,7 +3051,7 @@ void disableFuncInReverseScan(SQInfo *pQInfo) { static void setupQueryRangeForReverseScan(SQInfo* pQInfo) { SQuery* pQuery = pQInfo->runtimeEnv.pQuery; - int32_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo); + int32_t numOfGroups = (int32_t)(GET_NUM_OF_TABLEGROUP(pQInfo)); for(int32_t i = 0; i < numOfGroups; ++i) { SArray *group = GET_TABLEGROUP(pQInfo, i); @@ -6378,7 +6378,7 @@ static bool doBuildResCheck(SQInfo* pQInfo) { pthread_mutex_unlock(&pQInfo->lock); // clear qhandle owner - assert(pQInfo->owner == pthread_self()); + assert(pQInfo->owner == taosGetPthreadId()); pQInfo->owner = 0; return buildRes; @@ -6387,7 +6387,7 @@ static bool doBuildResCheck(SQInfo* pQInfo) { bool qTableQuery(qinfo_t qinfo) { SQInfo *pQInfo = (SQInfo *)qinfo; assert(pQInfo && pQInfo->signature == pQInfo); - int64_t threadId = pthread_self(); + int64_t threadId = taosGetPthreadId(); int64_t curOwner = 0; if ((curOwner = atomic_val_compare_exchange_64(&pQInfo->owner, 0, threadId)) != 0) { @@ -6549,7 +6549,7 @@ int32_t qKillQuery(qinfo_t qinfo) { // Wait for the query executing thread being stopped/ // Once the query is stopped, the owner of qHandle will be cleared immediately. - while(pQInfo->owner != 0) { + while (pQInfo->owner != 0) { taosMsleep(100); } diff --git a/src/query/src/qResultbuf.c b/src/query/src/qResultbuf.c index 7c40c33933651727e71d7636446e9df8a360bbfa..51ff892b3351eb2a6d077910be1a2cef4420728a 100644 --- a/src/query/src/qResultbuf.c +++ b/src/query/src/qResultbuf.c @@ -6,7 +6,7 @@ #include "queryLog.h" #include "taoserror.h" -#define GET_DATA_PAYLOAD(_p) ((_p)->pData + POINTER_BYTES) +#define GET_DATA_PAYLOAD(_p) ((char *)(_p)->pData + POINTER_BYTES) #define NO_IN_MEM_AVAILABLE_PAGES(_b) (listNEles((_b)->lruList) >= (_b)->inMemPages) int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t rowSize, int32_t pagesize, @@ -248,7 +248,7 @@ static char* evicOneDataPage(SDiskbasedResultBuf* pResultBuf) { int32_t prev = pResultBuf->inMemPages; // increase by 50% of previous mem pages - pResultBuf->inMemPages = pResultBuf->inMemPages * 1.5f; + pResultBuf->inMemPages = (int32_t)(pResultBuf->inMemPages * 1.5f); qWarn("%p in memory buf page not sufficient, expand from %d to %d, page size:%d", pResultBuf, prev, pResultBuf->inMemPages, pResultBuf->pageSize); @@ -313,7 +313,7 @@ tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32 ((void**)pi->pData)[0] = pi; pi->used = true; - return GET_DATA_PAYLOAD(pi); + return (void *)(GET_DATA_PAYLOAD(pi)); } tFilePage* getResBufPage(SDiskbasedResultBuf* pResultBuf, int32_t id) { @@ -327,7 +327,7 @@ tFilePage* getResBufPage(SDiskbasedResultBuf* pResultBuf, int32_t id) { // no need to update the LRU list if only one page exists if (pResultBuf->numOfPages == 1) { (*pi)->used = true; - return GET_DATA_PAYLOAD(*pi); + return (void *)(GET_DATA_PAYLOAD(*pi)); } SPageInfo** pInfo = (SPageInfo**) ((*pi)->pn->data); @@ -336,7 +336,7 @@ tFilePage* getResBufPage(SDiskbasedResultBuf* pResultBuf, int32_t id) { lruListMoveToFront(pResultBuf->lruList, (*pi)); (*pi)->used = true; - return GET_DATA_PAYLOAD(*pi); + return (void *)(GET_DATA_PAYLOAD(*pi)); } else { // not in memory assert((*pi)->pData == NULL && (*pi)->pn == NULL && (*pi)->info.length >= 0 && (*pi)->info.offset >= 0); @@ -358,7 +358,7 @@ tFilePage* getResBufPage(SDiskbasedResultBuf* pResultBuf, int32_t id) { (*pi)->used = true; loadPageFromDisk(pResultBuf, *pi); - return GET_DATA_PAYLOAD(*pi); + return (void *)(GET_DATA_PAYLOAD(*pi)); } } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 61c1293dd567314e7b015486cb778eb1ee53fc5e..4edbadc72559cbf1c0149377e5238b8c5e878411 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -245,9 +245,9 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab STableCheckInfo info = { .lastKey = pKeyInfo->lastKey, - .tableId = ((STable*)(pKeyInfo->pTable))->tableId, .pTableObj = pKeyInfo->pTable, }; + info.tableId = ((STable*)(pKeyInfo->pTable))->tableId; assert(info.pTableObj != NULL && (info.pTableObj->type == TSDB_NORMAL_TABLE || info.pTableObj->type == TSDB_CHILD_TABLE || info.pTableObj->type == TSDB_STREAM_TABLE)); diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 8df3e3d4d3777ca97deda00ce1f00548167111ac..714f36f1cb750776226ecfe6cc26b25837b88428 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -167,7 +167,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp void *p = calloc(pHashObj->capacity, sizeof(SHashEntry)); for (int32_t i = 0; i < pHashObj->capacity; ++i) { - pHashObj->hashList[i] = p + i * sizeof(SHashEntry); + pHashObj->hashList[i] = (void *)((char *)p + i * sizeof(SHashEntry)); } taosArrayPush(pHashObj->pMemBlock, &p); @@ -179,7 +179,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp size_t taosHashGetSize(const SHashObj *pHashObj) { return (pHashObj == NULL) ? 0 : pHashObj->size; } int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *data, size_t size) { - uint32_t hashVal = (*pHashObj->hashFp)(key, keyLen); + uint32_t hashVal = (*pHashObj->hashFp)(key, (uint32_t)keyLen); SHashNode *pNewNode = doCreateHashNode(key, keyLen, data, size, hashVal); if (pNewNode == NULL) { return -1; @@ -263,7 +263,7 @@ void *taosHashGetCB(SHashObj *pHashObj, const void *key, size_t keyLen, void (*f return NULL; } - uint32_t hashVal = (*pHashObj->hashFp)(key, keyLen); + uint32_t hashVal = (*pHashObj->hashFp)(key, (uint32_t)keyLen); // only add the read lock to disable the resize process __rd_lock(&pHashObj->lock, pHashObj->type); @@ -317,7 +317,7 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe return -1; } - uint32_t hashVal = (*pHashObj->hashFp)(key, keyLen); + uint32_t hashVal = (*pHashObj->hashFp)(key, (uint32_t)keyLen); // disable the resize process __rd_lock(&pHashObj->lock, pHashObj->type); @@ -418,7 +418,7 @@ int32_t taosHashCondTraverse(SHashObj *pHashObj, bool (*fp)(void *, void *), voi // disable the resize process __rd_lock(&pHashObj->lock, pHashObj->type); - int32_t numOfEntries = pHashObj->capacity; + int32_t numOfEntries = (int32_t)pHashObj->capacity; for (int32_t i = 0; i < numOfEntries; ++i) { SHashEntry *pEntry = pHashObj->hashList[i]; if (pEntry->num == 0) { @@ -649,7 +649,7 @@ void taosHashTableResize(SHashObj *pHashObj) { SHashNode *pNode = NULL; SHashNode *pNext = NULL; - int32_t newSize = pHashObj->capacity << 1u; + int32_t newSize = (int32_t)(pHashObj->capacity << 1u); if (newSize > HASH_MAX_CAPACITY) { // uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached", // pHashObj->capacity, HASH_MAX_CAPACITY); @@ -669,7 +669,7 @@ void taosHashTableResize(SHashObj *pHashObj) { void * p = calloc(inc, sizeof(SHashEntry)); for (int32_t i = 0; i < inc; ++i) { - pHashObj->hashList[i + pHashObj->capacity] = p + i * sizeof(SHashEntry); + pHashObj->hashList[i + pHashObj->capacity] = (void *)((char *)p + i * sizeof(SHashEntry)); } taosArrayPush(pHashObj->pMemBlock, &p); @@ -762,7 +762,7 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s pNewNode->key = pNewNode->data + dsize; memcpy(pNewNode->key, key, keyLen); - pNewNode->keyLen = keyLen; + pNewNode->keyLen = (uint32_t)keyLen; pNewNode->hashVal = hashVal; return pNewNode; } diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 54a4b289b76ceb68b2e0213e67d69a7ec1f92271..fee7ed3c8b923599a75be13acc44af68329636b2 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -95,7 +95,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo } pCacheObj->totalSize -= pNode->size; - int32_t size = taosHashGetSize(pCacheObj->pHashTable); + int32_t size = (int32_t)taosHashGetSize(pCacheObj->pHashTable); assert(size > 0); uDebug("cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, num:%d size:%" PRId64 "bytes", @@ -388,7 +388,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { } else { // ref == 0 atomic_sub_fetch_64(&pCacheObj->totalSize, pNode->size); - int32_t size = taosHashGetSize(pCacheObj->pHashTable); + int32_t size = (int32_t)taosHashGetSize(pCacheObj->pHashTable); uDebug("cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, num:%d size:%" PRId64 "bytes", pCacheObj->name, pNode->key, pNode->data, pNode->size, size, pCacheObj->totalSize); @@ -560,7 +560,7 @@ bool travHashTableFn(void* param, void* data) { SCacheObj* pCacheObj= ps->pCacheObj; SCacheDataNode* pNode = *(SCacheDataNode **) data; - if (pNode->expireTime < ps->time && T_REF_VAL_GET(pNode) <= 0) { + if ((int64_t)pNode->expireTime < ps->time && T_REF_VAL_GET(pNode) <= 0) { taosCacheReleaseNode(pCacheObj, pNode); // this node should be remove from hash table