diff --git a/tests/script/tsim/tag/change_multi_tag.sim b/tests/script/tsim/tag/change_multi_tag.sim new file mode 100644 index 0000000000..93ed8e633d --- /dev/null +++ b/tests/script/tsim/tag/change_multi_tag.sim @@ -0,0 +1,846 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======================== dnode1 start + +$dbPrefix = ta_ad_db +$tbPrefix = ta_ad_tb +$mtPrefix = ta_ad_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i + +sql create database $db +sql use $db + +print =============== step2 +$i = 2 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tagCol2 tinyint, tagCol3 smallint, tagCol4 int, tagCol5 bigint, tagCol6 nchar(10), tagCol7 binary(8)) +sql create table $tb using $mt tags( 1, 2, 3, 5, "test", "test") +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +sql alter table +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 int +sql reset query cache +sql alter table $tb set tag tgcol4 =4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step2 + return -1 +step2: + +print =============== step3 +$i = 3 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 tinyint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step3 + return -1 +step3: + +print =============== step4 +$i = 4 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float) +sql create table $tb using $mt tags( 1, 2 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi + +sql describe $tb +print sql describe $tb +if $data21 != BIGINT then + return -1 +endi +if $data31 != FLOAT then + return -1 +endi +if $data23 != TAG then + return -1 +endi +if $data33 != TAG then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 float +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4.00000 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step4 + return -1 +step4: + +print =============== step5 +$i = 5 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10)) +sql create table $tb using $mt tags( 1, '2' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt add tag tgcol4 smallint +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql reset query cache + +sql select * from $mt where tgcol4 = 4 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +sql select * from $mt where tgcol3 = '1' -x step5 + return -1 +step5: + +print =============== step6 +$i = 6 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 tinyint) +sql create table $tb using $mt tags( 1, 2, 3 ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = 2 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt rename tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(10) +sql alter table $mt add tag tgcol6 binary(10) + +sql reset query cache +sql alter table $tb set tag tgcol4=false +sql alter table $tb set tag tgcol5='5' +sql alter table $tb set tag tgcol6='6' +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol6 = '6' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol4 = 1 +if $rows != 0 then + return -1 +endi +sql select * from $mt where tgcol3 = 1 -x step52 + return -1 +step52: + +print =============== step7 +$i = 7 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt rename tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 tinyint + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol6 = 6 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step71 + return -1 +step71: +sql select * from $mt where tgcol3 = 1 -x step72 + return -1 +step72: + +print =============== step8 +$i = 8 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float, tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, 2, '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol3 = '3' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2.00000 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt rename tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 binary(17) +sql alter table $mt add tag tgcol6 bool +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5='5' +sql alter table $tb set tag tgcol6='1' +sql reset query cache + +sql select * from $mt where tgcol5 = '5' +print select * from $mt where tgcol5 = 5 +print $data01 $data02 $data03 $data04 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 5 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step81 + return -1 +step81: +sql select * from $mt where tgcol3 = 1 -x step82 + return -1 +step82: + +print =============== step9 +$i = 9 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10), tgcol3 binary(10)) +sql create table $tb using $mt tags( 1, '2', '3' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol2 = '2' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1.000000000 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi + +sql alter table $mt rename tag tgcol1 tgcol4 +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt add tag tgcol5 bool +sql alter table $mt add tag tgcol6 float + +sql reset query cache +sql alter table $tb set tag tgcol4=4 +sql alter table $tb set tag tgcol5=1 +sql alter table $tb set tag tgcol6=6 +sql reset query cache + +sql select * from $mt where tgcol5 = 1 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 4.000000000 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 6.00000 then + return -1 +endi + +sql select * from $mt where tgcol3 = 1 -x step91 + return -1 +step91: +sql select * from $mt where tgcol2 = 1 -x step92 + return -1 +step92: + +print =============== step10 +$i = 10 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10)) +sql create table $tb using $mt tags( '1', '2', '3', '4' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol4 = '4' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi + +sql alter table $mt rename tag tgcol1 tgcol4 -x step103 + return -1 +step103: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bool + +sql reset query cache +sql alter table $tb set tag tgcol4='4' +sql alter table $tb set tag tgcol5=false +sql reset query cache + +sql select * from $mt where tgcol4 = '4' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 0 then + return -1 +endi +if $data05 != null then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step101 + return -1 +step101: +sql select * from $mt where tgcol3 = 1 -x step102 + return -1 +step102: + +print =============== step11 +$i = 11 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int, tgcol3 smallint, tgcol4 float, tgcol5 binary(10)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4.00000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi + +sql alter table $mt rename tag tgcol1 tgcol4 -x step114 + return -1 +step114: + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 int +sql alter table $mt add tag tgcol6 binary(10) +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 smallint + +sql reset query cache +sql alter table $tb set tag tgcol4='4' +sql alter table $tb set tag tgcol5=5 +sql alter table $tb set tag tgcol6='6' +sql alter table $tb set tag tgcol7=7 +sql alter table $tb set tag tgcol8=8 +sql reset query cache + +sql select * from $mt where tgcol5 =5 +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 6 then + return -1 +endi +if $data06 != 7 then + return -1 +endi +if $data07 != 8 then + return -1 +endi + +sql select * from $mt where tgcol2 = 1 -x step111 + return -1 +step111: +sql select * from $mt where tgcol3 = 1 -x step112 + return -1 +step112: +sql select * from $mt where tgcol9 = 1 -x step113 + return -1 +step113: + +print =============== step12 +$i = 12 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 smallint, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(20)) +sql create table $tb using $mt tags( 1, 2, 3, 4, '5', '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = 1 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3.00000 then + return -1 +endi +if $data05 != 4.000000000 then + return -1 +endi +if $data06 != 5 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol3 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol5 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol3 int +sql alter table $mt add tag tgcol4 binary(10) +sql alter table $mt add tag tgcol5 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1=false +sql alter table $tb set tag tgcol2='5' +sql alter table $tb set tag tgcol3=4 +sql alter table $tb set tag tgcol4='3' +sql alter table $tb set tag tgcol5=2 +sql alter table $tb set tag tgcol6='1' +sql reset query cache + +sql select * from $mt where tgcol4 = '3' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 1 then + return -1 +endi +if $data04 != 5 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 3 then + return -1 +endi +if $data07 != 2 then + return -1 +endi + +sql select * from $mt where tgcol2 = '5' +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol3 = 4 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol5 = 2 +if $rows != 1 then + return -1 +endi + +sql select * from $mt where tgcol6 = '1' +if $rows != 1 then + return -1 +endi + +print =============== step13 +$i = 13 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20)) +sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) +sql insert into $tb values(now, 1) +sql select * from $mt where tgcol1 = '1' +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data03 != 2 then + return -1 +endi +if $data04 != 3 then + return -1 +endi +if $data05 != 4 then + return -1 +endi +if $data06 != 5.000000000 then + return -1 +endi +if $data07 != 6 then + return -1 +endi + +sql alter table $mt drop tag tgcol2 +sql alter table $mt drop tag tgcol4 +sql alter table $mt drop tag tgcol6 +sql reset query cache +sql alter table $mt add tag tgcol2 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol6 bigint + +sql reset query cache +sql alter table $tb set tag tgcol1='7' +sql alter table $tb set tag tgcol2='8' +sql alter table $tb set tag tgcol3=9 +sql alter table $tb set tag tgcol4=10 +sql alter table $tb set tag tgcol5=11 +sql alter table $tb set tag tgcol6=12 +sql reset query cache + +sql select * from $mt where tgcol2 = '8' +print $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 9 then + return -1 +endi +if $data04 != 11.000000000 then + return -1 +endi +if $data05 != 8 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 12 then + return -1 +endi + +print =============== step14 +$i = 14 +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bigint) +sql create table $tb using $mt tags( 1, 1 ) +sql insert into $tb values(now, 1) + +sql alter table $mt add tag tgcol3 binary(10) +sql alter table $mt add tag tgcol4 int +sql alter table $mt add tag tgcol5 bigint +sql alter table $mt add tag tgcol6 bigint + + sql reset query cache +sql alter table $mt drop tag tgcol6 +sql alter table $mt add tag tgcol7 bigint +sql alter table $mt add tag tgcol8 bigint + +print =============== clear +sql drop database $db +sql select * from information_schema.ins_databases +if $rows != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT