From 4b6c0736232bacd9f29c144d34546337c57ac414 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 8 Feb 2023 23:01:20 +0800 Subject: [PATCH] fix filter error --- source/dnode/vnode/src/meta/metaQuery.c | 19 ++++++++----------- tests/script/tsim/tagindex/add_index.sim | 2 -- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 78d029d73c..4d3219f80f 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -1260,13 +1260,10 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { if (tdbTbcMoveTo(pCursor->pCur, pKey, nKey, &cmp) < 0) { goto END; } - if (cmp < 0) { - } else if (cmp > 0) { - if (param->reverse) { - tdbTbcMoveToPrev(pCursor->pCur); - } else { - tdbTbcMoveToNext(pCursor->pCur); - } + if (param->reverse) { + if (tdbTbcMoveToNext(pCursor->pCur) < 0) tdbTbcMoveToLast(pCursor->pCur); + } else { + if (tdbTbcMoveToPrev(pCursor->pCur) < 0) tdbTbcMoveToFirst(pCursor->pCur); } int count = 0; @@ -1282,13 +1279,13 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { STagIdxKey *p = entryKey; if (p == NULL) break; - if (count >= 3) { + if (count >= 4) { if (p->type != pCursor->type || p->suid != pCursor->suid || p->cid != pCursor->cid) { break; } } else { - count++; if (p->type != pCursor->type || p->suid != pCursor->suid || p->cid != pCursor->cid) { + count++; valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur); if (valid < 0) { break; @@ -1308,11 +1305,11 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { } taosArrayPush(pUids, &tuid); } else if (cmp == 1) { - if (count >= 3) break; + if (count >= 4) break; // not match but should continue to iter } else { // not match and no more result - if (count >= 3) break; + if (count >= 4) break; } count++; valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur); diff --git a/tests/script/tsim/tagindex/add_index.sim b/tests/script/tsim/tagindex/add_index.sim index cec86fa697..4bd4594303 100644 --- a/tests/script/tsim/tagindex/add_index.sim +++ b/tests/script/tsim/tagindex/add_index.sim @@ -76,8 +76,6 @@ $i = 0 while $i < $tbNum sql select * from $mtPrefix where t2 > $i ; $tmp = $tbNum - $i - - $tmp = $tmp - 1 if $rows != $tmp then print $rows print $i