basic1.sim 3.6 KB
Newer Older
P
plum-lihui 已提交
1 2 3 4 5 6 7 8 9
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 d1
sql show databases
P
plum-lihui 已提交
10
if $rows != 2 then 
P
plum-lihui 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  return -1
endi

print $data00 $data01 $data02

sql use d1

print =============== create super table, include all type
sql create table if not exists stb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(16), c9 nchar(16), c10 timestamp, c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned) tags (t1 bool, t2 tinyint, t3 smallint, t4 int, t5 bigint, t6 float, t7 double, t8 binary(16), t9 nchar(16), t10 timestamp, t11 tinyint unsigned, t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned)

sql create stable if not exists stb_1 (ts timestamp, i int) tags (j int)
sql create table stb_2 (ts timestamp, i int) tags (j int)
sql create stable stb_3 (ts timestamp, i int) tags (j int)

sql show stables
if $rows != 4 then 
  return -1
endi

print =============== create child table
sql create table c1 using stb tags(true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40)
sql create table c2 using stb tags(false, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 2', 'child tbl 2', '2022-02-25 18:00:00.000', 10, 20, 30, 40)

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 c1 values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40)
sql insert into c1 values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+2s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40)

print =============== query data
sql select * from c1
P
plum-lihui 已提交
49 50 51 52 53
print rows: $rows 
print $data00  $data01
print $data10  $data11 
print $data20  $data21
print $data30  $data31
P
plum-lihui 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
if $rows != 4 then 
  return -1
endi

if $data01 != true then 
  return -1
endi

if $data02 != -1 then 
  return -1
endi

if $data03 != -2 then 
  return -1
endi

P
plum-lihui 已提交
70 71 72 73 74
print =============== query data from st, but not support select * from super table, waiting fix
#sql select * from st
#if $rows != 4 then 
#  return -1
#endi
P
plum-lihui 已提交
75 76 77 78 79

print =============== stop and restart taosd
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start

P
plum-lihui 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
$loop_cnt = 0
check_dnode_ready:
	$loop_cnt = $loop_cnt + 1
	sleep 100
	if $loop_cnt == 10 then
	  print ====> dnode not ready!
		return -1
	endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
  return -1
endi
if $data04 != ready then
  goto check_dnode_ready
endi

P
plum-lihui 已提交
97 98
print =============== query data
sql select * from c1
P
plum-lihui 已提交
99 100 101 102 103
print rows: $rows 
print $data00  $data01
print $data10  $data11 
print $data20  $data21
print $data30  $data31
P
plum-lihui 已提交
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
if $rows != 4 then 
  return -1
endi

if $data01 != true then 
  return -1
endi

if $data02 != -1 then 
  return -1
endi

if $data03 != -2 then 
  return -1
endi

P
plum-lihui 已提交
120 121 122 123 124 125
print =============== query data from st, but not support select * from super table, waiting fix
#sql select * from st
#if $rows != 4 then 
#  return -1
#endi

P
plum-lihui 已提交
126
system sh/exec.sh -n dnode1 -s stop -x SIGINT