From 9bcc0cd3023397d3d45aa12938c8bb18ef891373 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 23 Jun 2022 19:26:23 +0800 Subject: [PATCH] feat: sql command 'show consumers' and 'show subscriptions' --- source/libs/parser/src/parUtil.c | 8 ++++---- source/libs/parser/test/mockCatalogService.cpp | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 689ff08ab1..c4f4624355 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -897,7 +897,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) { if (pNew->pFuncs) { pNew->pFuncs = taosArrayDup(pNew->pFuncs); } - + int32_t schemaSize = (pCfg->numOfColumns + pCfg->numOfTags) * sizeof(SSchema); SSchema* pSchema = taosMemoryMalloc(schemaSize); @@ -912,7 +912,7 @@ int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST char fullName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pName, fullName); STableCfg* pCfg = NULL; - int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg); + int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg); if (TSDB_CODE_SUCCESS == code) { *pOutput = tableCfgDup(pCfg); if (NULL == *pOutput) { @@ -929,10 +929,10 @@ int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache) { int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) { SMetaRes* pRes = taosArrayGet(pMetaCache->pDnodes, 0); - if (pRes->code) { + if (TSDB_CODE_SUCCESS != pRes->code) { return pRes->code; } - + *pDnodes = taosArrayDup((SArray*)pRes->pRes); if (NULL == *pDnodes) { return TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 4263b59cc3..db33381f5e 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -166,13 +166,10 @@ class MockCatalogServiceImpl { } int32_t catalogGetDnodeList(SArray** pDnodes) const { - SMetaRes res = {0}; - res.pRes = taosArrayInit(dnode_.size(), sizeof(SEpSet)); + *pDnodes = taosArrayInit(dnode_.size(), sizeof(SEpSet)); for (const auto& dnode : dnode_) { - taosArrayPush((SArray*)res.pRes, &dnode.second); + taosArrayPush(*pDnodes, &dnode.second); } - *pDnodes = taosArrayInit(1, sizeof(SMetaRes)); - taosArrayPush(*pDnodes, &res); return TSDB_CODE_SUCCESS; } @@ -200,7 +197,7 @@ class MockCatalogServiceImpl { code = getAllTableIndex(pCatalogReq->pTableIndex, &pMetaData->pTableIndex); } if (TSDB_CODE_SUCCESS == code && pCatalogReq->dNodeRequired) { - code = catalogGetDnodeList(&pMetaData->pDnodeList); + code = getAllDnodeList(&pMetaData->pDnodeList); } if (TSDB_CODE_SUCCESS == code) { code = getAllTableCfg(pCatalogReq->pTableCfg, &pMetaData->pTableCfg); @@ -565,6 +562,13 @@ class MockCatalogServiceImpl { return TSDB_CODE_SUCCESS; } + int32_t getAllDnodeList(SArray** pDnodes) const { + SMetaRes res = {0}; + *pDnodes = taosArrayInit(1, sizeof(SMetaRes)); + taosArrayPush(*pDnodes, &res); + return catalogGetDnodeList((SArray**)&res.pRes); + } + uint64_t id_; std::unique_ptr builder_; DbMetaCache meta_; -- GitLab