From 5531775f8efc1aa70a3b2f86a661c3fbae02709a Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 21 Apr 2023 14:59:35 +0800 Subject: [PATCH 1/3] fix: when db_name!=xxx is used in systable scan index --- source/libs/executor/src/sysscanoperator.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 1abe678ac6..b0b27e0e67 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -1482,11 +1482,7 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) { pInfo->pIdx->init = 1; SSDataBlock* blk = sysTableBuildUserTablesByUids(pOperator); return blk; - } else if (flt == -2) { - qDebug("%s failed to get sys table info by idx, empty result", GET_TASKID(pTaskInfo)); - return NULL; - } else if (flt == -1) { - // not idx + } else if ((flt == -2) || (flt == -1)) { qDebug("%s failed to get sys table info by idx, scan sys table one by one", GET_TASKID(pTaskInfo)); } } else if (pCondition != NULL && (pInfo->pIdx != NULL && pInfo->pIdx->init == 1)) { From c971fe16062f0de5f1f273170f0680f19d6efec3 Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 21 Apr 2023 15:01:35 +0800 Subject: [PATCH 2/3] fix: when db_name != xxx can not be optimized by uid index --- source/libs/executor/src/sysscanoperator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index b0b27e0e67..c78e6002cd 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -1482,7 +1482,7 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) { pInfo->pIdx->init = 1; SSDataBlock* blk = sysTableBuildUserTablesByUids(pOperator); return blk; - } else if ((flt == -2) || (flt == -1)) { + } else if ((flt == -1) || (flt == -2)) { qDebug("%s failed to get sys table info by idx, scan sys table one by one", GET_TASKID(pTaskInfo)); } } else if (pCondition != NULL && (pInfo->pIdx != NULL && pInfo->pIdx->init == 1)) { From d0b370e736de6af184bb6cc79a589a8daaa16e4a Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 21 Apr 2023 16:28:25 +0800 Subject: [PATCH 3/3] fix: add test case --- tests/script/tsim/query/sys_tbname.sim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/script/tsim/query/sys_tbname.sim b/tests/script/tsim/query/sys_tbname.sim index c676f2b1e0..849aeb2ac5 100644 --- a/tests/script/tsim/query/sys_tbname.sim +++ b/tests/script/tsim/query/sys_tbname.sim @@ -109,5 +109,26 @@ if $rows != 5000 then return -1 endi +sql create database d1; +sql create stable d1.st1 (ts timestamp, f int) tags(t int); +sql create stable d1.st2 (ts timestamp, f int) tags(t int); +sql create table d1.ct1 using d1.st1 tags(1); +sql create table d1.ct2 using d1.st2 tags(2); +sql create database d2; +sql create stable d2.st1(ts timestamp, f int) tags(t int); +sql create stable d2.st2(ts timestamp, f int) tags(t int); +sql create table d2.ct1 using d2.st1 tags(1); +sql create table d2.ct2 using d2.st2 tags(2); + +sql create database d3; +sql create stable d3.st1(ts timestamp, f int) tags(t int); +sql create stable d3.st2(ts timestamp, f int) tags(t int); +sql create table d3.ct1 using d3.st1 tags(1); +sql create table d3.ct2 using d3.st2 tags(2); +sql select count(*), stable_name, db_name from information_schema.ins_tables where db_name != 'd2' group by stable_name,db_name +print $rows +if $rows != 9 then + return -1 +endi #system sh/exec.sh -n dnode1 -s stop -x SIGINT