未验证 提交 e52d71ad 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #11265 from taosdata/fix/TS-510

[TS-510]<fix>: fix missing last_row results
......@@ -189,6 +189,8 @@ static void* destroyTableCheckInfo(SArray* pTableCheckInfo);
static bool tsdbGetExternalRow(TsdbQueryHandleT pHandle);
static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo);
static STableBlockInfo* moveToNextDataBlockInCurrentFile(STsdbQueryHandle* pQueryHandle);
static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCheckInfo);
static SMemRow getSMemRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order, int32_t update, SMemRow* extraRow);
static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) {
pBlockLoadInfo->slot = -1;
......@@ -632,12 +634,53 @@ static int32_t lazyLoadCacheLast(STsdbQueryHandle* pQueryHandle) {
if (pTable->cacheLastConfigVersion == pRepo->cacheLastConfigVersion) {
continue;
}
if (!pCheckInfo->initBuf) {
initTableMemIterator(pQueryHandle, pCheckInfo);
}
code = tsdbLoadLastCache(pRepo, pTable);
if (code != 0) {
tsdbError("%p uid:%" PRId64 ", tid:%d, failed to load last cache since %s", pQueryHandle, pTable->tableId.uid,
pTable->tableId.tid, tstrerror(terrno));
break;
}
STsdbCfg *pCfg = &pQueryHandle->pTsdb->config;
bool cacheLastRow = CACHE_LAST_ROW(&(pRepo->config));
if (!cacheLastRow) continue;
SMemRow row = getSMemRowInTableMem(pCheckInfo, pQueryHandle->order, pCfg->update, NULL);
if (row == NULL) continue;
TSKEY key = memRowKey(row);
if (!pTable->lastRow) {
STSchema *pSchema = tsdbGetTableSchema(pTable);
SMemRow lastRow = taosTMalloc(memRowMaxBytesFromSchema(pSchema));
if (lastRow == NULL) {
return TSDB_CODE_TDB_OUT_OF_MEMORY;
}
memRowCpy(lastRow, row);
pTable->lastRow = lastRow;
pTable->lastKey = key;
} else {
TSKEY lastRowKey = memRowKey(pTable->lastRow);
if (key <= lastRowKey) continue;
if (memRowTLen(pTable->lastRow) < memRowTLen(row)) {
SMemRow lastRow = taosTRealloc(pTable->lastRow, memRowTLen(row));
if (lastRow == NULL) {
taosTZfree(pTable->lastRow);
pTable->lastRow = NULL;
return TSDB_CODE_TDB_OUT_OF_MEMORY;
}
pTable->lastRow = lastRow;
}
memRowCpy(pTable->lastRow, row);
pTable->lastKey = key;
}
}
return code;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册