From bf9ab440a79864eeed75f8b4521d71d152b1620e Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 27 Apr 2022 17:39:54 +0800 Subject: [PATCH] fix(os): fix new compilation errors. --- contrib/CMakeLists.txt | 4 +- include/client/taos.h | 9 ++-- include/common/tmsg.h | 6 ++- include/os/os.h | 1 + include/os/osMath.h | 32 +++++-------- include/util/tencode.h | 55 +++++++++++++++------- source/client/inc/clientInt.h | 2 - source/client/src/clientImpl.c | 4 +- source/client/src/taos.def | 1 + source/common/src/tmsg.c | 6 +-- source/common/src/ttypes.c | 12 ++--- source/dnode/mnode/impl/src/mndStb.c | 4 +- source/dnode/mnode/impl/src/mndUser.c | 4 +- source/dnode/vnode/src/inc/meta.h | 8 +++- source/dnode/vnode/src/meta/metaTable.c | 8 +++- source/dnode/vnode/src/tsdb/tsdbRead.c | 10 ++-- source/dnode/vnode/src/vnd/vnodeSvr.c | 3 +- source/libs/executor/src/executorimpl.c | 16 +++---- source/libs/executor/src/scanoperator.c | 2 +- source/libs/parser/src/parInsert.c | 2 +- source/libs/parser/src/parInsertData.c | 5 +- source/libs/parser/src/parTranslater.c | 15 +++--- source/libs/planner/src/planLogicCreater.c | 6 +-- source/libs/planner/src/planOptimizer.c | 2 +- source/libs/planner/src/planPhysiCreater.c | 2 +- source/libs/planner/src/planSpliter.c | 5 +- source/os/src/osSemaphore.c | 6 +++ source/util/test/encodeTest.cpp | 8 ++-- tools/shell/inc/shellInt.h | 1 - 29 files changed, 138 insertions(+), 101 deletions(-) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 6a290dda15..e797911add 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -219,8 +219,8 @@ endif(${BUILD_WITH_NURAFT}) # pthread if(${BUILD_PTHREAD}) set(CMAKE_BUILD_TYPE release) - add_definitions(-DPTW32_STATIC_LIB) - add_subdirectory(pthread EXCLUDE_FROM_ALL) + add_definitions(-DPTW32_STATIC_LIB) + add_subdirectory(pthread) set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread) add_library(pthread STATIC IMPORTED GLOBAL) SET_PROPERTY(TARGET pthread PROPERTY IMPORTED_LOCATION ${LIBRARY_OUTPUT_PATH}/pthread.lib) diff --git a/include/client/taos.h b/include/client/taos.h index 0f1633ed6f..1ac92c61a5 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -121,13 +121,14 @@ typedef struct setConfRet { DLL_EXPORT void taos_cleanup(void); DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...); DLL_EXPORT setConfRet taos_set_config(const char *config); +DLL_EXPORT int taos_init(void); DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port); -DLL_EXPORT TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, const char *pass, int passLen, +DLL_EXPORT TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, const char *pass, int passLen, const char *db, int dbLen, uint16_t port); -DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port); -DLL_EXPORT void taos_close(TAOS *taos); +DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port); +DLL_EXPORT void taos_close(TAOS *taos); -const char *taos_data_type(int type); +const char *taos_data_type(int type); DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos); DLL_EXPORT int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length); diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 14b64d64b4..ab03b2b932 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1538,6 +1538,10 @@ int tDecodeSVCreateStbReq(SCoder* pCoder, SVCreateStbReq* pReq); typedef struct SVDropStbReq { // data +#ifdef WINDOWS + size_t avoidCompilationErrors; +#endif + } SVDropStbReq; typedef struct SVCreateStbRsp { @@ -2117,7 +2121,7 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SCoder* pDecoder, SSchemaWrapp if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1; if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1; - pSW->pSchema = (SSchema*)TCODER_MALLOC(pDecoder, sizeof(SSchema) * pSW->nCols); + pSW->pSchema = (SSchema*)tCoderMalloc(pDecoder, sizeof(SSchema) * pSW->nCols); if (pSW->pSchema == NULL) return -1; for (int32_t i = 0; i < pSW->nCols; i++) { if (tDecodeSSchema(pDecoder, &pSW->pSchema[i]) < 0) return -1; diff --git a/include/os/os.h b/include/os/os.h index 86abcc15f5..329ad481aa 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -59,6 +59,7 @@ extern "C" { #include #endif +#define __typeof(a) auto #endif diff --git a/include/os/osMath.h b/include/os/osMath.h index cabb821844..829bbd847b 100644 --- a/include/os/osMath.h +++ b/include/os/osMath.h @@ -23,27 +23,21 @@ extern "C" { #define TPOW2(x) ((x) * (x)) #define TABS(x) ((x) > 0 ? (x) : -(x)) +#define TSWAP(a, b) \ + do { \ + __typeof(a) __tmp = (a); \ + (a) = (b); \ + (b) = __tmp; \ + } while (0) + #ifdef WINDOWS - #define TSWAP(a, b, c) \ - do { \ - c __tmp = (c)(a); \ - (a) = (c)(b); \ - (b) = __tmp; \ - } while (0) #define TMAX(a, b) (((a) > (b)) ? (a) : (b)) #define TMIN(a, b) (((a) < (b)) ? (a) : (b)) #define TRANGE(aa, bb, cc) ((aa) = TMAX((aa), (bb)),(aa) = TMIN((aa), (cc))) #else - #define TSWAP(a, b, c) \ - do { \ - __typeof(a) __tmp = (a); \ - (a) = (b); \ - (b) = __tmp; \ - } while (0) - #define TMAX(a, b) \ ({ \ __typeof(a) __a = (a); \ @@ -51,12 +45,12 @@ extern "C" { (__a > __b) ? __a : __b; \ }) - #define TMIN(a, b) \ - ({ \ - __typeof(a) __a = (a); \ - __typeof(b) __b = (b); \ - (__a < __b) ? __a : __b; \ - }) +#define TMIN(a, b) \ + ({ \ + __typeof(a) __a = (a); \ + __typeof(b) __b = (b); \ + (__a < __b) ? __a : __b; \ + }) #define TRANGE(a, b, c) \ ({ \ diff --git a/include/util/tencode.h b/include/util/tencode.h index 0236fe58da..c5066996f3 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -79,31 +79,52 @@ typedef struct { #define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos) #define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE)) #define TD_CODER_CHECK_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE)) -#define TCODER_MALLOC(PCODER, SIZE) \ - ({ \ - void* ptr = NULL; \ - SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + (SIZE)); \ - if (pMem) { \ - pMem->next = (PCODER)->mList; \ - (PCODER)->mList = pMem; \ - ptr = (void*)&pMem[1]; \ - } \ - ptr; \ - }) +// #define TCODER_MALLOC(PCODER, SIZE) \ +// ({ \ +// void* ptr = NULL; \ +// SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + (SIZE)); \ +// if (pMem) { \ +// pMem->next = (PCODER)->mList; \ +// (PCODER)->mList = pMem; \ +// ptr = (void*)&pMem[1]; \ +// } \ +// ptr; \ +// }) +static FORCE_INLINE void* tCoderMalloc(SCoder* pCoder, int32_t size) { + void* ptr = NULL; + SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(SCoderMem*) + size); + if (pMem) { + pMem->next = pCoder->mList; + pCoder->mList = pMem; + ptr = (void*)&pMem[1]; + } + return ptr; +} -#define tEncodeSize(E, S, SIZE) \ - ({ \ +#define tEncodeSize(E, S, SIZE, RET) \ + do{ \ SCoder coder = {0}; \ - int ret = 0; \ tCoderInit(&coder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); \ if ((E)(&coder, S) == 0) { \ SIZE = coder.pos; \ } else { \ - ret = -1; \ + RET = -1; \ } \ tCoderClear(&coder); \ - ret; \ - }) + }while(0) +// #define tEncodeSize(E, S, SIZE) \ +// ({ \ +// SCoder coder = {0}; \ +// int ret = 0; \ +// tCoderInit(&coder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); \ +// if ((E)(&coder, S) == 0) { \ +// SIZE = coder.pos; \ +// } else { \ +// ret = -1; \ +// } \ +// tCoderClear(&coder); \ +// ret; \ +// }) void tCoderInit(SCoder* pCoder, td_endian_t endian, uint8_t* data, int32_t size, td_coder_t type); void tCoderClear(SCoder* pCoder); diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 41448a4391..0ff542358d 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -254,8 +254,6 @@ extern int (*handleRequestRspFp[TDMT_MAX])(void*, const SDataBuf* pMsg, int32_t int genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code); SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pReqObj); -int taos_init(); - void* createTscObj(const char* user, const char* auth, const char* db, SAppInstInfo* pAppInfo); void destroyTscObj(void* pObj); STscObj* acquireTscObj(int64_t rid); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 48bfb46785..47154bedb7 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -187,8 +187,8 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC setResPrecision(&pRequest->body.resInfo, (*pQuery)->precision); } - TSWAP(pRequest->dbList, (*pQuery)->pDbList, SArray*); - TSWAP(pRequest->tableList, (*pQuery)->pTableList, SArray*); + TSWAP(pRequest->dbList, (*pQuery)->pDbList); + TSWAP(pRequest->tableList, (*pQuery)->pTableList); } return code; diff --git a/source/client/src/taos.def b/source/client/src/taos.def index bc78b241d2..994dd75090 100644 --- a/source/client/src/taos.def +++ b/source/client/src/taos.def @@ -1,6 +1,7 @@ taos_cleanup taos_options taos_set_config +taos_init taos_connect taos_connect_l taos_connect_auth diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 6c84fe6be7..8c1cfa5101 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -3231,7 +3231,7 @@ int32_t tEncodeSMqCMCommitOffsetReq(SCoder *encoder, const SMqCMCommitOffsetReq int32_t tDecodeSMqCMCommitOffsetReq(SCoder *decoder, SMqCMCommitOffsetReq *pReq) { if (tStartDecode(decoder) < 0) return -1; if (tDecodeI32(decoder, &pReq->num) < 0) return -1; - pReq->offsets = (SMqOffset *)TCODER_MALLOC(decoder, sizeof(SMqOffset) * pReq->num); + pReq->offsets = (SMqOffset *)tCoderMalloc(decoder, sizeof(SMqOffset) * pReq->num); if (pReq->offsets == NULL) return -1; for (int32_t i = 0; i < pReq->num; i++) { tDecodeSMqOffset(decoder, &pReq->offsets[i]); @@ -3514,7 +3514,7 @@ int tDecodeSVCreateTbBatchRsp(SCoder *pCoder, SVCreateTbBatchRsp *pRsp) { if (tStartDecode(pCoder) < 0) return -1; if (tDecodeI32v(pCoder, &pRsp->nRsps) < 0) return -1; - pRsp->pRsps = (SVCreateTbRsp *)TCODER_MALLOC(pCoder, sizeof(*pRsp->pRsps) * pRsp->nRsps); + pRsp->pRsps = (SVCreateTbRsp *)tCoderMalloc(pCoder, sizeof(*pRsp->pRsps) * pRsp->nRsps); for (int32_t i = 0; i < pRsp->nRsps; i++) { if (tDecodeSVCreateTbRsp(pCoder, pRsp->pRsps + i) < 0) return -1; } @@ -3743,7 +3743,7 @@ int tDecodeSVCreateTbBatchReq(SCoder *pCoder, SVCreateTbBatchReq *pReq) { if (tStartDecode(pCoder) < 0) return -1; if (tDecodeI32v(pCoder, &pReq->nReqs) < 0) return -1; - pReq->pReqs = (SVCreateTbReq *)TCODER_MALLOC(pCoder, sizeof(SVCreateTbReq) * pReq->nReqs); + pReq->pReqs = (SVCreateTbReq *)tCoderMalloc(pCoder, sizeof(SVCreateTbReq) * pReq->nReqs); if (pReq->pReqs == NULL) return -1; for (int iReq = 0; iReq < pReq->nReqs; iReq++) { if (tDecodeSVCreateTbReq(pCoder, pReq->pReqs + iReq) < 0) return -1; diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index 1c7a7986e9..e3d67cd488 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -651,35 +651,35 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void *buf switch (type) { case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_UINT: { - TSWAP(*(int32_t *)(pLeft), *(int32_t *)(pRight), int32_t); + TSWAP(*(int32_t *)(pLeft), *(int32_t *)(pRight)); break; } case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_TIMESTAMP: { - TSWAP(*(int64_t *)(pLeft), *(int64_t *)(pRight), int64_t); + TSWAP(*(int64_t *)(pLeft), *(int64_t *)(pRight)); break; } case TSDB_DATA_TYPE_DOUBLE: { - TSWAP(*(double *)(pLeft), *(double *)(pRight), double); + TSWAP(*(double *)(pLeft), *(double *)(pRight)); break; } case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_USMALLINT: { - TSWAP(*(int16_t *)(pLeft), *(int16_t *)(pRight), int16_t); + TSWAP(*(int16_t *)(pLeft), *(int16_t *)(pRight)); break; } case TSDB_DATA_TYPE_FLOAT: { - TSWAP(*(float *)(pLeft), *(float *)(pRight), float); + TSWAP(*(float *)(pLeft), *(float *)(pRight)); break; } case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_UTINYINT: { - TSWAP(*(int8_t *)(pLeft), *(int8_t *)(pRight), int8_t); + TSWAP(*(int8_t *)(pLeft), *(int8_t *)(pRight)); break; } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 3b6b264d1b..41bcef25d1 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -395,7 +395,9 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt } } // get length - if (tEncodeSize(tEncodeSVCreateStbReq, &req, contLen) < 0) { + int32_t ret = 0; + tEncodeSize(tEncodeSVCreateStbReq, &req, contLen, ret); + if (ret < 0) { return NULL; } diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 261d334de2..f739810065 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -230,8 +230,8 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) { memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN); pOld->updateTime = pNew->updateTime; - TSWAP(pOld->readDbs, pNew->readDbs, (void *)); - TSWAP(pOld->writeDbs, pNew->writeDbs, (void *)); + TSWAP(pOld->readDbs, pNew->readDbs); + TSWAP(pOld->writeDbs, pNew->writeDbs); return 0; } diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index 9a0b1f4578..0001a43231 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -77,21 +77,25 @@ typedef struct { tb_uid_t uid; } STbDbKey; -typedef struct __attribute__((__packed__)) { +#pragma pack(push, 1) +typedef struct { tb_uid_t uid; int32_t sver; } SSkmDbKey; +#pragma pack(pop) typedef struct { tb_uid_t suid; tb_uid_t uid; } SCtbIdxKey; -typedef struct __attribute__((__packed__)) { +#pragma pack(push, 1) +typedef struct { tb_uid_t suid; int16_t cid; char data[]; } STagIdxKey; +#pragma pack(pop) typedef struct { int64_t dtime; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 7003b0d17a..3e70bbb479 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -158,7 +158,9 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) { pKey = &tbDbKey; kLen = sizeof(tbDbKey); - if (tEncodeSize(metaEncodeEntry, pME, vLen) < 0) { + int32_t ret = 0; + tEncodeSize(metaEncodeEntry, pME, vLen, ret); + if (ret < 0) { goto _err; } @@ -250,7 +252,9 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) { skmDbKey.sver = pSW->sver; // encode schema - if (tEncodeSize(tEncodeSSchemaWrapper, pSW, vLen) < 0) return -1; + int32_t ret = 0; + tEncodeSize(tEncodeSSchemaWrapper, pSW, vLen, ret); + if (ret < 0) return -1; pVal = taosMemoryMalloc(vLen); if (pVal == NULL) { rcode = -1; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 302ee89e51..1b23d12c2f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -454,7 +454,7 @@ void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond* pCond) { if (emptyQueryTimewindow(pTsdbReadHandle)) { if (pCond->order != pTsdbReadHandle->order) { pTsdbReadHandle->order = pCond->order; - TSWAP(pTsdbReadHandle->window.skey, pTsdbReadHandle->window.ekey, int64_t); + TSWAP(pTsdbReadHandle->window.skey, pTsdbReadHandle->window.ekey); } return; @@ -924,7 +924,7 @@ static bool hasMoreDataInCache(STsdbReadHandle* pHandle) { pHandle->cur.mixBlock = true; if (!ASCENDING_TRAVERSE(pHandle->order)) { - TSWAP(win->skey, win->ekey, TSKEY); + TSWAP(win->skey, win->ekey); } return true; @@ -1203,7 +1203,7 @@ static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* // update the last key value pCheckInfo->lastKey = cur->win.ekey + step; if (!ASCENDING_TRAVERSE(pTsdbReadHandle->order)) { - TSWAP(cur->win.skey, cur->win.ekey, TSKEY); + TSWAP(cur->win.skey, cur->win.ekey); } cur->mixBlock = true; @@ -1701,7 +1701,7 @@ static void copyAllRemainRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, STa int32_t end = endPos; if (!ASCENDING_TRAVERSE(pTsdbReadHandle->order)) { - TSWAP(start, end, int32_t); + TSWAP(start, end); } assert(pTsdbReadHandle->outputCapacity >= (end - start + 1)); @@ -1932,7 +1932,7 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf ((pos < endPos || cur->lastKey < pTsdbReadHandle->window.ekey) && !ASCENDING_TRAVERSE(pTsdbReadHandle->order))); if (!ASCENDING_TRAVERSE(pTsdbReadHandle->order)) { - TSWAP(cur->win.skey, cur->win.ekey, TSKEY); + TSWAP(cur->win.skey, cur->win.ekey); } moveDataToFront(pTsdbReadHandle, numOfRows, numOfCols); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index de06f93c64..4a5be46698 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -369,7 +369,8 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, tCoderClear(&coder); // prepare rsp - tEncodeSize(tEncodeSVCreateTbBatchRsp, &rsp, pRsp->contLen); + int32_t ret = 0; + tEncodeSize(tEncodeSVCreateTbBatchRsp, &rsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); if (pRsp->pCont == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index f6b1839f68..ed33f3302e 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -2100,7 +2100,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { // // pQueryAttr->order.order = TSDB_ORDER_ASC; // if (pQueryAttr->window.skey > pQueryAttr->window.ekey) { -// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey, TSKEY); +// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey); // } // // pQueryAttr->needReverseScan = false; @@ -2110,7 +2110,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { // if (pQueryAttr->groupbyColumn && pQueryAttr->order.order == TSDB_ORDER_DESC) { // pQueryAttr->order.order = TSDB_ORDER_ASC; // if (pQueryAttr->window.skey > pQueryAttr->window.ekey) { -// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey, TSKEY); +// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey); // } // // pQueryAttr->needReverseScan = false; @@ -2135,7 +2135,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { // //qDebug(msg, pQInfo->qId, "only-first", pQueryAttr->order.order, TSDB_ORDER_ASC, pQueryAttr->window.skey, //// pQueryAttr->window.ekey, pQueryAttr->window.ekey, pQueryAttr->window.skey); // -// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey, TSKEY); +// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey); // doUpdateLastKey(pQueryAttr); // } // @@ -2146,7 +2146,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { // //qDebug(msg, pQInfo->qId, "only-last", pQueryAttr->order.order, TSDB_ORDER_DESC, pQueryAttr->window.skey, //// pQueryAttr->window.ekey, pQueryAttr->window.ekey, pQueryAttr->window.skey); // -// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey, TSKEY); +// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey); // doUpdateLastKey(pQueryAttr); // } // @@ -2162,7 +2162,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { //// pQueryAttr->window.skey, pQueryAttr->window.ekey, pQueryAttr->window.ekey, /// pQueryAttr->window.skey); // -// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey, TSKEY); +// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey); // doUpdateLastKey(pQueryAttr); // } // @@ -2174,7 +2174,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { //// pQueryAttr->window.skey, pQueryAttr->window.ekey, pQueryAttr->window.ekey, /// pQueryAttr->window.skey); // -// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey, TSKEY); +// TSWAP(pQueryAttr->window.skey, pQueryAttr->window.ekey); // doUpdateLastKey(pQueryAttr); // } // @@ -2673,7 +2673,7 @@ static void updateTableQueryInfoForReverseScan(STableQueryInfo* pTableQueryInfo) return; } - // TSWAP(pTableQueryInfo->win.skey, pTableQueryInfo->win.ekey, TSKEY); + // TSWAP(pTableQueryInfo->win.skey, pTableQueryInfo->win.ekey); // pTableQueryInfo->lastKey = pTableQueryInfo->win.skey; // SWITCH_ORDER(pTableQueryInfo->cur.order); @@ -6652,7 +6652,7 @@ static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableS //todo work around a problem, remove it later if ((pCond->order == TSDB_ORDER_ASC && pCond->twindow.skey > pCond->twindow.ekey) || (pCond->order == TSDB_ORDER_DESC && pCond->twindow.skey < pCond->twindow.ekey)) { - TSWAP(pCond->twindow.skey, pCond->twindow.ekey, int64_t); + TSWAP(pCond->twindow.skey, pCond->twindow.ekey); } #endif diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 022ba9d872..8291826e69 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -266,7 +266,7 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction // setupQueryRangeForReverseScan(pTableScanInfo); STimeWindow* pTWindow = &pTableScanInfo->cond.twindow; - TSWAP(pTWindow->skey, pTWindow->ekey, int64_t); + TSWAP(pTWindow->skey, pTWindow->ekey); pTableScanInfo->cond.order = TSDB_ORDER_DESC; } diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index dfeb2df911..18a51a37f0 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -307,7 +307,7 @@ static int32_t buildOutput(SInsertParseContext* pCxt) { taosHashGetDup(pCxt->pVgroupsHashObj, (const char*)&src->vgId, sizeof(src->vgId), &dst->vg); dst->numOfTables = src->numOfTables; dst->size = src->size; - TSWAP(dst->pData, src->pData, char*); + TSWAP(dst->pData, src->pData); buildMsgHeader(src, dst); taosArrayPush(pCxt->pOutput->pDataBlocks, &dst); } diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertData.c index aee4566fa0..ae05d2293e 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertData.c @@ -159,9 +159,10 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) { SCoder coder = {0}; char* pBuf; - int32_t len; + int32_t len; - tEncodeSize(tEncodeSVCreateTbReq, pCreateTbReq, len); + int32_t ret = 0; + tEncodeSize(tEncodeSVCreateTbReq, pCreateTbReq, len, ret); if (pBlocks->nAllocSize - pBlocks->size < len) { pBlocks->nAllocSize += len + pBlocks->rowSize; char* pTmp = taosMemoryRealloc(pBlocks->pData, pBlocks->nAllocSize); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index aae932471d..cb514e974a 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2049,10 +2049,10 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch } strcpy(pTable->table.dbName, pInfo->pDbName); strcpy(pTable->table.tableName, pInfo->pTableName); - TSWAP(pTable->pMeta, pInfo->pRollupTableMeta, STableMeta*); + TSWAP(pTable->pMeta, pInfo->pRollupTableMeta); pSelect->pFromTable = (SNode*)pTable; - TSWAP(pSelect->pProjectionList, pInfo->pFuncs, SNodeList*); + TSWAP(pSelect->pProjectionList, pInfo->pFuncs); SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pSelect->pProjectionList || NULL == pFunc) { nodesDestroyNode(pSelect); @@ -2069,9 +2069,9 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch return TSDB_CODE_OUT_OF_MEMORY; } pSelect->pWindow = (SNode*)pInterval; - TSWAP(pInterval->pInterval, pInfo->pInterval, SNode*); - TSWAP(pInterval->pOffset, pInfo->pOffset, SNode*); - TSWAP(pInterval->pSliding, pInfo->pSliding, SNode*); + TSWAP(pInterval->pInterval, pInfo->pInterval); + TSWAP(pInterval->pOffset, pInfo->pOffset); + TSWAP(pInterval->pSliding, pInfo->pSliding); pInterval->pCol = nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pInterval->pCol) { nodesDestroyNode(pSelect); @@ -3282,7 +3282,8 @@ static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray* int tlen; SCoder coder = {0}; - tEncodeSize(tEncodeSVCreateTbBatchReq, &pTbBatch->req, tlen); + int32_t ret = 0; + tEncodeSize(tEncodeSVCreateTbBatchReq, &pTbBatch->req, tlen, ret); tlen += sizeof(SMsgHead); //+ tSerializeSVCreateTbBatchReq(NULL, &(pTbBatch->req)); void* buf = taosMemoryMalloc(tlen); if (NULL == buf) { @@ -3696,7 +3697,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { default: pQuery->execMode = QUERY_EXEC_MODE_RPC; if (NULL != pCxt->pCmdMsg) { - TSWAP(pQuery->pCmdMsg, pCxt->pCmdMsg, SCmdMsgInfo*); + TSWAP(pQuery->pCmdMsg, pCxt->pCmdMsg); pQuery->msgType = pQuery->pCmdMsg->msgType; } break; diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 450fc307ea..18e59859ac 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -251,8 +251,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect return TSDB_CODE_OUT_OF_MEMORY; } - TSWAP(pScan->pMeta, pRealTable->pMeta, STableMeta*); - TSWAP(pScan->pVgroupList, pRealTable->pVgroupList, SVgroupsInfo*); + TSWAP(pScan->pMeta, pRealTable->pMeta); + TSWAP(pScan->pVgroupList, pRealTable->pVgroupList); pScan->scanSeq[0] = 1; pScan->scanSeq[1] = 0; pScan->scanRange = TSWINDOW_INITIALIZER; @@ -954,7 +954,7 @@ static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpS if (NULL == pModif) { return TSDB_CODE_OUT_OF_MEMORY; } - TSWAP(pModif->pDataBlocks, pStmt->pDataBlocks, SArray*); + TSWAP(pModif->pDataBlocks, pStmt->pDataBlocks); pModif->msgType = getMsgType(pStmt->sqlNodeType); *pLogicNode = (SLogicNode*)pModif; return TSDB_CODE_SUCCESS; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index f1b16353b6..042b914927 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -246,7 +246,7 @@ static int32_t cpdMergeConds(SNode** pDst, SNodeList** pSrc) { static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) { if (NULL == *pCond) { - TSWAP(*pCond, *pAdditionalCond, SNode*); + TSWAP(*pCond, *pAdditionalCond); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 707e6aac14..548957ab8e 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1097,7 +1097,7 @@ static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlock pInserter->numOfTables = pBlocks->numOfTables; pInserter->size = pBlocks->size; - TSWAP(pInserter->pData, pBlocks->pData, char*); + TSWAP(pInserter->pData, pBlocks->pData); *pSink = (SDataSinkNode*)pInserter; return TSDB_CODE_SUCCESS; diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 51bd36f9f9..1266e8ae4b 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -65,7 +65,7 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode* pSubplan->id.groupId = pCxt->groupId; pSubplan->subplanType = SUBPLAN_TYPE_SCAN; pSubplan->pNode = (SLogicNode*)nodesCloneNode(pScan); - TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pSubplan->pNode)->pVgroupList, SVgroupsInfo*); + TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pSubplan->pNode)->pVgroupList); SPLIT_FLAG_SET_MASK(pSubplan->splitFlag, flag); return pSubplan; } @@ -406,8 +406,7 @@ int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan } if (QUERY_NODE_LOGIC_PLAN_VNODE_MODIF == nodeType(pLogicNode)) { pSubplan->subplanType = SUBPLAN_TYPE_MODIFY; - TSWAP(((SVnodeModifLogicNode*)pLogicNode)->pDataBlocks, ((SVnodeModifLogicNode*)pSubplan->pNode)->pDataBlocks, - SArray*); + TSWAP(((SVnodeModifLogicNode*)pLogicNode)->pDataBlocks, ((SVnodeModifLogicNode*)pSubplan->pNode)->pDataBlocks); } else { pSubplan->subplanType = SUBPLAN_TYPE_SCAN; } diff --git a/source/os/src/osSemaphore.c b/source/os/src/osSemaphore.c index 9475625413..7df4c26afd 100644 --- a/source/os/src/osSemaphore.c +++ b/source/os/src/osSemaphore.c @@ -67,6 +67,12 @@ int32_t tsem_wait(tsem_t* sem) { return ret; } +int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) { + int ret = 0; + + return ret; +} + #elif defined(_TD_DARWIN_64) /* diff --git a/source/util/test/encodeTest.cpp b/source/util/test/encodeTest.cpp index 9ddbd24353..95ea6b1674 100644 --- a/source/util/test/encodeTest.cpp +++ b/source/util/test/encodeTest.cpp @@ -230,7 +230,7 @@ static int32_t tSStructA_v1_decode(SCoder *pCoder, SStructA_v1 *pSAV1) { const char *tstr; uint64_t len; if (tDecodeCStrAndLen(pCoder, &tstr, &len) < 0) return -1; - pSAV1->A_c = (char *)TCODER_MALLOC(pCoder, len + 1); + pSAV1->A_c = (char *)tCoderMalloc(pCoder, len + 1); memcpy(pSAV1->A_c, tstr, len + 1); tEndDecode(pCoder); @@ -269,7 +269,7 @@ static int32_t tSStructA_v2_decode(SCoder *pCoder, SStructA_v2 *pSAV2) { const char *tstr; uint64_t len; if (tDecodeCStrAndLen(pCoder, &tstr, &len) < 0) return -1; - pSAV2->A_c = (char *)TCODER_MALLOC(pCoder, len + 1); + pSAV2->A_c = (char *)tCoderMalloc(pCoder, len + 1); memcpy(pSAV2->A_c, tstr, len + 1); // ------------------------NEW FIELDS DECODE------------------------------- @@ -305,7 +305,7 @@ static int32_t tSFinalReq_v1_encode(SCoder *pCoder, const SFinalReq_v1 *ps1) { static int32_t tSFinalReq_v1_decode(SCoder *pCoder, SFinalReq_v1 *ps1) { if (tStartDecode(pCoder) < 0) return -1; - ps1->pA = (SStructA_v1 *)TCODER_MALLOC(pCoder, sizeof(*(ps1->pA))); + ps1->pA = (SStructA_v1 *)tCoderMalloc(pCoder, sizeof(*(ps1->pA))); if (tSStructA_v1_decode(pCoder, ps1->pA) < 0) return -1; if (tDecodeI32(pCoder, &ps1->v_a) < 0) return -1; if (tDecodeI8(pCoder, &ps1->v_b) < 0) return -1; @@ -339,7 +339,7 @@ static int32_t tSFinalReq_v2_encode(SCoder *pCoder, const SFinalReq_v2 *ps2) { static int32_t tSFinalReq_v2_decode(SCoder *pCoder, SFinalReq_v2 *ps2) { if (tStartDecode(pCoder) < 0) return -1; - ps2->pA = (SStructA_v2 *)TCODER_MALLOC(pCoder, sizeof(*(ps2->pA))); + ps2->pA = (SStructA_v2 *)tCoderMalloc(pCoder, sizeof(*(ps2->pA))); if (tSStructA_v2_decode(pCoder, ps2->pA) < 0) return -1; if (tDecodeI32(pCoder, &ps2->v_a) < 0) return -1; if (tDecodeI8(pCoder, &ps2->v_b) < 0) return -1; diff --git a/tools/shell/inc/shellInt.h b/tools/shell/inc/shellInt.h index d218bbf373..382009905c 100644 --- a/tools/shell/inc/shellInt.h +++ b/tools/shell/inc/shellInt.h @@ -111,6 +111,5 @@ void shellTestNetWork(); // shellMain.c extern SShellObj shell; -extern void taos_init(); #endif /*_TD_SHELL_INT_H_*/