sql connect
sleep 3000
print ======================== dnode1 start

sql show databases
sql drop database $data00 -x e1
e1:
sql show databases
sql drop database $data00 -x e2
e2:

$dbPrefix = ta_cr_db
$tbPrefix = ta_cr_tb
$mtPrefix = ta_cr_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(tgcol bool)
sql create table $tb using $mt tags( 1 )
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = 1
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol = 0
if $rows != 0 then 
  return -1
endi
  
print =============== step3
$i = 3
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol smallint)
sql create table $tb using $mt tags( 1 )
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = 1
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol = 0
if $rows != 0 then 
  return -1
endi
  
print =============== step4
$i = 4
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint)
sql create table $tb using $mt tags( 1 )
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = 1
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol = 0
if $rows != 0 then 
  return -1
endi
  
print =============== step5
$i = 5
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
sql create table $tb using $mt tags( 1 )
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = 1
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol = 0
if $rows != 0 then 
  return -1
endi
  
print =============== step6
$i = 6
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bigint)
sql create table $tb using $mt tags( 1 )
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = 1
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol = 0
if $rows != 0 then 
  return -1
endi
  
print =============== step7
$i = 7
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float)
sql create table $tb using $mt tags( 1 )
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = 1
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol = 0
if $rows != 0 then
  print expect 0, actual: $rows
  return -1
endi
  
print =============== step8
$i = 8
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol double)
sql create table $tb using $mt tags( 1 )
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = 1
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol = 0
if $rows != 0 then 
  return -1
endi
  
print =============== step9
$i = 9
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10))
sql create table $tb using $mt tags( '1')
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = '1'
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol = '0'
if $rows != 0 then 
  return -1
endi
  
print =============== step10
$i = 10
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool)
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
  print expect 1, actual: $rows
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step11
$i = 11
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 smallint)
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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step12
$i = 12
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, 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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step13
$i = 13
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)
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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step14
$i = 14
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bigint)
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

sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi
print =============== step15
$i = 15
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, 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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step16
$i = 16
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 double)
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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step17
$i = 17
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(10))
sql create table $tb using $mt tags( 1, '2' )
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = true
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step18
$i = 18
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol 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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step19
$i = 19
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol tinyint, tgcol2 int)
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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step20
$i = 20
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 bigint)
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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step21
$i = 21
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol 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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step22
$i = 22
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol float, tgcol2 double)
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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step23
$i = 23
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol 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
sql select * from $mt where tgcol2 = 0
if $rows != 0 then 
  return -1
endi

print =============== step24
$i = 24
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10))
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
sql select * from $mt where tgcol2 = 2
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol3 = 3
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol4 = 4
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol5 = 5
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol6 = '6'
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol6 = '0'
if $rows != 0 then 
  return -1
endi

print =============== step25
$i = 25
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int, tgcol3 float, tgcol4 double, tgcol5 binary(10), tgcol6 binary(10))
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 tgcol6 = '6'
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol6 = '0'
if $rows != 0 then 
  return -1
endi

print =============== step26
$i = 26
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10), tgcol2 binary(10), tgcol3 binary(10), tgcol4 binary(10), tgcol5 binary(10), tgcol6 binary(10))
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 tgcol3 = '3'
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
sql select * from $mt where tgcol3 = '0'
if $rows != 0 then 
  return -1
endi

print =============== step27
$i = 27
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool, tgcol3 int, tgcol4 float, tgcol5 double, tgcol6 binary(10), tgcol7) -x step27
  return -1
step27:

print =============== step28
$i = 28
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250))
sql create table $tb using $mt tags('1', '1')
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = '1'
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi

print =============== step29
$i = 29
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(25), tgcol2 binary(250))
sql create table $tb using $mt tags('1', '1')
sql insert into $tb values(now, 1)  
sql select * from $mt where tgcol = '1'
if $rows != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi

print =============== step30
$i = 30
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(250), tgcol2 binary(250), tgcol3 binary(30)) -x step30
#  return -1
step30: 

print =============== step31
$i = 31
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(5))
sql_error create table $tb using $mt tags('1234567')
sql create table $tb using $mt tags('12345')
sql insert into $tb values(now, 1) 
sql select * from $mt 
print sql select * from $mt
if $rows != 1 then 
  return -1
endi

print $data00 $data01 $data02
if $data02 != 12345 then 
  return -1
endi
