From dabcf00adeef8cd83c46a9503116c6bb3f79e3cd Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 14 Feb 2023 16:54:20 +0800 Subject: [PATCH] fix RC --- source/dnode/vnode/src/meta/metaTable.c | 5 +- tests/script/tsim/tagindex/perf.sim | 175 ++++++++++++++++++++++-- 2 files changed, 168 insertions(+), 12 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 609c8286a0..591cdc0ccc 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -1233,12 +1233,11 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl entry.version = version; - metaDeleteNcolIdx(pMeta, &oldEntry); - metaUpdateNcolIdx(pMeta, &entry); - // do actual write metaWLock(pMeta); + metaDeleteNcolIdx(pMeta, &oldEntry); + metaUpdateNcolIdx(pMeta, &entry); // save to table db metaSaveToTbDb(pMeta, &entry); diff --git a/tests/script/tsim/tagindex/perf.sim b/tests/script/tsim/tagindex/perf.sim index 9849f458a3..a8d48f3e98 100644 --- a/tests/script/tsim/tagindex/perf.sim +++ b/tests/script/tsim/tagindex/perf.sim @@ -8,7 +8,7 @@ print ======== step0 $dbPrefix = ta_3_db $tbPrefix = ta_3_tb $mtPrefix = ta_3_mt -$tbNum = 10000 +$tbNum = 1000000 $rowNum = 20 $totalNum = 200 @@ -48,21 +48,178 @@ while $i < $tbNum $i = $i + 1 endw -print ========== filter data + +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 ===== test operator equal $i = 0 while $i < $tbNum - sql select count(*) from $mtPrefix where t2 = $i - $i = $i + 1 + sql select * from $mtPrefix where t2= $i ; + if $rows != 1 then + return -1 + endi + $i = $i + 1 endw -sql create index ti2 on $mtPrefix (t2) +print ===== test operator great equal +# great equal than $i = 0 -while $i < $tbNum - sql select count(*) from $mtPrefix where t2 = $i - $i = $i + 1 +while $i < $tbNum + sql select * from $mtPrefix where t2 >= $i ; + $tmp = $tbNum - $i + if $rows != $tmp then + return -1 + endi + $i = $i + 1 +endw + +print ===== test operator great +$i = 0 +while $i < $tbNum + sql select * from $mtPrefix where t2 > $i ; + $tmp = $tbNum - $i + $tmp = $tmp - 1 + if $rows != $tmp then + return -1 + endi + $i = $i + 1 +endw + +print ===== test operator lower +$i = 0 +while $i < $tbNum + sql select * from $mtPrefix where t2 <= $i ; + $tmp = $i + 1 + if $rows != $tmp then + return -1 + endi + $i = $i + 1 +endw + +print ===== test operator lower than +# lower equal than +$i = 0 +while $i < $tbNum + sql select * from $mtPrefix where t2 < $i ; + $tmp = $i + if $rows != $tmp then + return -1 + endi + $i = $i + 1 endw -#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +print ===== add table after index created +$interval = $tbNum + $tbNum +$i = $interval +$limit = $interval + $tbNum +while $i < $limit + $tb = $tbPrefix . $i + sql insert into $tb using $mtPrefix tags( $i , $i , $i , $i , $i ) values( now, $i ) + $i = $i + 1 +endw + + + +print ===== add table after index created (opeator great equal than) +# great equal than +$i = $interval +while $i < $limit + sql select * from $mtPrefix where t2 >= $i ; + $tmp = $limit - $i + if $rows != $tmp then + return -1 + endi + $i = $i + 1 +endw + + +print ===== add table after index created (opeator great than) +# great than +$i = $interval +while $i < $limit + sql select * from $mtPrefix where t2 > $i ; + $tmp = $limit - $i + $tmp = $tmp - 1 + if $rows != $tmp then + return -1 + endi + $i = $i + 1 +endw + +print ===== drop table after index created + +# drop table +$dropTbNum = $tbNum / 2 +$i = 0 + +while $i < $tbNum + $tb = $tbPrefix . $i + sql drop table $tb + $i = $i + 1 +endw + +print ===== drop table after index created(opeator lower than) + +# lower equal than +$i = $interval +while $i < $limit + sql select * from $mtPrefix where t2 < $i ; + $tmp = $i - $interval + if $rows != $tmp then + return -1 + endi + $i = $i + 1 +endw + + +print ===== drop table after index created(opeator lower equal than) + +# lower equal than +$i = $interval +while $i < $limit + sql select * from $mtPrefix where t2 <= $i ; + + $tmp = $i - $interval + $tmp = $tmp + 1 + if $rows != $tmp then + return -1 + endi + $i = $i + 1 +endw + + +print === show index + +sql select * from information_schema.ins_indexes +if $rows != 1 then + return -1 +endi + + +print === drop index ti2 +sql drop index ti2 + +print === drop not exist index +sql_error drop index t2 +sql_error drop index t3 + + + +sql_error create index ti0 on $mtPrefix (t1) +sql_error create index t2i on ta_3_tb17 (t2) + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file -- GitLab