From ba5c3fb2ab6bf0e2a0000dd9237826c77873d548 Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 16 Mar 2023 00:01:54 +0800 Subject: [PATCH] fix: select ins_columns for stb with 4096 columns --- source/dnode/mnode/impl/src/mndStb.c | 7 +++++++ source/libs/executor/src/sysscanoperator.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 2a369a863a..9e61364801 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -3114,6 +3114,7 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(typeName, "SUPER_TABLE"); while (numOfRows < rows) { + void *prevIter = pShow->pIter; pShow->pIter = sdbFetch(pSdb, SDB_STB, pShow->pIter, (void **)&pStb); if (pShow->pIter == NULL) break; @@ -3122,6 +3123,12 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB continue; } + if ((numOfRows + pStb->numOfColumns) > rows) { + pShow->pIter = prevIter; + sdbRelease(pSdb, pStb); + break; + } + SName name = {0}; char stbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; mndExtractTbNameFromStbFullName(pStb->name, &stbName[VARSTR_HEADER_SIZE], TSDB_TABLE_NAME_LEN); diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 38c1d60899..20766b38d6 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -436,7 +436,7 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { int32_t numOfRows = 0; SSDataBlock* dataBlock = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_COLS); - blockDataEnsureCapacity(dataBlock, pOperator->resultInfo.capacity + TSDB_MAX_COLUMNS); + blockDataEnsureCapacity(dataBlock, pOperator->resultInfo.capacity); const char* db = NULL; int32_t vgId = 0; -- GitLab