diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 127d4ac273e59e5509845ef54795c59108826335..31b8eb71bf26184bd351ca6d9b1a704f4bfc36c2 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2652,7 +2652,8 @@ int32_t tSerializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) { } int32_t numOfIndex = taosArrayGetSize(pRsp->pIndexRsp); - for (int32_t i = 0; i < numOfMeta; ++i) { + if (tEncodeI32(&encoder, numOfIndex) < 0) return -1; + for (int32_t i = 0; i < numOfIndex; ++i) { STableIndexRsp *pIndexRsp = taosArrayGet(pRsp->pIndexRsp, i); if (tEncodeCStr(&encoder, pIndexRsp->tbName) < 0) return -1; if (tEncodeCStr(&encoder, pIndexRsp->dbFName) < 0) return -1; @@ -2660,12 +2661,10 @@ int32_t tSerializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) { if (tEncodeI32(&encoder, pIndexRsp->version) < 0) return -1; int32_t num = taosArrayGetSize(pIndexRsp->pIndex); if (tEncodeI32(&encoder, num) < 0) return -1; - if (num > 0) { - for (int32_t i = 0; i < num; ++i) { - STableIndexInfo *pInfo = (STableIndexInfo *)taosArrayGet(pIndexRsp->pIndex, i); - if (tSerializeSTableIndexInfo(&encoder, pInfo) < 0) return -1; - } - } + for (int32_t i = 0; i < num; ++i) { + STableIndexInfo *pInfo = (STableIndexInfo *)taosArrayGet(pIndexRsp->pIndex, i); + if (tSerializeSTableIndexInfo(&encoder, pInfo) < 0) return -1; + } } tEndEncode(&encoder); @@ -2693,9 +2692,8 @@ int32_t tDeserializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) { if (tStartDecode(&decoder) < 0) return -1; - int32_t numOfMeta = taosArrayGetSize(pRsp->pMetaRsp); + int32_t numOfMeta = 0; if (tDecodeI32(&decoder, &numOfMeta) < 0) return -1; - pRsp->pMetaRsp = taosArrayInit(numOfMeta, sizeof(STableMetaRsp)); if (pRsp->pMetaRsp == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -2708,7 +2706,7 @@ int32_t tDeserializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) { taosArrayPush(pRsp->pMetaRsp, &tableMetaRsp); } - int32_t numOfIndex = taosArrayGetSize(pRsp->pIndexRsp); + int32_t numOfIndex = 0; if (tDecodeI32(&decoder, &numOfIndex) < 0) return -1; pRsp->pIndexRsp = taosArrayInit(numOfIndex, sizeof(STableIndexRsp)); diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 9cb7991d33040e9315fc1fe8206cf727168e695c..3f0d20348be9da8b80986b3b49e057b598be1658 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -532,6 +532,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea SStreamObj streamObj = {0}; tstrncpy(streamObj.name, pCreate->name, TSDB_STREAM_FNAME_LEN); tstrncpy(streamObj.sourceDb, pDb->name, TSDB_DB_FNAME_LEN); + tstrncpy(streamObj.targetDb, streamObj.sourceDb, TSDB_DB_FNAME_LEN); streamObj.createTime = taosGetTimestampMs(); streamObj.updateTime = streamObj.createTime; streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name)); @@ -913,7 +914,7 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool } strcpy(rsp->dbFName, pStb->db); - strcpy(rsp->tbName, pStb->name); + strcpy(rsp->tbName, pStb->name + strlen(pStb->db) + 1); rsp->suid = pStb->uid; rsp->version = pStb->smaVer; mndReleaseStb(pMnode, pStb); @@ -1127,4 +1128,4 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc static void mndCancelGetNextSma(SMnode *pMnode, void *pIter) { SSdb *pSdb = pMnode->pSdb; sdbCancelFetch(pSdb, pIter); -} \ No newline at end of file +} diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index e099359d47ef5d205e478b3e59f9f06fa1fb8fe5..6f89c97f8322e90a3a3a422ade34abacb110cf15 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1715,6 +1715,12 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t bool exist = false; char tbFName[TSDB_TABLE_FNAME_LEN]; STableIndexRsp indexRsp = {0}; + indexRsp.pIndex = taosArrayInit(10, sizeof(STableIndexInfo)); + if (NULL == indexRsp.pIndex) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + sprintf(tbFName, "%s.%s", pStbVersion->dbFName, pStbVersion->stbName); int32_t code = mndGetTableSma(pMnode, tbFName, &indexRsp, &exist); if (code || !exist) { diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index b938dff932fbd4c898c8af4fe8bf41c9c788ceec..724b54d250d999e1d2e8c67d0fcb7c40ccb69def 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -1445,7 +1445,7 @@ int32_t ctgWriteTbIndexToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char* dbFNa ctgDebug("table %s index updated to cache, ver:%d, num:%d", tbName, pIndex->version, (int32_t)taosArrayGetSize(pIndex->pIndex)); if (suid) { - CTG_ERR_RET(ctgUpdateRentStbVersion(pCtg, dbFName, tbName, dbCache->dbId, pIndex->suid, pCache)); + CTG_ERR_RET(ctgUpdateRentStbVersion(pCtg, dbFName, tbName, dbCache->dbId, pIndex->suid, &cache)); } return TSDB_CODE_SUCCESS;