diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 83a4b0ffcb..083d96e975 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -401,7 +401,7 @@ pipeline { } } stage('linux test') { - agent{label "slave1_47 || slave1_48 || slave1_49 || slave1_50 || slave1_52 || worker03 || slave215 || slave217 || slave219 "} + agent{label "slave1_47 || slave1_48 || slave1_49 || slave1_50 || slave1_52 || slave1_59 || slave1_63 || worker03 || slave215 || slave217 || slave219 "} options { skipDefaultCheckout() } when { changeRequest() @@ -454,7 +454,7 @@ pipeline { cd ${WKC}/tests/parallel_test export DEFAULT_RETRY_TIME=2 date - ''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 900 ''' + extra_param + ''' + ''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 1200 ''' + extra_param + ''' ''' } } diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 2078455f1d..347fb203ef 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -192,6 +192,7 @@ typedef struct SBoundColInfo { int16_t* pColIndex; // bound index => schema index int32_t numOfCols; int32_t numOfBound; + bool hasBoundCols; } SBoundColInfo; typedef struct STableColsData { diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 9c760a465a..41c9184d27 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -556,6 +556,7 @@ int32_t taosGetErrSize(); #define TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x061B) #define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061C) #define TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE TAOS_DEF_ERROR_CODE(0, 0x061D) +#define TSDB_CODE_TDB_INCONSISTENT_DB_ID TAOS_DEF_ERROR_CODE(0, 0x061E) // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) diff --git a/source/dnode/vnode/src/vnd/vnodeAsync.c b/source/dnode/vnode/src/vnd/vnodeAsync.c index 6d6533463b..126c394f54 100644 --- a/source/dnode/vnode/src/vnd/vnodeAsync.c +++ b/source/dnode/vnode/src/vnd/vnodeAsync.c @@ -190,10 +190,10 @@ static int32_t vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) { task->prev->next = task->next; task->next->prev = task->prev; if (task->cancel) { - taosArrayPush(cancelArray, &(SVATaskCancelInfo){ - .cancel = task->cancel, - .arg = task->arg, - }); + TAOS_UNUSED(taosArrayPush(cancelArray, &(SVATaskCancelInfo){ + .cancel = task->cancel, + .arg = task->arg, + })); } vnodeAsyncTaskDone(async, task); } @@ -206,6 +206,9 @@ static void *vnodeAsyncLoop(void *arg) { SVWorker *worker = (SVWorker *)arg; SVAsync *async = worker->async; SArray *cancelArray = taosArrayInit(0, sizeof(SVATaskCancelInfo)); + if (cancelArray == NULL) { + return NULL; + } setThreadName(async->label); @@ -466,7 +469,7 @@ int32_t vnodeAsyncOpen(int32_t numOfThreads) { vnodeAsyncSetWorkers(2, numOfThreads); _exit: - return 0; + return code; } int32_t vnodeAsyncClose() { @@ -748,10 +751,10 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { task->prev->next = task->next; task->next->prev = task->prev; if (task->cancel) { - taosArrayPush(cancelArray, &(SVATaskCancelInfo){ - .cancel = task->cancel, - .arg = task->arg, - }); + TAOS_UNUSED(taosArrayPush(cancelArray, &(SVATaskCancelInfo){ + .cancel = task->cancel, + .arg = task->arg, + })); } vnodeAsyncTaskDone(async, task); } @@ -763,10 +766,10 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { channel->scheduled->prev->next = channel->scheduled->next; channel->scheduled->next->prev = channel->scheduled->prev; if (channel->scheduled->cancel) { - taosArrayPush(cancelArray, &(SVATaskCancelInfo){ - .cancel = channel->scheduled->cancel, - .arg = channel->scheduled->arg, - }); + TAOS_UNUSED(taosArrayPush(cancelArray, &(SVATaskCancelInfo){ + .cancel = channel->scheduled->cancel, + .arg = channel->scheduled->arg, + })); } vnodeAsyncTaskDone(async, channel->scheduled); } diff --git a/source/dnode/vnode/src/vnd/vnodeBufPool.c b/source/dnode/vnode/src/vnd/vnodeBufPool.c index 40112c5579..ad183839d7 100644 --- a/source/dnode/vnode/src/vnd/vnodeBufPool.c +++ b/source/dnode/vnode/src/vnd/vnodeBufPool.c @@ -16,13 +16,12 @@ #include "vnd.h" /* ------------------------ STRUCTURES ------------------------ */ -static int vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBufPool **ppPool) { +static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBufPool **ppPool) { SVBufPool *pPool; pPool = taosMemoryMalloc(sizeof(SVBufPool) + size); if (pPool == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return terrno = TSDB_CODE_OUT_OF_MEMORY; } memset(pPool, 0, sizeof(SVBufPool)); @@ -44,14 +43,12 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBufPoo pPool->lock = taosMemoryMalloc(sizeof(TdThreadSpinlock)); if (!pPool->lock) { taosMemoryFree(pPool); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return terrno = TSDB_CODE_OUT_OF_MEMORY; } if (taosThreadSpinInit(pPool->lock, 0) != 0) { taosMemoryFree((void *)pPool->lock); taosMemoryFree(pPool); - terrno = TAOS_SYSTEM_ERROR(errno); - return -1; + return terrno = TAOS_SYSTEM_ERROR(errno); } } else { pPool->lock = NULL; @@ -77,10 +74,11 @@ int vnodeOpenBufPool(SVnode *pVnode) { for (int i = 0; i < VNODE_BUFPOOL_SEGMENTS; i++) { // create pool - if (vnodeBufPoolCreate(pVnode, i, size, &pVnode->aBufPool[i])) { + int32_t code; + if ((code = vnodeBufPoolCreate(pVnode, i, size, &pVnode->aBufPool[i]))) { vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno)); vnodeCloseBufPool(pVnode); - return -1; + return code; } // add to free list @@ -274,8 +272,6 @@ _exit: } int32_t vnodeBufPoolRegisterQuery(SVBufPool *pPool, SQueryNode *pQNode) { - int32_t code = 0; - taosThreadMutexLock(&pPool->mutex); pQNode->pNext = pPool->qList.pNext; @@ -285,9 +281,7 @@ int32_t vnodeBufPoolRegisterQuery(SVBufPool *pPool, SQueryNode *pQNode) { pPool->nQuery++; taosThreadMutexUnlock(&pPool->mutex); - -_exit: - return code; + return 0; } void vnodeBufPoolDeregisterQuery(SVBufPool *pPool, SQueryNode *pQNode, bool proactive) { diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index c7b54d36b6..85981ac9aa 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -394,8 +394,7 @@ int vnodeValidateTableHash(SVnode *pVnode, char *tableFName) { } if (hashValue < pVnode->config.hashBegin || hashValue > pVnode->config.hashEnd) { - terrno = TSDB_CODE_VND_HASH_MISMATCH; - return -1; + return terrno = TSDB_CODE_VND_HASH_MISMATCH; } return 0; diff --git a/source/dnode/vnode/src/vnd/vnodeInitApi.c b/source/dnode/vnode/src/vnd/vnodeInitApi.c index 48852dd159..9be84b99f4 100644 --- a/source/dnode/vnode/src/vnd/vnodeInitApi.c +++ b/source/dnode/vnode/src/vnd/vnodeInitApi.c @@ -129,17 +129,17 @@ void initTqAPI(SStoreTqReader* pTq) { pTq->tqReaderIsQueriedTable = tqReaderIsQueriedTable; pTq->tqReaderCurrentBlockConsumed = tqCurrentBlockConsumed; - pTq->tqReaderGetWalReader = tqGetWalReader; // todo remove it -// pTq->tqReaderRetrieveTaosXBlock = tqRetrieveTaosxBlock; // todo remove it + pTq->tqReaderGetWalReader = tqGetWalReader; // todo remove it + // pTq->tqReaderRetrieveTaosXBlock = tqRetrieveTaosxBlock; // todo remove it pTq->tqReaderSetSubmitMsg = tqReaderSetSubmitMsg; // todo remove it pTq->tqGetResultBlock = tqGetResultBlock; -// pTq->tqReaderNextBlockFilterOut = tqNextDataBlockFilterOut; + // pTq->tqReaderNextBlockFilterOut = tqNextDataBlockFilterOut; pTq->tqGetResultBlockTime = tqGetResultBlockTime; pTq->tqGetStreamExecProgress = tqGetStreamExecInfo; - } +} void initStateStoreAPI(SStateStore* pStore) { pStore->streamFileStateInit = streamFileStateInit; diff --git a/source/dnode/vnode/src/vnd/vnodeModule.c b/source/dnode/vnode/src/vnd/vnodeModule.c index 3a454c53ef..228cc9e0b2 100644 --- a/source/dnode/vnode/src/vnd/vnodeModule.c +++ b/source/dnode/vnode/src/vnd/vnodeModule.c @@ -19,31 +19,19 @@ static volatile int32_t VINIT = 0; int vnodeInit(int nthreads) { - int32_t init; - - init = atomic_val_compare_exchange_32(&VINIT, 0, 1); - if (init) { + if (atomic_val_compare_exchange_32(&VINIT, 0, 1)) { return 0; } - if (vnodeAsyncOpen(nthreads) != 0) { - return -1; - } - - if (walInit() < 0) { - return -1; - } + TAOS_CHECK_RETURN(vnodeAsyncOpen(nthreads)); + TAOS_CHECK_RETURN(walInit()); return 0; } void vnodeCleanup() { - int32_t init = atomic_val_compare_exchange_32(&VINIT, 1, 0); - if (init == 0) return; - - // set stop + if (atomic_val_compare_exchange_32(&VINIT, 1, 0) == 0) return; vnodeAsyncClose(); - walCleanUp(); smaCleanUp(); } diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index 23fa8d000b..534070c540 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -106,7 +106,7 @@ int32_t ctgTestRspIdx = 0; void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) { SCreateDbReq createReq = {0}; - strcpy(createReq.db, "1.db1"); + TAOS_STRCPY(createReq.db, "1.db1"); createReq.numOfVgroups = 2; createReq.buffer = -1; createReq.pageSize = -1; @@ -127,16 +127,19 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) { createReq.ignoreExist = 1; int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSCreateDbReq(pReq, contLen, &createReq); - + ASSERT(pReq != NULL); + contLen = tSerializeSCreateDbReq(pReq, contLen, &createReq); + ASSERT(contLen > 0); + SRpcMsg rpcMsg = {0}; rpcMsg.pCont = pReq; rpcMsg.contLen = contLen; rpcMsg.msgType = TDMT_MND_CREATE_DB; SRpcMsg rpcRsp = {0}; - rpcSendRecv(shandle, pEpSet, &rpcMsg, &rpcRsp); + ASSERT(0 == rpcSendRecv(shandle, pEpSet, &rpcMsg, &rpcRsp)); ASSERT_EQ(rpcRsp.code, 0); } @@ -152,15 +155,16 @@ void ctgTestInitLogFile() { tsAsyncLog = 0; qDebugFlag = 159; tmrDebugFlag = 159; - strcpy(tsLogDir, TD_LOG_DIR_PATH); + TAOS_STRCPY(tsLogDir, TD_LOG_DIR_PATH); - ctgdEnableDebug("api", true); - ctgdEnableDebug("meta", true); - ctgdEnableDebug("cache", true); - ctgdEnableDebug("lock", true); + (void)ctgdEnableDebug("api", true); + (void)ctgdEnableDebug("meta", true); + (void)ctgdEnableDebug("cache", true); + (void)ctgdEnableDebug("lock", true); if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) { - printf("failed to open log file in directory:%s\n", tsLogDir); + (void)printf("failed to open log file in directory:%s\n", tsLogDir); + ASSERT(0); } } @@ -170,21 +174,21 @@ int32_t ctgTestGetVgNumFromVgVersion(int32_t vgVersion) { void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) { SName cn = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(cn.dbname, "db1"); - strcpy(cn.tname, ctgTestCTablename); + TAOS_STRCPY(cn.dbname, "db1"); + TAOS_STRCPY(cn.tname, ctgTestCTablename); SName sn = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(sn.dbname, "db1"); - strcpy(sn.tname, ctgTestSTablename); + TAOS_STRCPY(sn.dbname, "db1"); + TAOS_STRCPY(sn.tname, ctgTestSTablename); char db[TSDB_DB_FNAME_LEN] = {0}; - tNameGetFullDbName(&cn, db); + (void)tNameGetFullDbName(&cn, db); - strcpy(output->dbFName, db); + TAOS_STRCPY(output->dbFName, db); SET_META_TYPE_BOTH_TABLE(output->metaType); - strcpy(output->ctbName, cn.tname); - strcpy(output->tbName, sn.tname); + TAOS_STRCPY(output->ctbName, cn.tname); + TAOS_STRCPY(output->tbName, sn.tname); output->ctbMeta.vgId = 9; output->ctbMeta.tableType = TSDB_CHILD_TABLE; @@ -193,6 +197,7 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) { output->tbMeta = (STableMeta *)taosMemoryCalloc(1, sizeof(STableMeta) + sizeof(SSchema) * (ctgTestColNum + ctgTestColNum)); + ASSERT(NULL != output->tbMeta); output->tbMeta->vgId = 9; output->tbMeta->tableType = TSDB_SUPER_TABLE; output->tbMeta->uid = 2; @@ -209,19 +214,19 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) { s->type = TSDB_DATA_TYPE_TIMESTAMP; s->colId = 1; s->bytes = 8; - strcpy(s->name, "ts"); + TAOS_STRCPY(s->name, "ts"); s = &output->tbMeta->schema[1]; s->type = TSDB_DATA_TYPE_INT; s->colId = 2; s->bytes = 4; - strcpy(s->name, "col1s"); + TAOS_STRCPY(s->name, "col1s"); s = &output->tbMeta->schema[2]; s->type = TSDB_DATA_TYPE_BINARY; s->colId = 3; s->bytes = 12; - strcpy(s->name, "tag1s"); + TAOS_STRCPY(s->name, "tag1s"); } void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) { @@ -229,7 +234,8 @@ void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) { int32_t vgNum = 0; SVgroupInfo vgInfo = {0}; SDBVgInfo *dbVgroup = (SDBVgInfo *)taosMemoryCalloc(1, sizeof(SDBVgInfo)); - + ASSERT(NULL != dbVgroup); + dbVgroup->vgVersion = vgVersion++; ctgTestCurrentVgVersion = dbVgroup->vgVersion; @@ -238,6 +244,7 @@ void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) { dbVgroup->hashPrefix = 0; dbVgroup->hashSuffix = 0; dbVgroup->vgHash = taosHashInit(ctgTestVgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); + ASSERT(NULL != dbVgroup->vgHash); vgNum = ctgTestGetVgNumFromVgVersion(dbVgroup->vgVersion); uint32_t hashUnit = UINT32_MAX / vgNum; @@ -250,20 +257,20 @@ void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) { vgInfo.epSet.inUse = i % vgInfo.epSet.numOfEps; for (int32_t n = 0; n < vgInfo.epSet.numOfEps; ++n) { SEp *addr = &vgInfo.epSet.eps[n]; - strcpy(addr->fqdn, "a0"); + TAOS_STRCPY(addr->fqdn, "a0"); addr->port = n + 22; } - taosHashPut(dbVgroup->vgHash, &vgInfo.vgId, sizeof(vgInfo.vgId), &vgInfo, sizeof(vgInfo)); + ASSERT(0 == taosHashPut(dbVgroup->vgHash, &vgInfo.vgId, sizeof(vgInfo.vgId), &vgInfo, sizeof(vgInfo))); } *pdbVgroup = dbVgroup; } void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) { - strcpy(rspMsg->dbFName, ctgTestDbname); - sprintf(rspMsg->tbName, "%s", ctgTestSTablename); - sprintf(rspMsg->stbName, "%s", ctgTestSTablename); + TAOS_STRCPY(rspMsg->dbFName, ctgTestDbname); + (void)sprintf(rspMsg->tbName, "%s", ctgTestSTablename); + (void)sprintf(rspMsg->stbName, "%s", ctgTestSTablename); rspMsg->numOfTags = ctgTestTagNum; rspMsg->numOfColumns = ctgTestColNum; rspMsg->precision = 1 + 1; @@ -275,41 +282,43 @@ void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) { rspMsg->vgId = 1; rspMsg->pSchemas = (SSchema *)taosMemoryCalloc(rspMsg->numOfTags + rspMsg->numOfColumns, sizeof(SSchema)); - + ASSERT(NULL != rspMsg->pSchemas); + SSchema *s = NULL; s = &rspMsg->pSchemas[0]; s->type = TSDB_DATA_TYPE_TIMESTAMP; s->colId = 1; s->bytes = 8; - strcpy(s->name, "ts"); + TAOS_STRCPY(s->name, "ts"); s = &rspMsg->pSchemas[1]; s->type = TSDB_DATA_TYPE_INT; s->colId = 2; s->bytes = 4; - strcpy(s->name, "col1s"); + TAOS_STRCPY(s->name, "col1s"); s = &rspMsg->pSchemas[2]; s->type = TSDB_DATA_TYPE_BINARY; s->colId = 3; s->bytes = 12 + 1; - strcpy(s->name, "tag1s"); + TAOS_STRCPY(s->name, "tag1s"); return; } -void ctgTestRspDbVgroups(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { +int32_t ctgTestRspDbVgroups(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { rpcFreeCont(pMsg->pCont); SUseDbRsp usedbRsp = {0}; - strcpy(usedbRsp.db, ctgTestDbname); + TAOS_STRCPY(usedbRsp.db, ctgTestDbname); usedbRsp.vgVersion = ctgTestVgVersion; ctgTestCurrentVgVersion = ctgTestVgVersion; usedbRsp.vgNum = ctgTestVgNum; usedbRsp.hashMethod = 0; usedbRsp.uid = ctgTestDbId; usedbRsp.pVgroupInfos = taosArrayInit(usedbRsp.vgNum, sizeof(SVgroupInfo)); - + ASSERT(NULL != usedbRsp.pVgroupInfos); + uint32_t hashUnit = UINT32_MAX / ctgTestVgNum; for (int32_t i = 0; i < ctgTestVgNum; ++i) { SVgroupInfo vg = {0}; @@ -324,31 +333,36 @@ void ctgTestRspDbVgroups(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg * vg.epSet.inUse = i % vg.epSet.numOfEps; for (int32_t n = 0; n < vg.epSet.numOfEps; ++n) { SEp *addr = &vg.epSet.eps[n]; - strcpy(addr->fqdn, "a0"); + TAOS_STRCPY(addr->fqdn, "a0"); addr->port = n + 22; } vg.numOfTable = i % 2; - taosArrayPush(usedbRsp.pVgroupInfos, &vg); + ASSERT(NULL != taosArrayPush(usedbRsp.pVgroupInfos, &vg)); } int32_t contLen = tSerializeSUseDbRsp(NULL, 0, &usedbRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSUseDbRsp(pReq, contLen, &usedbRsp); + ASSERT(pReq != NULL); + contLen = tSerializeSUseDbRsp(pReq, contLen, &usedbRsp); + ASSERT(contLen > 0); pRsp->code = 0; pRsp->contLen = contLen; pRsp->pCont = pReq; taosArrayDestroy(usedbRsp.pVgroupInfos); + + return 0; } -void ctgTestRspTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { +int32_t ctgTestRspTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { rpcFreeCont(pMsg->pCont); STableMetaRsp metaRsp = {0}; - strcpy(metaRsp.dbFName, ctgTestDbname); - strcpy(metaRsp.tbName, ctgTestTablename); + TAOS_STRCPY(metaRsp.dbFName, ctgTestDbname); + TAOS_STRCPY(metaRsp.tbName, ctgTestTablename); metaRsp.numOfTags = 0; metaRsp.numOfColumns = ctgTestColNum; metaRsp.precision = 1; @@ -359,29 +373,38 @@ void ctgTestRspTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg * metaRsp.tuid = ctgTestNormalTblUid++; metaRsp.vgId = 8; metaRsp.pSchemas = (SSchema *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema)); + ASSERT(NULL != metaRsp.pSchemas); + metaRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchemaExt)); + ASSERT(NULL != metaRsp.pSchemaExt); + SSchema *s = NULL; s = &metaRsp.pSchemas[0]; s->type = TSDB_DATA_TYPE_TIMESTAMP; s->colId = 1; s->bytes = 8; - strcpy(s->name, "ts"); + TAOS_STRCPY(s->name, "ts"); s = &metaRsp.pSchemas[1]; s->type = TSDB_DATA_TYPE_INT; s->colId = 2; s->bytes = 4; - strcpy(s->name, "col1"); + TAOS_STRCPY(s->name, "col1"); int32_t contLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSTableMetaRsp(pReq, contLen, &metaRsp); - + ASSERT(pReq != NULL); + contLen = tSerializeSTableMetaRsp(pReq, contLen, &metaRsp); + ASSERT(contLen > 0); + pRsp->code = 0; pRsp->contLen = contLen; pRsp->pCont = pReq; tFreeSTableMetaRsp(&metaRsp); + + return 0; } void ctgTestRspTableMetaNotExist(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { @@ -390,13 +413,13 @@ void ctgTestRspTableMetaNotExist(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, S pRsp->code = CTG_ERR_CODE_TABLE_NOT_EXIST; } -void ctgTestRspCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { +int32_t ctgTestRspCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { rpcFreeCont(pMsg->pCont); STableMetaRsp metaRsp = {0}; - strcpy(metaRsp.dbFName, ctgTestDbname); - strcpy(metaRsp.tbName, ctgTestCurrentCTableName ? ctgTestCurrentCTableName : ctgTestCTablename); - strcpy(metaRsp.stbName, ctgTestSTablename); + TAOS_STRCPY(metaRsp.dbFName, ctgTestDbname); + TAOS_STRCPY(metaRsp.tbName, ctgTestCurrentCTableName ? ctgTestCurrentCTableName : ctgTestCTablename); + TAOS_STRCPY(metaRsp.stbName, ctgTestSTablename); metaRsp.numOfTags = ctgTestTagNum; metaRsp.numOfColumns = ctgTestColNum; metaRsp.precision = 1; @@ -407,44 +430,54 @@ void ctgTestRspCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg metaRsp.tuid = 0x0000000000000003; metaRsp.vgId = 9; metaRsp.pSchemas = (SSchema *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema)); + ASSERT(NULL != metaRsp.pSchemas); + metaRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchemaExt)); + ASSERT(NULL != metaRsp.pSchemaExt); + SSchema *s = NULL; s = &metaRsp.pSchemas[0]; s->type = TSDB_DATA_TYPE_TIMESTAMP; s->colId = 1; s->bytes = 8; - strcpy(s->name, "ts"); + TAOS_STRCPY(s->name, "ts"); s = &metaRsp.pSchemas[1]; s->type = TSDB_DATA_TYPE_INT; s->colId = 2; s->bytes = 4; - strcpy(s->name, "col1s"); + TAOS_STRCPY(s->name, "col1s"); s = &metaRsp.pSchemas[2]; s->type = TSDB_DATA_TYPE_BINARY; s->colId = 3; s->bytes = 12; - strcpy(s->name, "tag1s"); + TAOS_STRCPY(s->name, "tag1s"); int32_t contLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSTableMetaRsp(pReq, contLen, &metaRsp); + ASSERT(pReq != NULL); + contLen = tSerializeSTableMetaRsp(pReq, contLen, &metaRsp); + ASSERT(contLen > 0); + pRsp->code = 0; pRsp->contLen = contLen; pRsp->pCont = pReq; tFreeSTableMetaRsp(&metaRsp); + + return 0; } -void ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { +int32_t ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { rpcFreeCont(pMsg->pCont); STableMetaRsp metaRsp = {0}; - strcpy(metaRsp.dbFName, ctgTestDbname); - strcpy(metaRsp.tbName, ctgTestCurrentSTableName ? ctgTestCurrentSTableName : ctgTestSTablename); - strcpy(metaRsp.stbName, ctgTestSTablename); + TAOS_STRCPY(metaRsp.dbFName, ctgTestDbname); + TAOS_STRCPY(metaRsp.tbName, ctgTestCurrentSTableName ? ctgTestCurrentSTableName : ctgTestSTablename); + TAOS_STRCPY(metaRsp.stbName, ctgTestSTablename); metaRsp.numOfTags = ctgTestTagNum; metaRsp.numOfColumns = ctgTestColNum; metaRsp.precision = 1; @@ -455,46 +488,55 @@ void ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg metaRsp.tuid = ctgTestSuid + 1; metaRsp.vgId = 0; metaRsp.pSchemas = (SSchema *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema)); + ASSERT(NULL != metaRsp.pSchemas); + + metaRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchemaExt)); + ASSERT(NULL != metaRsp.pSchemaExt); SSchema *s = NULL; s = &metaRsp.pSchemas[0]; s->type = TSDB_DATA_TYPE_TIMESTAMP; s->colId = 1; s->bytes = 8; - strcpy(s->name, "ts"); + TAOS_STRCPY(s->name, "ts"); s = &metaRsp.pSchemas[1]; s->type = TSDB_DATA_TYPE_INT; s->colId = 2; s->bytes = 4; - strcpy(s->name, "col1s"); + TAOS_STRCPY(s->name, "col1s"); s = &metaRsp.pSchemas[2]; s->type = TSDB_DATA_TYPE_BINARY; s->colId = 3; s->bytes = 12; - strcpy(s->name, "tag1s"); + TAOS_STRCPY(s->name, "tag1s"); int32_t contLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSTableMetaRsp(pReq, contLen, &metaRsp); + ASSERT(pReq != NULL); + contLen = tSerializeSTableMetaRsp(pReq, contLen, &metaRsp); + ASSERT(contLen > 0); pRsp->code = 0; pRsp->contLen = contLen; pRsp->pCont = pReq; tFreeSTableMetaRsp(&metaRsp); + + return 0; } -void ctgTestRspMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { +int32_t ctgTestRspMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { rpcFreeCont(pMsg->pCont); static int32_t idx = 1; STableMetaRsp metaRsp = {0}; - strcpy(metaRsp.dbFName, ctgTestDbname); - sprintf(metaRsp.tbName, "%s_%d", ctgTestSTablename, idx); - sprintf(metaRsp.stbName, "%s_%d", ctgTestSTablename, idx); + TAOS_STRCPY(metaRsp.dbFName, ctgTestDbname); + (void)sprintf(metaRsp.tbName, "%s_%d", ctgTestSTablename, idx); + (void)sprintf(metaRsp.stbName, "%s_%d", ctgTestSTablename, idx); metaRsp.numOfTags = ctgTestTagNum; metaRsp.numOfColumns = ctgTestColNum; metaRsp.precision = 1; @@ -505,37 +547,46 @@ void ctgTestRspMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRp metaRsp.tuid = ctgTestSuid + idx; metaRsp.vgId = 0; metaRsp.pSchemas = (SSchema *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema)); + ASSERT(NULL != metaRsp.pSchemas); + + metaRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchemaExt)); + ASSERT(NULL != metaRsp.pSchemaExt); SSchema *s = NULL; s = &metaRsp.pSchemas[0]; s->type = TSDB_DATA_TYPE_TIMESTAMP; s->colId = 1; s->bytes = 8; - strcpy(s->name, "ts"); + TAOS_STRCPY(s->name, "ts"); s = &metaRsp.pSchemas[1]; s->type = TSDB_DATA_TYPE_INT; s->colId = 2; s->bytes = 4; - strcpy(s->name, "col1s"); + TAOS_STRCPY(s->name, "col1s"); s = &metaRsp.pSchemas[2]; s->type = TSDB_DATA_TYPE_BINARY; s->colId = 3; s->bytes = 12; - strcpy(s->name, "tag1s"); + TAOS_STRCPY(s->name, "tag1s"); ++idx; int32_t contLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSTableMetaRsp(pReq, contLen, &metaRsp); + ASSERT(pReq != NULL); + contLen = tSerializeSTableMetaRsp(pReq, contLen, &metaRsp); + ASSERT(contLen > 0); pRsp->code = 0; pRsp->contLen = contLen; pRsp->pCont = pReq; tFreeSTableMetaRsp(&metaRsp); + + return 0; } void ctgTestRspErrIndexInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { @@ -550,14 +601,17 @@ void ctgTestRspUserAuth(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *p rpcFreeCont(pMsg->pCont); SGetUserAuthRsp userRsp = {0}; - strcpy(userRsp.user, ctgTestUsername); + TAOS_STRCPY(userRsp.user, ctgTestUsername); userRsp.version = 1; userRsp.superAuth = 1; userRsp.enable = 1; int32_t contLen = tSerializeSGetUserAuthRsp(NULL, 0, &userRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSGetUserAuthRsp(pReq, contLen, &userRsp); + ASSERT(pReq != NULL); + contLen = tSerializeSGetUserAuthRsp(pReq, contLen, &userRsp); + ASSERT(contLen > 0); pRsp->code = 0; pRsp->contLen = contLen; @@ -570,27 +624,34 @@ void ctgTestRspTableCfg(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *p static int32_t idx = 1; STableCfgRsp tblRsp = {0}; - strcpy(tblRsp.tbName, ctgTestTablename); + TAOS_STRCPY(tblRsp.tbName, ctgTestTablename); tblRsp.numOfColumns = ctgTestColNum; tblRsp.pSchemas = (SSchema *)taosMemoryMalloc((tblRsp.numOfTags + tblRsp.numOfColumns) * sizeof(SSchema)); + ASSERT(tblRsp.pSchemas != NULL); + + tblRsp.pSchemaExt = (SSchemaExt *)taosMemoryMalloc((tblRsp.numOfTags + tblRsp.numOfColumns) * sizeof(SSchemaExt)); + ASSERT(NULL != tblRsp.pSchemaExt); SSchema *s = NULL; s = &tblRsp.pSchemas[0]; s->type = TSDB_DATA_TYPE_TIMESTAMP; s->colId = 1; s->bytes = 8; - strcpy(s->name, "ts"); + TAOS_STRCPY(s->name, "ts"); s = &tblRsp.pSchemas[1]; s->type = TSDB_DATA_TYPE_INT; s->colId = 2; s->bytes = 4; - strcpy(s->name, "col1"); + TAOS_STRCPY(s->name, "col1"); int32_t contLen = tSerializeSTableCfgRsp(NULL, 0, &tblRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSTableCfgRsp(pReq, contLen, &tblRsp); + ASSERT(pReq != NULL); + contLen = tSerializeSTableCfgRsp(pReq, contLen, &tblRsp); + ASSERT(contLen > 0); pRsp->code = 0; pRsp->contLen = contLen; @@ -605,20 +666,24 @@ void ctgTestRspTableIndex(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg static int32_t idx = 1; STableIndexRsp tblRsp = {0}; - strcpy(tblRsp.tbName, ctgTestSTablename); + TAOS_STRCPY(tblRsp.tbName, ctgTestSTablename); tblRsp.pIndex = taosArrayInit(ctgTestIndexNum, sizeof(STableIndexInfo)); - + ASSERT(NULL != tblRsp.pIndex); + STableIndexInfo info = {0}; for (int32_t i = 0; i < ctgTestIndexNum; ++i) { info.interval = 1 + i; info.expr = (char *)taosMemoryCalloc(1, 10); - taosArrayPush(tblRsp.pIndex, &info); + ASSERT(NULL != taosArrayPush(tblRsp.pIndex, &info)); } int32_t contLen = tSerializeSTableIndexRsp(NULL, 0, &tblRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSTableIndexRsp(pReq, contLen, &tblRsp); + ASSERT(pReq != NULL); + contLen = tSerializeSTableIndexRsp(pReq, contLen, &tblRsp); + ASSERT(contLen > 0); pRsp->code = 0; pRsp->contLen = contLen; @@ -636,8 +701,11 @@ void ctgTestRspDBCfg(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp dbRsp.numOfVgroups = ctgTestVgNum; int32_t contLen = tSerializeSDbCfgRsp(NULL, 0, &dbRsp); + ASSERT(contLen > 0); void *pReq = rpcMallocCont(contLen); - tSerializeSDbCfgRsp(pReq, contLen, &dbRsp); + ASSERT(pReq != NULL); + contLen = tSerializeSDbCfgRsp(pReq, contLen, &dbRsp); + ASSERT(contLen > 0); pRsp->code = 0; pRsp->contLen = contLen; @@ -653,15 +721,18 @@ void ctgTestRspQnodeList(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg * SQueryNodeLoad nodeLoad = {0}; nodeLoad.addr.nodeId = i; - (void)taosArrayPush(qlistRsp.qnodeList, &nodeLoad); + ASSERT(NULL != taosArrayPush(qlistRsp.qnodeList, &nodeLoad)); } - int32_t rspLen = tSerializeSQnodeListRsp(NULL, 0, &qlistRsp); - void *pReq = rpcMallocCont(rspLen); - tSerializeSQnodeListRsp(pReq, rspLen, &qlistRsp); + int32_t contLen = tSerializeSQnodeListRsp(NULL, 0, &qlistRsp); + ASSERT(contLen > 0); + void *pReq = rpcMallocCont(contLen); + ASSERT(pReq != NULL); + contLen = tSerializeSQnodeListRsp(pReq, contLen, &qlistRsp); + ASSERT(contLen > 0); pRsp->code = 0; - pRsp->contLen = rspLen; + pRsp->contLen = contLen; pRsp->pCont = pReq; tFreeSQnodeListRsp(&qlistRsp); @@ -675,21 +746,24 @@ void ctgTestRspUdfInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pR funcRsp.pFuncInfos = taosArrayInit(1, sizeof(SFuncInfo)); funcRsp.pFuncExtraInfos = taosArrayInit(1, sizeof(SFuncExtraInfo)); SFuncInfo funcInfo = {0}; - strcpy(funcInfo.name, "func1"); + TAOS_STRCPY(funcInfo.name, "func1"); funcInfo.funcType = ctgTestFuncType; - (void)taosArrayPush(funcRsp.pFuncInfos, &funcInfo); + ASSERT(NULL != taosArrayPush(funcRsp.pFuncInfos, &funcInfo)); SFuncExtraInfo extraInfo = {0}; extraInfo.funcVersion = 0; extraInfo.funcCreatedTime = taosGetTimestampMs(); - (void)taosArrayPush(funcRsp.pFuncExtraInfos, &extraInfo); + ASSERT(NULL != taosArrayPush(funcRsp.pFuncExtraInfos, &extraInfo)); - int32_t rspLen = tSerializeSRetrieveFuncRsp(NULL, 0, &funcRsp); - void *pReq = rpcMallocCont(rspLen); - tSerializeSRetrieveFuncRsp(pReq, rspLen, &funcRsp); + int32_t contLen = tSerializeSRetrieveFuncRsp(NULL, 0, &funcRsp); + ASSERT(contLen > 0); + void *pReq = rpcMallocCont(contLen); + ASSERT(pReq != NULL); + contLen = tSerializeSRetrieveFuncRsp(pReq, contLen, &funcRsp); + ASSERT(contLen > 0); pRsp->code = 0; - pRsp->contLen = rspLen; + pRsp->contLen = contLen; pRsp->pCont = pReq; tFreeSRetrieveFuncRsp(&funcRsp); @@ -699,14 +773,17 @@ void ctgTestRspSvrVer(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRs rpcFreeCont(pMsg->pCont); SServerVerRsp verRsp = {0}; - strcpy(verRsp.ver, "1.0"); + TAOS_STRCPY(verRsp.ver, "1.0"); - int32_t rspLen = tSerializeSServerVerRsp(NULL, 0, &verRsp); - void *pReq = rpcMallocCont(rspLen); - tSerializeSServerVerRsp(pReq, rspLen, &verRsp); + int32_t contLen = tSerializeSServerVerRsp(NULL, 0, &verRsp); + ASSERT(contLen > 0); + void *pReq = rpcMallocCont(contLen); + ASSERT(pReq != NULL); + contLen = tSerializeSServerVerRsp(pReq, contLen, &verRsp); + ASSERT(contLen > 0); pRsp->code = 0; - pRsp->contLen = rspLen; + pRsp->contLen = contLen; pRsp->pCont = pReq; } @@ -715,19 +792,23 @@ void ctgTestRspDndeList(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *p SDnodeListRsp dRsp = {0}; dRsp.dnodeList = taosArrayInit(1, sizeof(SEpSet)); + ASSERT(dRsp.dnodeList != NULL); SEpSet epSet = {0}; epSet.numOfEps = 1; tstrncpy(epSet.eps[0].fqdn, "localhost", TSDB_FQDN_LEN); epSet.eps[0].port = 6030; - (void)taosArrayPush(dRsp.dnodeList, &epSet); + ASSERT(NULL != taosArrayPush(dRsp.dnodeList, &epSet)); - int32_t rspLen = tSerializeSDnodeListRsp(NULL, 0, &dRsp); - void *pReq = rpcMallocCont(rspLen); - tSerializeSDnodeListRsp(pReq, rspLen, &dRsp); + int32_t contLen = tSerializeSDnodeListRsp(NULL, 0, &dRsp); + ASSERT(contLen > 0); + void *pReq = rpcMallocCont(contLen); + ASSERT(pReq != NULL); + contLen = tSerializeSDnodeListRsp(pReq, contLen, &dRsp); + ASSERT(contLen > 0); pRsp->code = 0; - pRsp->contLen = rspLen; + pRsp->contLen = contLen; pRsp->pCont = pReq; tFreeSDnodeListRsp(&dRsp); @@ -767,22 +848,22 @@ void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) return; } -void ctgTestRspByIdx(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { +int32_t ctgTestRspByIdx(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { switch (ctgTestRspFunc[ctgTestRspIdx]) { case CTGT_RSP_VGINFO: - ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp); + ASSERT(0 == ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp)); break; case CTGT_RSP_TBMETA: - ctgTestRspTableMeta(shandle, pEpSet, pMsg, pRsp); + ASSERT(0 == ctgTestRspTableMeta(shandle, pEpSet, pMsg, pRsp)); break; case CTGT_RSP_CTBMETA: - ctgTestRspCTableMeta(shandle, pEpSet, pMsg, pRsp); + ASSERT(0 == ctgTestRspCTableMeta(shandle, pEpSet, pMsg, pRsp)); break; case CTGT_RSP_STBMETA: - ctgTestRspSTableMeta(shandle, pEpSet, pMsg, pRsp); + ASSERT(0 == ctgTestRspSTableMeta(shandle, pEpSet, pMsg, pRsp)); break; case CTGT_RSP_MSTBMETA: - ctgTestRspMultiSTableMeta(shandle, pEpSet, pMsg, pRsp); + ASSERT(0 == ctgTestRspMultiSTableMeta(shandle, pEpSet, pMsg, pRsp)); break; case CTGT_RSP_INDEXINFO_E: ctgTestRspErrIndexInfo(shandle, pEpSet, pMsg, pRsp); @@ -821,39 +902,39 @@ void ctgTestRspByIdx(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp ctgTestRspIdx++; - return; + return 0; } -void ctgTestRspDbVgroupsAndNormalMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { - ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp); +int32_t ctgTestRspDbVgroupsAndNormalMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { + ASSERT(0 == ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp)); ctgTestSetRspTableMeta(); - return; + return 0; } -void ctgTestRspDbVgroupsAndChildMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { - ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp); +int32_t ctgTestRspDbVgroupsAndChildMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { + ASSERT(0 == ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp)); ctgTestSetRspCTableMeta(); - return; + return 0; } -void ctgTestRspDbVgroupsAndSuperMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { - ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp); +int32_t ctgTestRspDbVgroupsAndSuperMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { + ASSERT(0 == ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp)); ctgTestSetRspSTableMeta(); - return; + return 0; } -void ctgTestRspDbVgroupsAndMultiSuperMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { - ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp); +int32_t ctgTestRspDbVgroupsAndMultiSuperMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { + ASSERT(0 == ctgTestRspDbVgroups(shandle, pEpSet, pMsg, pRsp)); ctgTestSetRspMultiSTableMeta(); - return; + return 0; } void ctgTestSetRspDbVgroups() { @@ -1069,7 +1150,7 @@ void *ctgTestGetDbVgroupThread(void *param) { while (!ctgTestStop) { code = catalogGetDBVgList(pCtg, mockPointer, ctgTestDbname, &vgList); if (code) { - printf("code:%x\n", code); + (void)printf("code:%x\n", code); assert(0); } @@ -1081,7 +1162,7 @@ void *ctgTestGetDbVgroupThread(void *param) { taosUsleep(taosRand() % 5); } if (++n % ctgTestPrintNum == 0) { - printf("Get:%d\n", n); + (void)printf("Get:%d\n", n); } } @@ -1105,7 +1186,7 @@ void *ctgTestSetSameDbVgroupThread(void *param) { taosUsleep(taosRand() % 5); } if (++n % ctgTestPrintNum == 0) { - printf("Set:%d\n", n); + (void)printf("Set:%d\n", n); } } @@ -1129,7 +1210,7 @@ void *ctgTestSetDiffDbVgroupThread(void *param) { taosUsleep(taosRand() % 5); } if (++n % ctgTestPrintNum == 0) { - printf("Set:%d\n", n); + (void)printf("Set:%d\n", n); } } @@ -1144,8 +1225,8 @@ void *ctgTestGetCtableMetaThread(void *param) { bool inCache = false; SName cn = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(cn.dbname, "db1"); - strcpy(cn.tname, ctgTestCTablename); + TAOS_STRCPY(cn.dbname, "db1"); + TAOS_STRCPY(cn.tname, ctgTestCTablename); SCtgTbMetaCtx ctx = {0}; ctx.pName = &cn; @@ -1164,7 +1245,7 @@ void *ctgTestGetCtableMetaThread(void *param) { } if (++n % ctgTestPrintNum == 0) { - printf("Get:%d\n", n); + (void)printf("Get:%d\n", n); } } @@ -1184,9 +1265,11 @@ void *ctgTestSetCtableMetaThread(void *param) { while (!ctgTestStop) { output = (STableMetaOutput *)taosMemoryMalloc(sizeof(STableMetaOutput)); + ASSERT(NULL != output); ctgTestBuildCTableMetaOutput(output); SCtgUpdateTbMetaMsg *msg = (SCtgUpdateTbMetaMsg *)taosMemoryMalloc(sizeof(SCtgUpdateTbMetaMsg)); + ASSERT(NULL != msg); msg->pCtg = pCtg; msg->pMeta = output; operation.data = msg; @@ -1200,7 +1283,7 @@ void *ctgTestSetCtableMetaThread(void *param) { taosUsleep(taosRand() % 5); } if (++n % ctgTestPrintNum == 0) { - printf("Set:%d\n", n); + (void)printf("Set:%d\n", n); } } @@ -1216,14 +1299,15 @@ void ctgTestFetchRows(TAOS_RES *result, int32_t *rows) { // fetch the records row by row while ((row = taos_fetch_row(result))) { (*rows)++; - memset(temp, 0, sizeof(temp)); - taos_print_row(temp, row, fields, num_fields); - printf("\t[%s]\n", temp); + TAOS_MEMSET(temp, 0, sizeof(temp)); + (void)taos_print_row(temp, row, fields, num_fields); + (void)printf("\t[%s]\n", temp); } } void ctgTestExecQuery(TAOS *taos, char *sql, bool fetch, int32_t *rows) { TAOS_RES *result = taos_query(taos, sql); + ASSERT(NULL != result); int code = taos_errno(result); ASSERT_EQ(code, 0); @@ -1255,8 +1339,8 @@ TEST(tableMeta, normalTable) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); code = catalogGetTableHashVgroup(pCtg, mockPointer, &n, &vgInfo); ASSERT_EQ(code, 0); @@ -1265,7 +1349,7 @@ TEST(tableMeta, normalTable) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n != 1) { taosMsleep(50); } else { @@ -1273,7 +1357,7 @@ TEST(tableMeta, normalTable) { } } - memset(&vgInfo, 0, sizeof(vgInfo)); + TAOS_MEMSET(&vgInfo, 0, sizeof(vgInfo)); bool exists = false; code = catalogGetCachedTableHashVgroup(pCtg, &n, &vgInfo, &exists); ASSERT_EQ(code, 0); @@ -1322,7 +1406,7 @@ TEST(tableMeta, normalTable) { taosMemoryFree(tableMeta); tableMeta = NULL; - catalogGetCachedTableMeta(pCtg, &n, &tableMeta); + code = catalogGetCachedTableMeta(pCtg, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 8); ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE); @@ -1345,19 +1429,19 @@ TEST(tableMeta, normalTable) { ASSERT_EQ(code, 0); if (dbNum) { - printf("got expired db,dbId:%" PRId64 "\n", dbs->dbId); + (void)printf("got expired db,dbId:%" PRId64 "\n", dbs->dbId); taosMemoryFree(dbs); dbs = NULL; } else { - printf("no expired db\n"); + (void)printf("no expired db\n"); } if (stbNum) { - printf("got expired stb,suid:%" PRId64 ",dbFName:%s, stbName:%s\n", stb->suid, stb->dbFName, stb->stbName); + (void)printf("got expired stb,suid:%" PRId64 ",dbFName:%s, stbName:%s\n", stb->suid, stb->dbFName, stb->stbName); taosMemoryFree(stb); stb = NULL; } else { - printf("no expired stb\n"); + (void)printf("no expired stb\n"); } allDbNum += dbNum; @@ -1391,8 +1475,8 @@ TEST(tableMeta, childTableCase) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestCTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestCTablename); STableMeta *tableMeta = NULL; code = catalogGetTableMeta(pCtg, mockPointer, &n, &tableMeta); @@ -1431,7 +1515,7 @@ TEST(tableMeta, childTableCase) { taosMemoryFreeClear(tableMeta); - strcpy(n.tname, ctgTestSTablename); + TAOS_STRCPY(n.tname, ctgTestSTablename); code = catalogGetTableMeta(pCtg, mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 0); @@ -1457,19 +1541,19 @@ TEST(tableMeta, childTableCase) { ASSERT_EQ(code, 0); if (dbNum) { - printf("got expired db,dbId:%" PRId64 "\n", dbs->dbId); + (void)printf("got expired db,dbId:%" PRId64 "\n", dbs->dbId); taosMemoryFree(dbs); dbs = NULL; } else { - printf("no expired db\n"); + (void)printf("no expired db\n"); } if (stbNum) { - printf("got expired stb,suid:%" PRId64 ",dbFName:%s, stbName:%s\n", stb->suid, stb->dbFName, stb->stbName); + (void)printf("got expired stb,suid:%" PRId64 ",dbFName:%s, stbName:%s\n", stb->suid, stb->dbFName, stb->stbName); taosMemoryFree(stb); stb = NULL; } else { - printf("no expired stb\n"); + (void)printf("no expired stb\n"); } allDbNum += dbNum; @@ -1501,8 +1585,8 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestSTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestSTablename); STableMeta *tableMeta = NULL; code = catalogGetTableMeta(pCtg, mockPointer, &n, &tableMeta); @@ -1548,8 +1632,8 @@ TEST(tableMeta, superTableCase) { tableMeta = NULL; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestCTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestCTablename); code = catalogGetTableMeta(pCtg, mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 9); @@ -1598,20 +1682,20 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(code, 0); if (dbNum) { - printf("got expired db,dbId:%" PRId64 "\n", dbs->dbId); + (void)printf("got expired db,dbId:%" PRId64 "\n", dbs->dbId); taosMemoryFree(dbs); dbs = NULL; } else { - printf("no expired db\n"); + (void)printf("no expired db\n"); } if (stbNum) { - printf("got expired stb,suid:%" PRId64 ",dbFName:%s, stbName:%s\n", stb->suid, stb->dbFName, stb->stbName); + (void)printf("got expired stb,suid:%" PRId64 ",dbFName:%s, stbName:%s\n", stb->suid, stb->dbFName, stb->stbName); taosMemoryFree(stb); stb = NULL; } else { - printf("no expired stb\n"); + (void)printf("no expired stb\n"); } allDbNum += dbNum; @@ -1645,8 +1729,8 @@ TEST(tableMeta, rmStbMeta) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestSTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestSTablename); STableMeta *tableMeta = NULL; code = catalogGetTableMeta(pCtg, mockPointer, &n, &tableMeta); @@ -1715,8 +1799,8 @@ TEST(tableMeta, updateStbMeta) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestSTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestSTablename); STableMeta *tableMeta = NULL; code = catalogGetTableMeta(pCtg, mockPointer, &n, &tableMeta); @@ -1754,7 +1838,7 @@ TEST(tableMeta, updateStbMeta) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n != 3) { taosMsleep(50); } else { @@ -1795,7 +1879,7 @@ TEST(getIndexInfo, notExists) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_INDEXINFO_E; @@ -1825,7 +1909,7 @@ TEST(refreshGetMeta, normal2normal) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; @@ -1844,8 +1928,8 @@ TEST(refreshGetMeta, normal2normal) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); code = catalogGetTableHashVgroup(pCtg, mockPointer, &n, &vgInfo); ASSERT_EQ(code, 0); @@ -1854,7 +1938,7 @@ TEST(refreshGetMeta, normal2normal) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n > 0) { break; } @@ -1904,7 +1988,7 @@ TEST(refreshGetMeta, normal2notexist) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; @@ -1923,8 +2007,8 @@ TEST(refreshGetMeta, normal2notexist) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); code = catalogGetTableHashVgroup(pCtg, mockPointer, &n, &vgInfo); ASSERT_EQ(code, 0); @@ -1933,7 +2017,7 @@ TEST(refreshGetMeta, normal2notexist) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n > 0) { break; } @@ -1974,7 +2058,7 @@ TEST(refreshGetMeta, normal2child) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; @@ -1994,8 +2078,8 @@ TEST(refreshGetMeta, normal2child) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); ctgTestCurrentCTableName = ctgTestTablename; ctgTestCurrentSTableName = ctgTestSTablename; @@ -2006,7 +2090,7 @@ TEST(refreshGetMeta, normal2child) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n > 0) { break; } @@ -2057,7 +2141,7 @@ TEST(refreshGetMeta, stable2child) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_STBMETA; @@ -2078,8 +2162,8 @@ TEST(refreshGetMeta, stable2child) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); ctgTestCurrentSTableName = ctgTestTablename; ctgTestCurrentCTableName = ctgTestTablename; @@ -2090,7 +2174,7 @@ TEST(refreshGetMeta, stable2child) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n > 0) { break; } @@ -2143,7 +2227,7 @@ TEST(refreshGetMeta, stable2stable) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_STBMETA; @@ -2164,8 +2248,8 @@ TEST(refreshGetMeta, stable2stable) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); ctgTestCurrentSTableName = ctgTestTablename; code = catalogGetTableHashVgroup(pCtg, mockPointer, &n, &vgInfo); @@ -2175,7 +2259,7 @@ TEST(refreshGetMeta, stable2stable) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n > 0) { break; } @@ -2229,7 +2313,7 @@ TEST(refreshGetMeta, child2stable) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_CTBMETA; @@ -2250,8 +2334,8 @@ TEST(refreshGetMeta, child2stable) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); ctgTestCurrentCTableName = ctgTestTablename; ctgTestCurrentSTableName = ctgTestSTablename; @@ -2262,7 +2346,7 @@ TEST(refreshGetMeta, child2stable) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n > 0) { break; } @@ -2315,7 +2399,7 @@ TEST(tableDistVgroup, normalTable) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; @@ -2334,8 +2418,8 @@ TEST(tableDistVgroup, normalTable) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); code = catalogGetTableDistVgInfo(pCtg, mockPointer, &n, &vgList); ASSERT_TRUE(code != 0); @@ -2352,7 +2436,7 @@ TEST(tableDistVgroup, childTableCase) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_CTBMETA; @@ -2372,8 +2456,8 @@ TEST(tableDistVgroup, childTableCase) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestCTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestCTablename); code = catalogGetTableDistVgInfo(pCtg, mockPointer, &n, &vgList); ASSERT_TRUE(code != 0); @@ -2390,7 +2474,7 @@ TEST(tableDistVgroup, superTableCase) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_STBMETA; @@ -2409,8 +2493,8 @@ TEST(tableDistVgroup, superTableCase) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestSTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestSTablename); code = catalogGetTableDistVgInfo(pCtg, mockPointer, &n, &vgList); ASSERT_EQ(code, 0); @@ -2441,7 +2525,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; @@ -2459,8 +2543,8 @@ TEST(dbVgroup, getSetDbVgroupCase) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); code = catalogGetDBVgList(pCtg, mockPointer, ctgTestDbname, &vgList); ASSERT_EQ(code, 0); @@ -2470,7 +2554,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n > 0) { break; } @@ -2501,7 +2585,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n != 3) { taosMsleep(50); } else { @@ -2545,17 +2629,17 @@ TEST(multiThread, getSetRmSameDbVgroup) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); TdThreadAttr thattr; - taosThreadAttrInit(&thattr); + (void)taosThreadAttrInit(&thattr); TdThread thread1, thread2; - taosThreadCreate(&(thread1), &thattr, ctgTestSetSameDbVgroupThread, pCtg); + (void)taosThreadCreate(&(thread1), &thattr, ctgTestSetSameDbVgroupThread, pCtg); taosSsleep(1); - taosThreadCreate(&(thread2), &thattr, ctgTestGetDbVgroupThread, pCtg); + (void)taosThreadCreate(&(thread2), &thattr, ctgTestGetDbVgroupThread, pCtg); while (true) { if (ctgTestDeadLoop) { @@ -2597,17 +2681,17 @@ TEST(multiThread, getSetRmDiffDbVgroup) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); TdThreadAttr thattr; - taosThreadAttrInit(&thattr); + (void)taosThreadAttrInit(&thattr); TdThread thread1, thread2; - taosThreadCreate(&(thread1), &thattr, ctgTestSetDiffDbVgroupThread, pCtg); + (void)taosThreadCreate(&(thread1), &thattr, ctgTestSetDiffDbVgroupThread, pCtg); taosSsleep(1); - taosThreadCreate(&(thread2), &thattr, ctgTestGetDbVgroupThread, pCtg); + (void)taosThreadCreate(&(thread2), &thattr, ctgTestGetDbVgroupThread, pCtg); while (true) { if (ctgTestDeadLoop) { @@ -2649,16 +2733,16 @@ TEST(multiThread, ctableMeta) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); TdThreadAttr thattr; - taosThreadAttrInit(&thattr); + (void)taosThreadAttrInit(&thattr); TdThread thread1, thread2; - taosThreadCreate(&(thread1), &thattr, ctgTestSetCtableMetaThread, pCtg); + (void)taosThreadCreate(&(thread1), &thattr, ctgTestSetCtableMetaThread, pCtg); taosSsleep(1); - taosThreadCreate(&(thread1), &thattr, ctgTestGetCtableMetaThread, pCtg); + (void)taosThreadCreate(&(thread1), &thattr, ctgTestGetCtableMetaThread, pCtg); while (true) { if (ctgTestDeadLoop) { @@ -2701,10 +2785,10 @@ TEST(rentTest, allRent) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); + TAOS_STRCPY(n.dbname, "db1"); for (int32_t i = 1; i <= 10; ++i) { - sprintf(n.tname, "%s_%d", ctgTestSTablename, i); + (void)sprintf(n.tname, "%s_%d", ctgTestSTablename, i); STableMeta *tableMeta = NULL; code = catalogGetSTableMeta(pCtg, mockPointer, &n, &tableMeta); @@ -2728,25 +2812,25 @@ TEST(rentTest, allRent) { code = catalogGetExpiredDBs(pCtg, &dbs, &num); ASSERT_EQ(code, 0); - printf("%d - expired dbNum:%d\n", i, num); + (void)printf("%d - expired dbNum:%d\n", i, num); if (dbs) { - printf("%d - expired dbId:%" PRId64 ", vgVersion:%d\n", i, dbs->dbId, dbs->vgVersion); + (void)printf("%d - expired dbId:%" PRId64 ", vgVersion:%d\n", i, dbs->dbId, dbs->vgVersion); taosMemoryFree(dbs); dbs = NULL; } code = catalogGetExpiredSTables(pCtg, &stable, &num); ASSERT_EQ(code, 0); - printf("%d - expired stableNum:%d\n", i, num); + (void)printf("%d - expired stableNum:%d\n", i, num); if (stable) { for (int32_t n = 0; n < num; ++n) { - printf("suid:%" PRId64 ", dbFName:%s, stbName:%s, sversion:%d, tversion:%d\n", stable[n].suid, + (void)printf("suid:%" PRId64 ", dbFName:%s, stbName:%s, sversion:%d, tversion:%d\n", stable[n].suid, stable[n].dbFName, stable[n].stbName, stable[n].sversion, stable[n].tversion); } taosMemoryFree(stable); stable = NULL; } - printf("*************************************************\n"); + (void)printf("*************************************************\n"); taosSsleep(2); } @@ -2761,7 +2845,7 @@ TEST(apiTest, catalogRefreshDBVgInfo_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; @@ -2788,7 +2872,7 @@ TEST(apiTest, catalogChkAuth_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_USERAUTH; @@ -2804,8 +2888,8 @@ TEST(apiTest, catalogChkAuth_test) { SUserAuthInfo authInfo = {0}; SUserAuthRes authRes = {0}; - strcpy(authInfo.user, ctgTestUsername); - toName(1, ctgTestDbname, ctgTestSTablename, &authInfo.tbName); + TAOS_STRCPY(authInfo.user, ctgTestUsername); + (void)toName(1, ctgTestDbname, ctgTestSTablename, &authInfo.tbName); authInfo.type = AUTH_TYPE_READ; bool exists = false; code = catalogChkAuthFromCache(pCtg, &authInfo, &authRes, &exists); @@ -2818,7 +2902,7 @@ TEST(apiTest, catalogChkAuth_test) { while (true) { uint64_t n = 0; - ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n); + ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n)); if (n != 1) { taosMsleep(50); } else { @@ -2841,7 +2925,7 @@ TEST(apiTest, catalogRefreshGetTableCfg_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; @@ -2857,8 +2941,8 @@ TEST(apiTest, catalogRefreshGetTableCfg_test) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); STableCfg *pCfg = NULL; code = catalogRefreshGetTableCfg(pCtg, mockPointer, &n, &pCfg); @@ -2879,7 +2963,7 @@ TEST(apiTest, catalogGetTableIndex_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_TBLINDEX; @@ -2894,8 +2978,8 @@ TEST(apiTest, catalogGetTableIndex_test) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); SArray *pRes = NULL; code = catalogGetTableIndex(pCtg, mockPointer, &n, &pRes); @@ -2915,7 +2999,7 @@ TEST(apiTest, catalogGetDBCfg_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_DBCFG; @@ -2930,8 +3014,8 @@ TEST(apiTest, catalogGetDBCfg_test) { ASSERT_EQ(code, 0); SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; - strcpy(n.dbname, "db1"); - strcpy(n.tname, ctgTestTablename); + TAOS_STRCPY(n.dbname, "db1"); + TAOS_STRCPY(n.tname, ctgTestTablename); SDbCfgInfo cfgInfo = {0}; code = catalogGetDBCfg(pCtg, mockPointer, ctgTestDbname, &cfgInfo); @@ -2948,7 +3032,7 @@ TEST(apiTest, catalogGetQnodeList_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_QNODELIST; @@ -2982,7 +3066,7 @@ TEST(apiTest, catalogGetUdfInfo_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_UDF; @@ -3011,7 +3095,7 @@ TEST(apiTest, catalogGetServerVersion_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_SVRVER; @@ -3040,7 +3124,7 @@ TEST(apiTest, catalogUpdateTableIndex_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_SVRVER; @@ -3055,8 +3139,8 @@ TEST(apiTest, catalogUpdateTableIndex_test) { ASSERT_EQ(code, 0); STableIndexRsp rsp = {0}; - strcpy(rsp.dbFName, ctgTestDbname); - strcpy(rsp.tbName, ctgTestSTablename); + TAOS_STRCPY(rsp.dbFName, ctgTestDbname); + TAOS_STRCPY(rsp.tbName, ctgTestSTablename); rsp.suid = ctgTestSuid; rsp.version = 1; code = catalogUpdateTableIndex(pCtg, &rsp); @@ -3072,7 +3156,7 @@ TEST(apiTest, catalogGetDnodeList_test) { ctgTestInitLogFile(); - memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); + TAOS_MEMSET(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc)); ctgTestRspIdx = 0; ctgTestRspFunc[0] = CTGT_RSP_DNODElIST; @@ -3103,17 +3187,17 @@ TEST(intTest, autoCreateTableTest) { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_TRUE(NULL != taos); - ctgdEnableDebug("api", true); - ctgdEnableDebug("meta", true); - ctgdEnableDebug("cache", true); - ctgdEnableDebug("lock", true); + (void)ctgdEnableDebug("api", true); + (void)ctgdEnableDebug("meta", true); + (void)ctgdEnableDebug("cache", true); + (void)ctgdEnableDebug("lock", true); ctgTestExecQuery(taos, "drop database if exists db1", false, NULL); ctgTestExecQuery(taos, "create database db1", false, NULL); ctgTestExecQuery(taos, "create stable db1.st1 (ts timestamp, f1 int) tags(tg1 int)", false, NULL); ctgTestExecQuery(taos, "insert into db1.tb1 using db1.st1 tags(1) values(now, 1)", false, NULL); - ctgdGetOneHandle(&pCtg); + (void)ctgdGetOneHandle(&pCtg); while (true) { uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); diff --git a/source/libs/parser/inc/parInsertUtil.h b/source/libs/parser/inc/parInsertUtil.h index 4f2877fcf6..899661a18c 100644 --- a/source/libs/parser/inc/parInsertUtil.h +++ b/source/libs/parser/inc/parInsertUtil.h @@ -45,6 +45,7 @@ int16_t insFindCol(struct SToken *pColname, int16_t start, int16_t end, SSchema void insBuildCreateTbReq(SVCreateTbReq *pTbReq, const char *tname, STag *pTag, int64_t suid, const char *sname, SArray *tagName, uint8_t tagNum, int32_t ttl); int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo *pInfo); +void insResetBoundColsInfo(SBoundColInfo *pInfo); void insInitColValues(STableMeta *pTableMeta, SArray *aColValues); void insCheckTableDataOrder(STableDataCxt *pTableCxt, SRowKey *rowKey); int32_t insGetTableDataCxt(SHashObj *pHash, void *id, int32_t idLen, STableMeta *pTableMeta, diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 313d9449d2..0d0fe75ddb 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -183,6 +183,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, E } pBoundInfo->numOfBound = 0; + pBoundInfo->hasBoundCols = true; bool hasPK = pTableMeta->tableInfo.numOfPKs; int16_t numOfBoundPKs = 0; @@ -1379,6 +1380,8 @@ static int32_t parseBoundColumnsClause(SInsertParseContext* pCxt, SVnodeModifyOp if (NULL != pStmt->pBoundCols) { return parseBoundColumns(pCxt, &pStmt->pBoundCols, BOUND_COLUMNS, pStmt->pTableMeta, &pTableCxt->boundColsInfo); + } else if (pTableCxt->boundColsInfo.hasBoundCols) { + insResetBoundColsInfo(&pTableCxt->boundColsInfo); } return TSDB_CODE_SUCCESS; diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 17b5733ff7..7e1893ae00 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -180,6 +180,7 @@ void insInitColValues(STableMeta* pTableMeta, SArray* aColValues) { initColValue int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo* pInfo) { pInfo->numOfCols = numOfBound; pInfo->numOfBound = numOfBound; + pInfo->hasBoundCols = false; pInfo->pColIndex = taosMemoryCalloc(numOfBound, sizeof(int16_t)); if (NULL == pInfo->pColIndex) { return TSDB_CODE_OUT_OF_MEMORY; @@ -190,6 +191,14 @@ int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo* pInfo) { return TSDB_CODE_SUCCESS; } +void insResetBoundColsInfo(SBoundColInfo* pInfo) { + pInfo->numOfBound = pInfo->numOfCols; + pInfo->hasBoundCols = false; + for (int32_t i = 0; i < pInfo->numOfCols; ++i) { + pInfo->pColIndex[i] = i; + } +} + void insCheckTableDataOrder(STableDataCxt* pTableCxt, SRowKey* rowKey) { // once the data block is disordered, we do NOT keep last timestamp any more if (!pTableCxt->ordered) { diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 9818394a2a..cf466f3cd9 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -825,18 +825,19 @@ static int32_t allocConnRef(SCliConn* conn, bool update) { transRemoveExHandle(transGetRefMgt(), conn->refId); conn->refId = -1; } - SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle)); - exh->handle = conn; - exh->pThrd = conn->hostThrd; - QUEUE_INIT(&exh->q); - taosInitRWLatch(&exh->latch); + SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle)); exh->refId = transAddExHandle(transGetRefMgt(), exh); SExHandle* self = transAcquireExHandle(transGetRefMgt(), exh->refId); - ASSERT(exh == self); + if (self != exh) { + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } QUEUE_INIT(&exh->q); taosInitRWLatch(&exh->latch); + exh->handle = conn; + exh->pThrd = conn->hostThrd; conn->refId = exh->refId; if (conn->refId == -1) { @@ -2836,6 +2837,10 @@ int64_t transAllocHandle() { exh->refId = transAddExHandle(transGetRefMgt(), exh); SExHandle* self = transAcquireExHandle(transGetRefMgt(), exh->refId); ASSERT(exh == self); + if (exh != self) { + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } QUEUE_INIT(&exh->q); taosInitRWLatch(&exh->latch); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 990c84371f..4db1475fa9 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -435,6 +435,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_STB_NOT_EXIST, "Stable not exists") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER, "Table schema is old") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE, "Table already exists in other stables") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INCONSISTENT_DB_ID, "Inconsistent database id") // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle") diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c index 82993e8449..1d2b3f003c 100644 --- a/source/util/src/tjson.c +++ b/source/util/src/tjson.c @@ -49,8 +49,7 @@ int32_t tjsonAddIntegerToObject(SJson* pJson, const char* pName, const uint64_t int32_t tjsonAddDoubleToObject(SJson* pJson, const char* pName, const double number) { if (NULL == cJSON_AddNumberToObject((cJSON*)pJson, pName, number)) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; + return terrno = TSDB_CODE_OUT_OF_MEMORY; } return TSDB_CODE_SUCCESS; @@ -58,8 +57,7 @@ int32_t tjsonAddDoubleToObject(SJson* pJson, const char* pName, const double num int32_t tjsonAddBoolToObject(SJson* pJson, const char* pName, const bool boolean) { if (NULL == cJSON_AddBoolToObject((cJSON*)pJson, pName, boolean)) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; + return terrno = TSDB_CODE_OUT_OF_MEMORY; } return TSDB_CODE_SUCCESS; @@ -67,8 +65,7 @@ int32_t tjsonAddBoolToObject(SJson* pJson, const char* pName, const bool boolean int32_t tjsonAddStringToObject(SJson* pJson, const char* pName, const char* pVal) { if (NULL == cJSON_AddStringToObject((cJSON*)pJson, pName, pVal)) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; + return terrno = TSDB_CODE_OUT_OF_MEMORY; } return TSDB_CODE_SUCCESS; @@ -87,8 +84,7 @@ int32_t tjsonAddItemToObject(SJson* pJson, const char* pName, SJson* pItem) { return TSDB_CODE_SUCCESS; } - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; + return terrno = TSDB_CODE_OUT_OF_MEMORY; } int32_t tjsonAddItemToArray(SJson* pJson, SJson* pItem) { @@ -96,8 +92,7 @@ int32_t tjsonAddItemToArray(SJson* pJson, SJson* pItem) { return TSDB_CODE_SUCCESS; } - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; + return terrno = TSDB_CODE_OUT_OF_MEMORY; } int32_t tjsonAddObject(SJson* pJson, const char* pName, FToJson func, const void* pObj) { @@ -106,18 +101,27 @@ int32_t tjsonAddObject(SJson* pJson, const char* pName, FToJson func, const void } SJson* pJobj = tjsonCreateObject(); - if (NULL == pJobj || TSDB_CODE_SUCCESS != func(pObj, pJobj)) { + if (NULL == pJobj) { + return terrno; + } + int32_t rc = func(pObj, pJobj); + if (rc != TSDB_CODE_SUCCESS) { tjsonDelete(pJobj); - return TSDB_CODE_FAILED; + return rc; } return tjsonAddItemToObject(pJson, pName, pJobj); } int32_t tjsonAddItem(SJson* pJson, FToJson func, const void* pObj) { SJson* pJobj = tjsonCreateObject(); - if (NULL == pJobj || TSDB_CODE_SUCCESS != func(pObj, pJobj)) { + if (pJobj == NULL) { + return terrno; + } + + int32_t rc = func(pObj, pJobj); + if (rc != TSDB_CODE_SUCCESS) { tjsonDelete(pJobj); - return TSDB_CODE_FAILED; + return rc; } return tjsonAddItemToArray(pJson, pJobj); } @@ -156,9 +160,21 @@ int32_t tjsonAddTArray(SJson* pJson, const char* pName, FToJson func, const SArr return TSDB_CODE_SUCCESS; } -char* tjsonToString(const SJson* pJson) { return cJSON_Print((cJSON*)pJson); } +char* tjsonToString(const SJson* pJson) { + char* p = cJSON_Print((cJSON*)pJson); + if (!p) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + } + return p; +} -char* tjsonToUnformattedString(const SJson* pJson) { return cJSON_PrintUnformatted((cJSON*)pJson); } +char* tjsonToUnformattedString(const SJson* pJson) { + char* p = cJSON_PrintUnformatted((cJSON*)pJson); + if (!p) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + } + return p; +} SJson* tjsonGetObjectItem(const SJson* pJson, const char* pName) { return cJSON_GetObjectItem(pJson, pName); } diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 848917ceb5..bb67aa5a1f 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -27,7 +27,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f insert/insert_basic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f cluster/splitVgroupByLearner.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f authorith/authBasic.py -N 3 -,,n,army,python3 ./test.py -f cmdline/fullopt.py +# ,,n,army,python3 ./test.py -f cmdline/fullopt.py ,,n,army,python3 ./test.py -f query/show.py -N 3 ,,n,army,python3 ./test.py -f alter/alterConfig.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/subquery/subqueryBugs.py -N 3 @@ -278,8 +278,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -n 3 -i True ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-db-removewal.py -N 2 -n 1 ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-stb-removewal.py -N 6 -n 3 -,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 2 -n 1 -,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 6 -n 3 +#,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 2 -n 1 +#,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-stb.py -N 6 -n 3 #,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeTransform-db.py -N 6 -n 3 ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 2 -n 1 ,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata.py -N 3 -n 3 diff --git a/tests/system-test/1-insert/insert_column_value.py b/tests/system-test/1-insert/insert_column_value.py index fcb83e2f97..c488a13a88 100644 --- a/tests/system-test/1-insert/insert_column_value.py +++ b/tests/system-test/1-insert/insert_column_value.py @@ -45,7 +45,7 @@ class TDTestCase: self.TIMESTAMP_BASE = 1706716800 tdSql.init(conn.cursor()) tdSql.execute(f'drop database if exists db') - tdSql.execute(f'create database if not exists db vgroups 1') + tdSql.execute(f'create database if not exists db vgroups 1 keep 10512000m') tdLog.printNoPrefix("create table") self.__create_tb() @@ -516,9 +516,19 @@ class TDTestCase: # check json self.__insert_query_json("db", "stb_js", "ctb_js", OK_JS, KO_JS, "\'{\"k1\":\"v1\",\"k2\":\"v2\"}\'") + def __insert_query_ts5184(self, dbname="db", stbname="stb_ts5184", ctbname="ctb_ts5184", ntbname="ntb_ts5184"): + TB_LIST = [ ctbname, ntbname] + tdSql.execute(f'create table {dbname}.{stbname} (ts timestamp, w_ts timestamp, opc nchar(100),quality int) tags(t0 int);') + tdSql.execute(f'create table {dbname}.{ntbname} (ts timestamp, w_ts timestamp, opc nchar(100),quality int);') + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(1);') + for _tb in TB_LIST: + tdSql.execute(f'insert into {dbname}.{_tb} values(1721265436000,now(),"0",192) {dbname}.{_tb}(quality,w_ts,ts) values(192,now(),1721265326000) {dbname}.{_tb}(quality,w_ts,ts) values(190,now()+1s,1721265326000) {dbname}.{_tb} values(1721265436000,now()+2s,"1",191) {dbname}.{_tb}(quality,w_ts,ts) values(192,now()+3s,1721265326002) {dbname}.{_tb}(ts,w_ts,opc,quality) values(1721265436003,now()+4s,"3",193);'); + tdSql.query(f'select * from {dbname}.{_tb}', show=True) + tdSql.checkRows(4) def run(self): self.__insert_query_exec() + self.__insert_query_ts5184() def stop(self):