From db7dec0347b7c876895a21a5058f5c1935f37531 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sat, 18 Feb 2023 11:21:10 +0800 Subject: [PATCH] fix filter error --- source/dnode/mnode/impl/src/mndSma.c | 3 - source/dnode/vnode/src/meta/metaQuery.c | 18 +++-- source/libs/executor/src/sysscanoperator.c | 2 +- .../tsim/tagindex/sma_and_tag_index.sim | 81 +++++++++++++++++++ 4 files changed, 94 insertions(+), 10 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 8408506b8c..fb9a4e52d6 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -50,11 +50,8 @@ static void mndDestroySmaObj(SSmaObj *pSmaObj); // retrieve sma index and tag index static int32_t mndRetrieveIdx(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { - // TODO int32_t read = mndRetrieveSma(pReq, pShow, pBlock, rows); - read += mndRetrieveTagIdx(pReq, pShow, pBlock, rows - read); - return read; } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 8615f6d566..c8779c69ec 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -1124,8 +1124,10 @@ int32_t metaFilterCreateTime(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) if (cmp == 0) taosArrayPush(pUids, &p->uid); else { - if (param->equal == true) break; - count++; + if (param->equal == true) { + if (count > TRY_ERROR_LIMIT) break; + count++; + } } valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur); if (valid < 0) break; @@ -1182,8 +1184,10 @@ int32_t metaFilterTableName(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { tb_uid_t tuid = *(tb_uid_t *)pEntryVal; taosArrayPush(pUids, &tuid); } else { - if (param->equal == true) break; - count++; + if (param->equal == true) { + if (count > TRY_ERROR_LIMIT) break; + count++; + } } valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur); if (valid < 0) { @@ -1329,8 +1333,10 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { } taosArrayPush(pUids, &tuid); } else { - if (param->equal == true) break; - count++; + if (param->equal == true) { + if (count > TRY_ERROR_LIMIT) break; + count++; + } } valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur); if (valid < 0) { diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 97b76ec7c5..fd23357002 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -219,8 +219,8 @@ int32_t sysFilte__CreateTime(void* arg, SNode* pNode, SArray* result) { SOperatorNode* pOper = (SOperatorNode*)pNode; SValueNode* pVal = (SValueNode*)pOper->pRight; - bool reverse = false; + bool reverse = false; bool equal = false; __optSysFilter func = optSysGetFilterFunc(pOper->opType, &reverse, &equal); if (func == NULL) return -1; diff --git a/tests/script/tsim/tagindex/sma_and_tag_index.sim b/tests/script/tsim/tagindex/sma_and_tag_index.sim index e69de29bb2..3aa14b6117 100644 --- a/tests/script/tsim/tagindex/sma_and_tag_index.sim +++ b/tests/script/tsim/tagindex/sma_and_tag_index.sim @@ -0,0 +1,81 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step0 +$dbPrefix = ta_3_db +$tbPrefix = ta_3_tb +$mtPrefix = ta_3_mt +$tbNum = 101 +$rowNum = 20 +$totalNum = 200 + +print =============== create database +sql create database $dbPrefix +sql use $dbPrefix + +print =============== create super table and register tag index +sql create table if not exists $mtPrefix (ts timestamp, c1 int) tags (t1 int, t2 int, t3 int, t4 int, t5 int) + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== create child table + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mtPrefix tags( $i , $i , $i , $i , $i ); + $i = $i + 1 +endw + +sql show tables +if $rows != $tbNum then + return -1 +endi + + + +print =============== insert data into each table +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb values(now, $i ); + $i = $i + 1 +endw + + +sql create index ti2 on $mtPrefix (t2) + +print ==== test name conflict +# +sql_error create index ti3 on $mtPrefix(t2) + +sql_error create index ti2 on $mtPrefix(t2) +sql_error create index ti2 on $mtPrefix(t1) +sql_error create index ti2 on $mtPrefix(t3) +sql_error create index ti2 on $mtPrefix(txx) + + + + + + + + + + + +print === show index + +sql select * from information_schema.ins_indexes +if $rows != 1 then + return -1 +endi + + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file -- GitLab