diff --git a/tests/script/tsim/insert/basic0.sim b/tests/script/tsim/insert/basic0.sim new file mode 100644 index 0000000000..eb4780caac --- /dev/null +++ b/tests/script/tsim/insert/basic0.sim @@ -0,0 +1,334 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print =============== create database +sql create database d0 +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +sql use d0 + +print =============== create super table, include column type for count/sum/min/max/first +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== create child table +sql create table ct1 using stb tags(1000) +sql create table ct2 using stb tags(2000) + +sql show tables +if $rows != 2 then + return -1 +endi + + +print =============== insert data, mode1: one row one table in sql +print =============== insert data, mode1: mulit rows one table in sql +print =============== insert data, mode1: one rows mulit table in sql +print =============== insert data, mode1: mulit rows mulit table in sql +sql insert into ct1 values(now+0s, 10, 2.0, 3.0) +sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3) +sql insert into ct2 values(now+0s, 10, 2.0, 3.0) +sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3) +# after fix bug, modify sql_error to sql +sql_error insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4) +sql_error insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) + +#=================================================================== +#=================================================================== +print =============== query data from child table +sql select * from ct1 +if $rows != 4 then # after fix bug, modify 4 to 7 + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 2.00000 then + return -1 +endi +if $data03 != 3.000000000 then + return -1 +endi +#if $data41 != -14 then +# return -1 +#endi +#if $data42 != -2.40000 then +# return -1 +#endi +#if $data43 != -3.400000000 then +# return -1 +#endi + + +print =============== select count(*) from child table +sql select count(*) from ct1 +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 +if $data00 != 4 then + return -1 +endi + +print =============== select count(column) from child table +sql select count(ts), count(c1), count(c2), count(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $data00 != 4 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +#print =============== select first(*)/first(column) from child table +#sql select first(*) from ct1 +#sql select first(ts), first(c1), first(c2), first(c3) from ct1 + +print =============== select min(column) from child table +sql select min(c1), min(c2), min(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi + +print =============== select max(column) from child table +sql select max(c1), max(c2), max(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 13 then + return -1 +endi +if $data01 != 2.30000 then + return -1 +endi +if $data02 != 3.300000000 then + return -1 +endi + +print =============== select sum(column) from child table +sql select sum(c1), sum(c2), sum(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 46 then + return -1 +endi +if $data01 != 8.599999905 then + return -1 +endi +if $data02 != 12.600000000 then + return -1 +endi + +print =============== select column, from child table +sql select c1, c2, c3 from ct1 +print $data00 $data01 $data02 +#if $rows != 4 then +# return -1 +#endi +#if $data00 != 10 then +# return -1 +#endi +#if $data01 != 2.00000 then +# return -1 +#endi +#if $data02 != 3.000000000 then +# return -1 +#endi +#if $data10 != 11 then +# return -1 +#endi +#if $data11 != 2.10000 then +# return -1 +#endi +#if $data12 != 3.100000000 then +# return -1 +#endi +#if $data30 != 13 then +# return -1 +#endi +#if $data31 != 2.30000 then +# return -1 +#endi +#if $data32 != 3.300000000 then +# return -1 +#endi +#=================================================================== +#=================================================================== + +#print =============== query data from stb +#sql select * from stb +#if $rows != 4 then +# return -1 +#endi +#print =============== select count(*) from supter table +#sql select count(*) from stb +#if $rows != 1 then +# return -1 +#endi +# +#print $data00 $data01 $data02 +#if $data00 != 8 then +# return -1 +#endi +# +#print =============== select count(column) from supter table +#sql select count(ts), count(c1), count(c2), count(c3) from stb +#print $data00 $data01 $data02 $data03 +#if $data00 != 8 then +# return -1 +#endi +#if $data01 != 8 then +# return -1 +#endi +#if $data02 != 8 then +# return -1 +#endi +#if $data03 != 8 then +# return -1 +#endi + + +#=================================================================== +#=================================================================== + +print =============== stop and restart taosd, then again do query above +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql select * from ct1 +if $rows != 4 then # after fix bug, modify 4 to 7 + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 2.00000 then + return -1 +endi +if $data03 != 3.000000000 then + return -1 +endi +#if $data41 != -14 then +# return -1 +#endi +#if $data42 != -2.40000 then +# return -1 +#endi +#if $data43 != -3.400000000 then +# return -1 +#endi + + +print =============== select count(*) from child table +sql select count(*) from ct1 +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 +if $data00 != 4 then + return -1 +endi + +print =============== select count(column) from child table +sql select count(ts), count(c1), count(c2), count(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $data00 != 4 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +#print =============== select first(*)/first(column) from child table +#sql select first(*) from ct1 +#sql select first(ts), first(c1), first(c2), first(c3) from ct1 + +print =============== select min(column) from child table +sql select min(c1), min(c2), min(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi + +print =============== select max(column) from child table +sql select max(c1), max(c2), max(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 13 then + return -1 +endi +if $data01 != 2.30000 then + return -1 +endi +if $data02 != 3.300000000 then + return -1 +endi + +print =============== select sum(column) from child table +sql select sum(c1), sum(c2), sum(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 46 then + return -1 +endi +if $data01 != 8.599999905 then + return -1 +endi +if $data02 != 12.600000000 then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT