lastrow.sim 2.0 KB
Newer Older
S
slguan 已提交
1
system sh/stop_dnodes.sh
S
slguan 已提交
2 3

system sh/deploy.sh -n dnode1 -i 1
4
system sh/cfg.sh -n dnode1 -c walLevel -v 1
H
Haojun Liao 已提交
5
system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4
S
slguan 已提交
6
system sh/exec.sh -n dnode1 -s start
H
Haojun Liao 已提交
7
sleep 100
S
slguan 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
sql connect

$dbPrefix = lr_db
$tbPrefix = lr_tb
$stbPrefix = lr_stb
$tbNum = 8
$rowNum = 60 * 24
$totalNum = $tbNum * $rowNum
$ts0 = 1537146000000
$delta = 60000
print ========== lastrow.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

sql drop database $db -x step1
step1:
H
Haojun Liao 已提交
25
sql create database $db
S
slguan 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
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 int)

$i = $tbNum
while $i > 0
  $tb = $tbPrefix . $i
  sql create table $tb using $stb tags( $i )
  $i = $i - 1
endw 

$ts = $ts0
$i = 1
while $i <= $tbNum
  $x = 0
  $tb = $tbPrefix . $i
  while $x < $rowNum
    $ts = $ts + $delta
    $c6 =  $x / 128 
    $c6 = $c6 * 128
    $c6 = $x - $c6
    $c3 = NULL
    $xr = $x / 10
    $xr = $xr * 10
    $xr = $x - $xr
    if $xr = 0 then
       $c3 = $x
    endi
    sql insert into $tb values ( $ts , $x , NULL , $x , $x , $x , $c6 , true, 'BINARY', 'NCHAR' ) 
    $x = $x + 1
  endw 
  $i = $i + 1
endw

print ====== test data created

S
scripts  
slguan 已提交
61
run general/parser/lastrow_query.sim
S
slguan 已提交
62 63 64

print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
H
Haojun Liao 已提交
65
sleep 500
S
slguan 已提交
66 67 68
system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
H
Haojun Liao 已提交
69
sleep 100
S
slguan 已提交
70

S
scripts  
slguan 已提交
71
run general/parser/lastrow_query.sim
S
scripts  
Shengliang Guan 已提交
72

H
Haojun Liao 已提交
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
print =================== last_row + nested query
sql use $db
sql create table lr_nested(ts timestamp, f int)
sql insert into lr_nested values(now, 1)
sql insert into lr_nested values(now+1s, null)
sql select last_row(*) from (select * from lr_nested)
if $rows != 1 then
  return -1
endi
if $data01 != NULL then
  return -1
endi
sql select last_row(*) from (select f from lr_nested)
if $rows != 1 then
  return -1
endi

system sh/exec.sh -n dnode1 -s stop -x SIGINT