diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index b03aef9e188b96d2bd3203720317a68f81c0a960..0b9674f3be579057438cd073f9fdd658805abe62 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -942,23 +942,30 @@ SSDataBlock* doGetDataBlock(void* param, bool* newgroup) { pBlock->info.rows = pRes->numOfRows; if (pRes->numOfRows != 0) { doSetupSDataBlock(pRes, pBlock, pInput->pFilterInfo); - *newgroup = false; - return pBlock; + if (pBlock->info.rows > 0) { + *newgroup = false; + return pBlock; + } } - // No data block exists. So retrieve and transfer it into to SSDataBlock - TAOS_ROW pRow = NULL; - taos_fetch_block(pSql, &pRow); + SSDataBlock* result = NULL; + do { + // No data block exists. So retrieve and transfer it into to SSDataBlock + TAOS_ROW pRow = NULL; + taos_fetch_block(pSql, &pRow); - if (pRes->numOfRows == 0) { - pOperator->status = OP_EXEC_DONE; - return NULL; - } + if (pRes->numOfRows == 0) { + pOperator->status = OP_EXEC_DONE; + result = NULL; + break; + } + pBlock->info.rows = pRes->numOfRows; + doSetupSDataBlock(pRes, pBlock, pInput->pFilterInfo); + *newgroup = false; + result = pBlock; + } while (result->info.rows == 0); - pBlock->info.rows = pRes->numOfRows; - doSetupSDataBlock(pRes, pBlock, pInput->pFilterInfo); - *newgroup = false; - return pBlock; + return result; } static void fetchNextBlockIfCompleted(SOperatorInfo* pOperator, bool* newgroup) {