diff --git a/cmake/cmake.define b/cmake/cmake.define index 9c2d5dc04c7471c4d4de54c4f18c6b007e41a40b..298d102b8738de5b437c5cf7adad86879c74b7a0 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -36,8 +36,8 @@ IF (TD_WINDOWS) ENDIF () ELSE () - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -g3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -g3") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3") MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}") IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64") diff --git a/cmake/cmake.platform b/cmake/cmake.platform index dfb79c0fae948686859a8251ef7e50b1ccbea7b6..0312f92a5b4116cad03d4bb9c2e7556d7a35deb2 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -42,7 +42,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin SET(TD_DARWIN TRUE) SET(OSTYPE "macOS") - ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare -Wno-return-type") + ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare") MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.") IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 4bbe42bc50926394fd1f57a99a285e5c0aec7e36..3afdcfba8e77b7747e8df3a2b2a8a7dfab1e45e3 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -113,39 +113,39 @@ static FORCE_INLINE void colDataAppendNULL(SColumnInfoData* pColumnInfoData, uin pColumnInfoData->hasNull = true; } -static FORCE_INLINE int32_t colDataAppendInt8(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int8_t* v) { +static FORCE_INLINE void colDataAppendInt8(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int8_t* v) { ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_TINYINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_UTINYINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_BOOL); char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; *(int8_t*)p = *(int8_t*)v; } -static FORCE_INLINE int32_t colDataAppendInt16(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int16_t* v) { +static FORCE_INLINE void colDataAppendInt16(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int16_t* v) { ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_SMALLINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_USMALLINT); char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; *(int16_t*)p = *(int16_t*)v; } -static FORCE_INLINE int32_t colDataAppendInt32(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int32_t* v) { +static FORCE_INLINE void colDataAppendInt32(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int32_t* v) { ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_INT || pColumnInfoData->info.type == TSDB_DATA_TYPE_UINT); char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; *(int32_t*)p = *(int32_t*)v; } -static FORCE_INLINE int32_t colDataAppendInt64(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int64_t* v) { +static FORCE_INLINE void colDataAppendInt64(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int64_t* v) { int32_t type = pColumnInfoData->info.type; ASSERT(type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_UBIGINT || type == TSDB_DATA_TYPE_TIMESTAMP); char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; *(int64_t*)p = *(int64_t*)v; } -static FORCE_INLINE int32_t colDataAppendFloat(SColumnInfoData* pColumnInfoData, uint32_t currentRow, float* v) { +static FORCE_INLINE void colDataAppendFloat(SColumnInfoData* pColumnInfoData, uint32_t currentRow, float* v) { ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_FLOAT); char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; *(float*)p = *(float*)v; } -static FORCE_INLINE int32_t colDataAppendDouble(SColumnInfoData* pColumnInfoData, uint32_t currentRow, double* v) { +static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, uint32_t currentRow, double* v) { ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_DOUBLE); char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow; *(double*)p = *(double*)v; diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index f22051f1c6a2f6b6eb4211d0a339e7ca5d78397e..67cc597fdf670c8d1c8b3cd578d6f4ef86cbf9a2 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -17,6 +17,7 @@ #include "tdatablock.h" #include "tcompare.h" #include "tglobal.h" +#include "tlog.h" int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) { pEp->port = 0; @@ -424,7 +425,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd } size += sizeof(pColInfoData->varmeta.offset[0]); - } else { + } else { // this block is unreached, because hasVarCol = true size += pColInfoData->info.bytes; if (((j - startIndex) & 0x07) == 0) { @@ -665,23 +666,13 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) { void* left1 = colDataGetData(pColInfoData, left); void* right1 = colDataGetData(pColInfoData, right); - switch (pColInfoData->info.type) { - case TSDB_DATA_TYPE_INT: { - int32_t leftx = *(int32_t*)left1; - int32_t rightx = *(int32_t*)right1; + __compar_fn_t fn = getKeyComparFunc(pColInfoData->info.type, pOrder->order); - if (leftx == rightx) { - break; - } else { - if (pOrder->order == TSDB_ORDER_ASC) { - return (leftx < rightx) ? -1 : 1; - } else { - return (leftx < rightx) ? 1 : -1; - } - } - } - default: - assert(0); + int ret = fn(left1, right1); + if (ret == 0) { + continue; + } else { + return ret; } } @@ -834,17 +825,14 @@ static void copyBackToBlock(SSDataBlock* pDataBlock, SColumnInfoData* pCols) { if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { taosMemoryFreeClear(pColInfoData->varmeta.offset); - pColInfoData->varmeta = pCols[i].varmeta; } else { taosMemoryFreeClear(pColInfoData->nullbitmap); - pColInfoData->nullbitmap = pCols[i].nullbitmap; } taosMemoryFreeClear(pColInfoData->pData); - pColInfoData->pData = pCols[i].pData; } - taosMemoryFreeClear(pCols); + colDataDestroy(pCols); } static int32_t* createTupleIndex(size_t rows) { @@ -862,33 +850,6 @@ static int32_t* createTupleIndex(size_t rows) { static void destroyTupleIndex(int32_t* index) { taosMemoryFreeClear(index); } -static __compar_fn_t getComparFn(int32_t type, int32_t order) { - switch (type) { - case TSDB_DATA_TYPE_TINYINT: - return order == TSDB_ORDER_ASC ? compareInt8Val : compareInt8ValDesc; - case TSDB_DATA_TYPE_SMALLINT: - return order == TSDB_ORDER_ASC ? compareInt16Val : compareInt16ValDesc; - case TSDB_DATA_TYPE_INT: - return order == TSDB_ORDER_ASC ? compareInt32Val : compareInt32ValDesc; - case TSDB_DATA_TYPE_BIGINT: - return order == TSDB_ORDER_ASC ? compareInt64Val : compareInt64ValDesc; - case TSDB_DATA_TYPE_FLOAT: - return order == TSDB_ORDER_ASC ? compareFloatVal : compareFloatValDesc; - case TSDB_DATA_TYPE_DOUBLE: - return order == TSDB_ORDER_ASC ? compareDoubleVal : compareDoubleValDesc; - case TSDB_DATA_TYPE_UTINYINT: - return order == TSDB_ORDER_ASC ? compareUint8Val : compareUint8ValDesc; - case TSDB_DATA_TYPE_USMALLINT: - return order == TSDB_ORDER_ASC ? compareUint16Val : compareUint16ValDesc; - case TSDB_DATA_TYPE_UINT: - return order == TSDB_ORDER_ASC ? compareUint32Val : compareUint32ValDesc; - case TSDB_DATA_TYPE_UBIGINT: - return order == TSDB_ORDER_ASC ? compareUint64Val : compareUint64ValDesc; - default: - return order == TSDB_ORDER_ASC ? compareInt32Val : compareInt32ValDesc; - } -} - int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { ASSERT(pDataBlock != NULL && pOrderInfo != NULL); if (pDataBlock->info.rows <= 1) { @@ -922,11 +883,11 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { int64_t p0 = taosGetTimestampUs(); - __compar_fn_t fn = getComparFn(pColInfoData->info.type, pOrder->order); + __compar_fn_t fn = getKeyComparFunc(pColInfoData->info.type, pOrder->order); qsort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn); int64_t p1 = taosGetTimestampUs(); - printf("sort:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows); + uDebug("blockDataSort easy cost:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows); return TSDB_CODE_SUCCESS; } else { // var data type @@ -955,6 +916,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { SColumnInfoData* pCols = createHelpColInfoData(pDataBlock); if (pCols == NULL) { + destroyTupleIndex(index); terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } @@ -963,6 +925,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { int32_t code = blockDataAssign(pCols, pDataBlock, index); if (code != TSDB_CODE_SUCCESS) { + destroyTupleIndex(index); terrno = code; return code; } @@ -972,7 +935,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { copyBackToBlock(pDataBlock, pCols); int64_t p4 = taosGetTimestampUs(); - printf("sort:%" PRId64 ", create:%" PRId64 ", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1 - p0, p2 - p1, + uDebug("blockDataSort complex sort:%" PRId64 ", create:%" PRId64 ", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows); destroyTupleIndex(index); @@ -1234,6 +1197,7 @@ void colDataDestroy(SColumnInfoData* pColData) { } taosMemoryFree(pColData->pData); + taosMemoryFree(pColData); } int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c85184ffba5e54dd103713d6613a41e5237e91fe..7a9014dc434b85cf89fc265e20534a8340eb8d49 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2571,6 +2571,7 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * int32_t tFreeSCreateVnodeReq(SCreateVnodeReq *pReq) { taosArrayDestroy(pReq->pRetensions); pReq->pRetensions = NULL; + return 0; } int32_t tSerializeSDropVnodeReq(void *buf, int32_t bufLen, SDropVnodeReq *pReq) { diff --git a/source/dnode/mgmt/dm/src/dmMsg.c b/source/dnode/mgmt/dm/src/dmMsg.c index b301ef478b0430f3a09b65f8e17aa6f62fb92052..b08657d4dca609c98cc78a9337d6e025a936774f 100644 --- a/source/dnode/mgmt/dm/src/dmMsg.c +++ b/source/dnode/mgmt/dm/src/dmMsg.c @@ -95,6 +95,7 @@ int32_t dmProcessStatusRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) { } pMgmt->statusSent = 0; + return TSDB_CODE_SUCCESS; } int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) { diff --git a/source/dnode/mgmt/dm/src/dmWorker.c b/source/dnode/mgmt/dm/src/dmWorker.c index 63b9704b7884be5ff624a29fa91f10a48dcc12a7..ca86f426086425748acab31da585ec53541b2cee 100644 --- a/source/dnode/mgmt/dm/src/dmWorker.c +++ b/source/dnode/mgmt/dm/src/dmWorker.c @@ -50,6 +50,7 @@ static void *dmThreadRoutine(void *param) { lastMonitorTime = curTime; } } + return TSDB_CODE_SUCCESS; } static void dmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { diff --git a/source/dnode/mgmt/main/src/dndTransport.c b/source/dnode/mgmt/main/src/dndTransport.c index 07ea0309a86f0dc58062b4464907de61017e00c7..6398af21dc561ba3d8bbd44c04bde47a9e9a51ce 100644 --- a/source/dnode/mgmt/main/src/dndTransport.c +++ b/source/dnode/mgmt/main/src/dndTransport.c @@ -333,6 +333,7 @@ int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg taosMsleep(1); } } + return TSDB_CODE_SUCCESS; } int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) { diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 314e70db9bb5352aba585380b03e632d139a355b..4149cb56026f9cb6a7ac47a11bc4e990b749bd1c 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -630,6 +630,7 @@ static int32_t mndProcessConfigDnodeReq(SNodeMsg *pReq) { static int32_t mndProcessConfigDnodeRsp(SNodeMsg *pRsp) { mInfo("app:%p config rsp from dnode", pRsp->rpcMsg.ahandle); + return TSDB_CODE_SUCCESS; } static int32_t mndGetConfigMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) { diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index f04f4791b5491dfd3eebf3c08f5bf8aff1af8845..9cb444f6679a0123db6c563f350aad131fd7f802 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -331,6 +331,7 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { } taosHashCleanup(pSmaStat->smaStatItems); } + return TSDB_CODE_SUCCESS; } static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { @@ -433,6 +434,7 @@ static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t return TSDB_CODE_FAILED; } tsdbDebug("vgId:%d smaIndex %" PRIi64 " tsKey %" PRIi64 " is put to hash", REPO_ID(pTsdb), indexUid, winSKey); + return TSDB_CODE_SUCCESS; } /** @@ -1051,6 +1053,7 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) { } // clear sma data files // TODO: + return TSDB_CODE_SUCCESS; } static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, int32_t fid) { @@ -1173,6 +1176,7 @@ static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, int64_t interv pSmaH->interval = tsdbGetIntervalByPrecision(interval, intervalUnit, REPO_CFG(pTsdb)->precision, true); pSmaH->storageLevel = tsdbGetSmaStorageLevel(interval, intervalUnit); pSmaH->days = tsdbGetTSmaDays(pTsdb, pSmaH->interval, pSmaH->storageLevel); + return TSDB_CODE_SUCCESS; } /** @@ -1192,6 +1196,7 @@ static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, int64_t indexUid, TSKEY skey) pSmaH->dFile.path = strdup(tSmaFile); pSmaH->smaFsIter.iter = 0; pSmaH->smaFsIter.fid = fid; + return TSDB_CODE_SUCCESS; } /** diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index e87fdba71db969a11ddd19e92a9100e766083ac5..0305d045a9f35f6141052d2704016e0d80f65739 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -2532,7 +2532,7 @@ _return: } int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet) { - + return 0; } int32_t catalogRemoveTableMeta(SCatalog* pCtg, const SName* pTableName) { @@ -2599,7 +2599,7 @@ _return: } int32_t catalogGetIndexMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, const char *pIndexName, SIndexMeta** pIndexMeta) { - + return 0; } int32_t catalogGetTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) { diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index bcbfeb7015390bc8ddadd08349cd858e93a9bdc1..d375299d57b20e13f0b19d8433f9a6a30331a496 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -128,8 +128,8 @@ static FORCE_INLINE char* getPosInResultPage(struct STaskAttr* pQueryAttr, SFile int32_t offset) { assert(rowOffset >= 0 && pQueryAttr != NULL); -// int32_t numOfRows = (int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery); -// return ((char *)page->data) + rowOffset + offset * numOfRows; + // int32_t numOfRows = (int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery); + return ((char *)page->data); } static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffset, int32_t offset) { diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index 34894c235b0e0565710a2b8d1908ff5a6b6e3fee..0b03613ab50ab8cd1055b60e5633b752351eb5b6 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -236,6 +236,7 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) { } taosCloseQueue(pDispatcher->pDataBlocks); taosThreadMutexDestroy(&pDispatcher->mutex); + return TSDB_CODE_SUCCESS; } int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle) { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 2df18f135c68cccb5c16333ff58d1c3205332017..209ffb9101374b1a546876f3419900bd15553ff5 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -359,6 +359,10 @@ SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) { idata.info.precision = pDescNode->dataType.precision; taosArrayPush(pBlock->pDataBlock, &idata); + + if (IS_VAR_DATA_TYPE(idata.info.type)) { + pBlock->info.hasVarCol = true; + } } return pBlock; @@ -4924,6 +4928,7 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator, bool* newgroup) { pOperator->status = OP_EXEC_DONE; return pBlock; #endif + return TSDB_CODE_SUCCESS; } static void doClearBufferedBlocks(SStreamBlockScanInfo* pInfo) { @@ -5000,6 +5005,7 @@ int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) pSourceDataInfo->status = EX_SOURCE_DATA_READY; tsem_post(&pSourceDataInfo->pEx->ready); + return TSDB_CODE_SUCCESS; } static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) { @@ -5673,6 +5679,7 @@ static int32_t loadSysTableContentCb(void* param, const SDataBuf* pMsg, int32_t } tsem_post(&pScanResInfo->ready); + return TSDB_CODE_SUCCESS; } static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) { @@ -6484,6 +6491,7 @@ static SSDataBlock* doSort(SOperatorInfo* pOperator, bool* newgroup) { tsortAddSource(pInfo->pSortHandle, ps); int32_t code = tsortOpen(pInfo->pSortHandle); + taosMemoryFreeClear(ps); if (code != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, terrno); } @@ -6496,15 +6504,18 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR SExecTaskInfo* pTaskInfo) { SSortOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - if (pInfo == NULL || pOperator == NULL) { + int32_t rowSize = pResBlock->info.rowSize; + + if (pInfo == NULL || pOperator == NULL || rowSize > 100 * 1024 * 1024) { taosMemoryFreeClear(pInfo); taosMemoryFreeClear(pOperator); terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; return NULL; } - pInfo->sortBufSize = 1024 * 16; // 1MB, TODO dynamic set the available sort buffer - pInfo->bufPageSize = 1024; + pInfo->bufPageSize = rowSize < 1024 ? 1024 : rowSize; + + pInfo->sortBufSize = pInfo->bufPageSize * 16; // 1MB, TODO dynamic set the available sort buffer pInfo->numOfRowsInRes = 1024; pInfo->pDataBlock = pResBlock; pInfo->pSortInfo = pSortInfo; @@ -7590,6 +7601,7 @@ static int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, S pBasicInfo->capacity = numOfRows; doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols, pkey); + return TSDB_CODE_SUCCESS; } static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInfo) { @@ -8389,6 +8401,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator, bool* newgroup) { return (pRes->info.rows == 0)? NULL:pInfo->pRes; #endif + return TSDB_CODE_SUCCESS; } SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput) { @@ -8906,6 +8919,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return createMultiTableAggOperatorInfo(op, pPhyNode->pTargets, pTaskInfo, pTableGroupInfo); } }*/ + return NULL; } static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STableGroupInfo* pGroupInfo, @@ -9217,6 +9231,7 @@ int32_t createQueryFilter(char* data, uint16_t len, SFilterInfo** pFilters) { // tExprTreeDestroy(expr, NULL); // return ret; + return TSDB_CODE_SUCCESS; } // int32_t doCreateFilterInfo(SColumnInfo* pCols, int32_t numOfCols, int32_t numOfFilterCols, SSingleColumnFilterInfo** diff --git a/source/libs/executor/src/tlinearhash.c b/source/libs/executor/src/tlinearhash.c index 1b55467c8587e2b2132bae8b3f549bb7a7c39035..21fd54b620574272aad02315a3f0d74ae05405a8 100644 --- a/source/libs/executor/src/tlinearhash.c +++ b/source/libs/executor/src/tlinearhash.c @@ -409,6 +409,7 @@ char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) { int32_t tHashRemove(SLHashObj* pHashObj, const void *key, size_t keyLen) { // todo + return TSDB_CODE_SUCCESS; } void tHashPrint(const SLHashObj* pHashObj, int32_t type) { diff --git a/source/libs/executor/src/tsimplehash.c b/source/libs/executor/src/tsimplehash.c index 981da0415e63684841099f24729891f0e8ccb5a1..eb6a5dcabea36d84758e4dc36590a02abe16d6ef 100644 --- a/source/libs/executor/src/tsimplehash.c +++ b/source/libs/executor/src/tsimplehash.c @@ -258,6 +258,7 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key) { int32_t tSimpleHashRemove(SSHashObj *pHashObj, const void *key) { // todo + return TSDB_CODE_SUCCESS; } void tSimpleHashClear(SSHashObj *pHashObj) { diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 0d69ed711ccb025d4541c6370e980ddf7f5d1c09..343efb5fbf08c1e16195fec0b7b01eeb1095a7f1 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -22,6 +22,7 @@ #include "tpagedbuf.h" #include "tsort.h" #include "tutil.h" +#include "tcompare.h" struct STupleHandle { SSDataBlock* pBlock; @@ -123,6 +124,7 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) { int32_t tsortAddSource(SSortHandle* pSortHandle, void* pSource) { taosArrayPush(pSortHandle->pOrderedSource, &pSource); + return TSDB_CODE_SUCCESS; } static int32_t doAddNewExternalMemSource(SDiskbasedBuf *pBuf, SArray* pAllSources, SSDataBlock* pBlock, int32_t* sourceId) { @@ -164,7 +166,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { } int32_t pageId = -1; - SFilePage* pPage = getNewBufPage(pHandle->pBuf, pHandle->sourceId, &pageId); + void* pPage = getNewBufPage(pHandle->pBuf, pHandle->sourceId, &pageId); if (pPage == NULL) { return terrno; } @@ -172,7 +174,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { int32_t size = blockDataGetSize(p) + sizeof(int32_t) + p->info.numOfCols * sizeof(int32_t); assert(size <= getBufPageSize(pHandle->pBuf)); - blockDataToBuf(pPage->data, p); + blockDataToBuf(pPage, p); setBufPageDirty(pPage, true); releaseBufPage(pHandle->pBuf, pPage); @@ -184,10 +186,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { blockDataCleanup(pDataBlock); SSDataBlock* pBlock = createOneDataBlock(pDataBlock); - int32_t code = doAddNewExternalMemSource(pHandle->pBuf, pHandle->pOrderedSource, pBlock, &pHandle->sourceId); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + return doAddNewExternalMemSource(pHandle->pBuf, pHandle->pOrderedSource, pBlock, &pHandle->sourceId); } static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int32_t startIndex, int32_t endIndex, SSortHandle* pHandle) { @@ -201,8 +200,8 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int SExternalMemSource* pSource = cmpParam->pSources[i]; SPageInfo* pPgInfo = *(SPageInfo**)taosArrayGet(pSource->pageIdList, pSource->pageIndex); - SFilePage* pPage = getBufPage(pHandle->pBuf, getPageId(pPgInfo)); - code = blockDataFromBuf(pSource->src.pBlock, pPage->data); + void* pPage = getBufPage(pHandle->pBuf, getPageId(pPgInfo)); + code = blockDataFromBuf(pSource->src.pBlock, pPage); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -236,6 +235,7 @@ static int32_t sortComparClearup(SMsortComparParam* cmpParam) { } cmpParam->numOfSources = 0; + return TSDB_CODE_SUCCESS; } static void appendOneRowToDataBlock(SSDataBlock *pBlock, const SSDataBlock* pSource, int32_t* rowIndex) { @@ -309,6 +309,7 @@ static int32_t adjustMergeTreeForNextTuple(SExternalMemSource *pSource, SMultiwa printf("\nafter adjust:\t"); tMergeTreePrint(pTree); #endif + return TSDB_CODE_SUCCESS; } static SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SMsortComparParam* cmpParam, int32_t capacity) { @@ -392,23 +393,13 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) { void* left1 = colDataGetData(pLeftColInfoData, pLeftSource->src.rowIndex); void* right1 = colDataGetData(pRightColInfoData, pRightSource->src.rowIndex); - switch(pLeftColInfoData->info.type) { - case TSDB_DATA_TYPE_INT: { - int32_t leftv = *(int32_t*)left1; - int32_t rightv = *(int32_t*)right1; + __compar_fn_t fn = getKeyComparFunc(pLeftColInfoData->info.type, pOrder->order); - if (leftv == rightv) { - break; - } else { - if (pOrder->order == TSDB_ORDER_ASC) { - return leftv < rightv? -1 : 1; - } else { - return leftv < rightv? 1 : -1; - } - } - } - default: - assert(0); + int ret = fn(left1, right1); + if (ret == 0) { + continue; + } else { + return ret; } } return 0; @@ -424,13 +415,13 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { double sortPass = floorl(log2(numOfSources) / log2(pHandle->numOfPages)); pHandle->totalElapsed = taosGetTimestampUs() - pHandle->startTs; - qDebug("%s %d rounds mergesort required to complete the sort, first-round sorted data size:%"PRIzu", sort:%"PRId64", total elapsed:%"PRId64, + qDebug("%s %d rounds mergesort required to complete the sort, first-round sorted data size:%"PRIzu", sort elapsed:%"PRId64", total elapsed:%"PRId64, pHandle->idStr, (int32_t) (sortPass + 1), getTotalBufSize(pHandle->pBuf), pHandle->sortElapsed, pHandle->totalElapsed); size_t pgSize = pHandle->pageSize; int32_t numOfRows = (pgSize - blockDataGetSerialMetaSize(pHandle->pDataBlock))/ blockDataGetSerialRowSize(pHandle->pDataBlock); - blockDataEnsureCapacity(pHandle->pDataBlock, numOfRows); + // blockDataEnsureCapacity(pHandle->pDataBlock, numOfRows); // useless, it is already enough size_t numOfSorted = taosArrayGetSize(pHandle->pOrderedSource); for(int32_t t = 0; t < sortPass; ++t) { @@ -469,7 +460,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { } int32_t pageId = -1; - SFilePage* pPage = getNewBufPage(pHandle->pBuf, pHandle->sourceId, &pageId); + void* pPage = getNewBufPage(pHandle->pBuf, pHandle->sourceId, &pageId); if (pPage == NULL) { return terrno; } @@ -477,7 +468,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { int32_t size = blockDataGetSize(pDataBlock) + sizeof(int32_t) + pDataBlock->info.numOfCols * sizeof(int32_t); assert(size <= getBufPageSize(pHandle->pBuf)); - blockDataToBuf(pPage->data, pDataBlock); + blockDataToBuf(pPage, pDataBlock); setBufPageDirty(pPage, true); releaseBufPage(pHandle->pBuf, pPage); @@ -526,7 +517,6 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) { if (pHandle->type == SORT_SINGLESOURCE_SORT) { SGenericSource* source = taosArrayGetP(pHandle->pOrderedSource, 0); taosArrayClear(pHandle->pOrderedSource); - while (1) { SSDataBlock* pBlock = pHandle->fetchfp(source->param); if (pBlock == NULL) { @@ -559,8 +549,13 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) { size_t size = blockDataGetSize(pHandle->pDataBlock); // Perform the in-memory sort and then flush data in the buffer into disk. + int64_t p = taosGetTimestampUs(); + blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo); + int64_t el = taosGetTimestampUs() - p; + pHandle->sortElapsed += el; + // All sorted data can fit in memory, external memory sort is not needed. Return to directly if (size <= sortBufSize) { pHandle->cmpParam.numOfSources = 1; @@ -573,8 +568,6 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) { doAddToBuf(pHandle->pDataBlock, pHandle); } } - - taosMemoryFreeClear(source); } return TSDB_CODE_SUCCESS; @@ -616,22 +609,22 @@ int32_t tsortOpen(SSortHandle* pHandle) { return code; } - code = tMergeTreeCreate(&pHandle->pMergeTree, pHandle->cmpParam.numOfSources, &pHandle->cmpParam, pHandle->comparFn); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + return tMergeTreeCreate(&pHandle->pMergeTree, pHandle->cmpParam.numOfSources, &pHandle->cmpParam, pHandle->comparFn); } int32_t tsortClose(SSortHandle* pHandle) { // do nothing + return TSDB_CODE_SUCCESS; } int32_t tsortSetFetchRawDataFp(SSortHandle* pHandle, _sort_fetch_block_fn_t fp) { pHandle->fetchfp = fp; + return TSDB_CODE_SUCCESS; } int32_t tsortSetComparFp(SSortHandle* pHandle, _sort_merge_compar_fn_t fp) { pHandle->comparFn = fp; + return TSDB_CODE_SUCCESS; } STupleHandle* tsortNextTuple(SSortHandle* pHandle) { diff --git a/source/libs/executor/test/sortTests.cpp b/source/libs/executor/test/sortTests.cpp index 1b64182266d5c28e09a8ea9b4b9c71f40cd8a84e..3bff67eb69148bbf54b7dd6af5e14bf8cee08ca0 100644 --- a/source/libs/executor/test/sortTests.cpp +++ b/source/libs/executor/test/sortTests.cpp @@ -33,6 +33,7 @@ #include "tdef.h" #include "trpc.h" #include "tvariant.h" +#include "tcompare.h" namespace { typedef struct { @@ -125,24 +126,13 @@ int32_t docomp(const void* p1, const void* p2, void* param) { void* left1 = colDataGetData(pLeftColInfoData, pLeftSource->src.rowIndex); void* right1 = colDataGetData(pRightColInfoData, pRightSource->src.rowIndex); + __compar_fn_t fn = getKeyComparFunc(pLeftColInfoData->info.type, pOrder->order); - switch(pLeftColInfoData->info.type) { - case TSDB_DATA_TYPE_INT: { - int32_t leftv = *(int32_t*)left1; - int32_t rightv = *(int32_t*)right1; - - if (leftv == rightv) { - break; - } else { - if (pOrder->order == TSDB_ORDER_ASC) { - return leftv < rightv? -1 : 1; - } else { - return leftv < rightv? 1 : -1; - } - } - } - default: - assert(0); + int ret = fn(left1, right1); + if (ret == 0) { + continue; + } else { + return ret; } } diff --git a/source/libs/index/src/indexFstRegex.c b/source/libs/index/src/indexFstRegex.c index ec41a7f58eac2087986f28fb032756d2ea7007c6..e89c94079ec5b34965d159e34aabcef028dd3e1d 100644 --- a/source/libs/index/src/indexFstRegex.c +++ b/source/libs/index/src/indexFstRegex.c @@ -26,6 +26,7 @@ FstRegex *regexCreate(const char *str) { memcpy(orig, str, sz); regex->orig = orig; + return regex; } void regexSetup(FstRegex *regex, uint32_t size, const char *str) { diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 1cc259d4da1bff20a5fbcb15f0490f63ed79aa83..dd3edcf1a3ea89caa59ca29b1aac1a73e8ceded6 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -132,7 +132,6 @@ void sclFreeRes(SHashObj *res) { void sclFreeParam(SScalarParam *param) { if (param->columnData != NULL) { colDataDestroy(param->columnData); - taosMemoryFreeClear(param->columnData); } if (param->pHashFilter != NULL) { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index d8e97e7e12055b26191b8faf6bab42b453a129c0..04860492969f13131c72f071eabb593217d9c779 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -385,16 +385,19 @@ bool getTimePseudoFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv int32_t qStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0)); + return TSDB_CODE_SUCCESS; } int32_t qEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 1)); + return TSDB_CODE_SUCCESS; } int32_t winDurFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 2)); + return TSDB_CODE_SUCCESS; } int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index f22f9a5c3c06c799160ef6ece32e3d0ca9e45513..d08352602de7783a9321692ea19115157c440dd1 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -476,7 +476,6 @@ static SColumnInfoData* doVectorConvert(SScalarParam* pInput, int32_t* doConvert static void doReleaseVec(SColumnInfoData* pCol, int32_t type) { if (type == VECTOR_DO_CONVERT) { colDataDestroy(pCol); - taosMemoryFree(pCol); } } diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 5af13d97ca0e249f25618abd9950bd26d721fa2e..86eaa09594ab7b975fc8bf743dd11a1ff613ce86 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -258,6 +258,7 @@ _return: SCH_JOB_ELOG("invalid job status update, from %s to %s", jobTaskStatusStr(oriStatus), jobTaskStatusStr(newStatus)); SCH_ERR_RET(code); + return TSDB_CODE_SUCCESS; } int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { @@ -791,7 +792,7 @@ _return: SCH_RET(schProcessOnJobFailure(pJob, code)); } -int32_t schProcessOnDataFetched(SSchJob *job) { +void schProcessOnDataFetched(SSchJob *job) { atomic_val_compare_exchange_32(&job->remoteFetch, 1, 0); tsem_post(&job->rspSem); } @@ -1150,6 +1151,7 @@ int32_t schHandleReadyCallback(void *param, const SDataBuf *pMsg, int32_t code) int32_t schHandleDropCallback(void *param, const SDataBuf *pMsg, int32_t code) { SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; qDebug("QID:%" PRIx64 ",TID:%" PRIx64 " drop task rsp received, code:%x", pParam->queryId, pParam->taskId, code); + return TSDB_CODE_SUCCESS; } int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) { @@ -2029,7 +2031,7 @@ void schDropJobAllTasks(SSchJob *pJob) { int32_t schCancelJob(SSchJob *pJob) { // TODO - + return TSDB_CODE_SUCCESS; // TODO MOVE ALL TASKS FROM EXEC LIST TO FAIL LIST } diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index c98f6eb9be326317dd35dd678fed724ec30546ca..d4abcb962afa05af9272c657a8aef7cbeab69fc9 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -436,7 +436,6 @@ int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight) { int32_t compareWStrPatternNotMatch(const void *pLeft, const void *pRight) { return compareWStrPatternMatch(pLeft, pRight) ? 0 : 1; } - __compar_fn_t getComparFunc(int32_t type, int32_t optr) { __compar_fn_t comparFn = NULL; @@ -568,53 +567,36 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { } __compar_fn_t getKeyComparFunc(int32_t keyType, int32_t order) { - __compar_fn_t comparFn = NULL; - switch (keyType) { case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_BOOL: - comparFn = (order == TSDB_ORDER_ASC) ? compareInt8Val : compareInt8ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareInt8Val : compareInt8ValDesc; case TSDB_DATA_TYPE_SMALLINT: - comparFn = (order == TSDB_ORDER_ASC) ? compareInt16Val : compareInt16ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareInt16Val : compareInt16ValDesc; case TSDB_DATA_TYPE_INT: - comparFn = (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc; case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_TIMESTAMP: - comparFn = (order == TSDB_ORDER_ASC) ? compareInt64Val : compareInt64ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareInt64Val : compareInt64ValDesc; case TSDB_DATA_TYPE_FLOAT: - comparFn = (order == TSDB_ORDER_ASC) ? compareFloatVal : compareFloatValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareFloatVal : compareFloatValDesc; case TSDB_DATA_TYPE_DOUBLE: - comparFn = (order == TSDB_ORDER_ASC) ? compareDoubleVal : compareDoubleValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareDoubleVal : compareDoubleValDesc; case TSDB_DATA_TYPE_UTINYINT: - comparFn = (order == TSDB_ORDER_ASC) ? compareUint8Val : compareUint8ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareUint8Val : compareUint8ValDesc; case TSDB_DATA_TYPE_USMALLINT: - comparFn = (order == TSDB_ORDER_ASC) ? compareUint16Val : compareUint16ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareUint16Val : compareUint16ValDesc; case TSDB_DATA_TYPE_UINT: - comparFn = (order == TSDB_ORDER_ASC) ? compareUint32Val : compareUint32ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareUint32Val : compareUint32ValDesc; case TSDB_DATA_TYPE_UBIGINT: - comparFn = (order == TSDB_ORDER_ASC) ? compareUint64Val : compareUint64ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareUint64Val : compareUint64ValDesc; case TSDB_DATA_TYPE_BINARY: - comparFn = (order == TSDB_ORDER_ASC) ? compareLenPrefixedStr : compareLenPrefixedStrDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareLenPrefixedStr : compareLenPrefixedStrDesc; case TSDB_DATA_TYPE_NCHAR: - comparFn = (order == TSDB_ORDER_ASC) ? compareLenPrefixedWStr : compareLenPrefixedWStrDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareLenPrefixedWStr : compareLenPrefixedWStrDesc; default: - comparFn = (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc; - break; + return (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc; } - - return comparFn; } int32_t doCompare(const char *f1, const char *f2, int32_t type, size_t size) { diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index 096a16ec943e0f6bc6bdbc3b1820e5c3c5afd919..e6bc2787e86358e19e755cf1a5245dcb2e0bcb12 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -350,8 +350,7 @@ static void lruListMoveToFront(SList* pList, SPageInfo* pi) { } static SPageInfo* getPageInfoFromPayload(void* page) { - int32_t offset = offsetof(SPageInfo, pData); - char* p = (char *)page - offset; + char* p = (char *)page - POINTER_BYTES; SPageInfo* ppi = ((SPageInfo**)p)[0]; return ppi;