diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 60f59e46f798ee2cca55fe96ce030e5d59253b23..506d185d1cfb5cbcfef9ad2e7d5ba8a9eba0367d 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -798,7 +798,15 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBloc cur->rows = binfo.rows; cur->win = binfo.window; cur->mixBlock = false; - cur->lastKey = ASCENDING_TRAVERSE(pQueryHandle->order)? (binfo.window.ekey + 1): (binfo.window.skey -1); + cur->blockCompleted = true; + + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { + cur->lastKey = binfo.window.ekey + 1; + cur->pos = binfo.rows; + } else { + cur->lastKey = binfo.window.skey - 1; + cur->pos = -1; + } } else { // partially copy to dest buffer int32_t endPos = ASCENDING_TRAVERSE(pQueryHandle->order)? (binfo.rows - 1): 0; copyAllRemainRowsFromFileBlock(pQueryHandle, pCheckInfo, &binfo, endPos); @@ -1195,7 +1203,6 @@ static void copyAllRemainRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, STabl cur->win.ekey, cur->rows, pQueryHandle->qinfo); } - // only return the qualified data to client in terms of query time window, data rows in the same block but do not // be included in the query time window will be discarded static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock) {