system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/cfg.sh -n dnode1 -c sessionsPerVnode -v 4
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect

$dbPrefix = slm_db
$tbPrefix = slm_tb
$stbPrefix = slm_stb
$tbNum = 10
$rowNum = 300
$totalNum = $tbNum * $rowNum
$ts0 = 1537146000000
$delta = 600000
print ========== slimit.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

sql drop database if exists $db
sql create database $db rows 200 cache 1024 tblocks 200 tables 4
print ====== create tables
sql use $db
sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool)

$i = 0
$ts = $ts0
$halfNum = $tbNum / 2
while $i < $tbNum
  $tb = $tbPrefix . $i
  $t1 = ' . $tb
  $t1 = $t1 . '
  $t2 = $i
  $t3 = $i
  $t4 = '涛思 . $tb
  $t4 = $t4 . '
  $t5 = $i
  $t6 = true
  sql create table $tb using $stb tags( $t1 , $t2 , $t3 , $t4 , $t5 , $t6 )
 
  $x = 0
  while $x < $rowNum
    $xs = $x * $delta
    $ts = $ts0 + $xs
    $c = $x / 10
    $c = $c * 10
    $c = $x - $c
    $binary = 'binary . $c 
    $binary = $binary . '
    $nchar = '涛思nchar . $c
    $nchar = $nchar . '
    sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) 
    $x = $x + 1
  endw 
  $ts = $ts + $delta
  sql insert into $tb values ( $ts , null, null, null, null, null, null, null, null, null )
  $i = $i + 1
endw
print ====== $db tables created

$db = $dbPrefix . 1
sql drop database if exists $db
sql create database $db rows 200 cache 1024
sql use $db
sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool)

$i = 0
$ts = $ts0
$halfNum = $tbNum / 2
while $i < $tbNum
  $tb = $tbPrefix . $i                                                                                                                           
  $t1 = ' . $tb
  $t1 = $t1 . '
  $t2 = $i
  $t3 = $i
  $t4 = '涛思 . $tb
  $t4 = $t4 . '
  $t5 = $i
  $t6 = true
  sql create table $tb using $stb tags( $t1 , $t2 , $t3 , $t4 , $t5 , $t6 )
 
  $x = 0
  while $x < $rowNum
    $xs = $x * $delta
    $ts = $ts0 + $xs
    sql insert into $tb values ( $ts , null , null , null , null , null , null , null , null , null ) 
    $x = $x + 1
  endw 
  $i = $i + 1
endw
print ====== $db tables created
  
run lite/parser/slimit_query.sim

print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
sleep 3000

run lite/parser/slimit_query.sim
