From ee7d25602e66b4c1af091041cefd1d31386398d0 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 8 Apr 2024 15:40:52 +0800 Subject: [PATCH] fix(tsdb): fix error in retrieve varchar pk. --- source/dnode/vnode/src/tsdb/tsdbRead2.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 57d4121880..a8a4ced517 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -1678,11 +1678,9 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* __compar_fn_t compFn = pReader->pkComparFn; int32_t pkSrcSlot = pReader->suppInfo.pkSrcSlot; - SRowKey* pSttKey = &(SRowKey){0}; + SRowKey* pSttKey = NULL; if (hasDataInSttBlock(pBlockScanInfo) && (!pBlockScanInfo->cleanSttBlocks)) { pSttKey = getCurrentKeyInSttBlock(pSttBlockReader); - } else { - pSttKey = NULL; } SRowKey k; @@ -1714,10 +1712,8 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* } } - SRowKey minKey; + SRowKey minKey = k; if (pReader->info.order == TSDB_ORDER_ASC) { - minKey = k; // chosen the minimum value - if (pfKey != NULL && pkCompEx(compFn, pfKey, &minKey) < 0) { minKey = *pfKey; } @@ -1726,8 +1722,6 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* minKey = *pSttKey; } } else { - minKey = k; - if (pfKey != NULL && pkCompEx(compFn, pfKey, &minKey) > 0) { minKey = *pfKey; } @@ -1882,11 +1876,9 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pDelList, pReader); TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader); - SRowKey* pSttKey = &(SRowKey){0}; + SRowKey* pSttKey = NULL; if (hasDataInSttBlock(pBlockScanInfo) && (!pBlockScanInfo->cleanSttBlocks)) { - tRowKeyAssign(pSttKey, getCurrentKeyInSttBlock(pSttBlockReader)); - } else { - pSttKey = NULL; + pSttKey = getCurrentKeyInSttBlock(pSttBlockReader); } SRowKey* pfKey = &(SRowKey){0};