From ab1ee971227a3124d22d010a9fe6ab502beee8b8 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 12 Oct 2020 14:56:46 +0800 Subject: [PATCH] fix td-1675 --- src/tsdb/src/tsdbRead.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index d3f4747a96..f0a2694b60 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -2639,8 +2639,7 @@ int32_t tsdbGetTableGroupFromIdList(TSDB_REPO_T* tsdb, SArray* pTableIdList, STa pGroupInfo->pGroupList = taosArrayInit(1, POINTER_BYTES); SArray* group = taosArrayInit(1, sizeof(STableKeyInfo)); - int32_t i = 0; - for(; i < size; ++i) { + for(int32_t i = 0; i < size; ++i) { STableIdInfo *id = taosArrayGet(pTableIdList, i); STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), id->uid); @@ -2665,8 +2664,12 @@ int32_t tsdbGetTableGroupFromIdList(TSDB_REPO_T* tsdb, SArray* pTableIdList, STa return terrno; } - pGroupInfo->numOfTables = i; - taosArrayPush(pGroupInfo->pGroupList, &group); + pGroupInfo->numOfTables = taosArrayGetSize(group); + if (pGroupInfo->numOfTables > 0) { + taosArrayPush(pGroupInfo->pGroupList, &group); + } else { + taosArrayDestroy(group); + } return TSDB_CODE_SUCCESS; } -- GitLab