insert_multiTbl.sim 2.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
system sh/stop_dnodes.sh


system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 500
sql connect
sleep 100
print ======================== dnode1 start

sql create database mul_db
sql use mul_db
sql create table mul_st (ts timestamp, col1 int) tags (tag1 int)

# case: insert multiple recordes for multiple table in a query
print =========== insert_multiTbl.sim case: insert multiple records for multiple table in a query
$ts = 1500000000000
sql insert into mul_t0 using mul_st tags(0) values ( $ts , 0) ( $ts + 1s, 1) ( $ts + 2s, 2) mul_t1 using mul_st tags(1) values ( $ts , 10) ( $ts + 1s, 11) ( $ts + 2s, 12) mul_t2 using mul_st tags(2) values ( $ts , 20) ( $ts + 1s, 21) ( $ts + 2s, 22) mul_t3 using mul_st tags(3) values ( $ts , 30) ( $ts + 1s, 31) ( $ts + 2s, 32)
sql select * from mul_st
print rows = $rows
if $rows != 12 then
  return -1
endi
if $data01 != 0 then
  return -1
endi

sql create table mul_b0 (ts timestamp, col1 int)
sql create table mul_b1 (ts timestamp, col1 int)
sql create table mul_b2 (ts timestamp, col1 int)
sql create table mul_b3 (ts timestamp, col1 int)

sql insert into mul_b0 values ( $ts , 0) ( $ts + 1s, 1) ( $ts + 2s, 2) mul_b1 values ( $ts , 10) ( $ts + 1s, 11) ( $ts + 2s, 12) mul_b2 values ( $ts , 20) ( $ts + 1s, 21) ( $ts + 2s, 22) mul_b3 values ( $ts , 30) ( $ts + 1s, 31) ( $ts + 2s, 32)
sql select * from mul_b3
print rows = $rows
if $rows != 3 then
  return -1
endi
if $data01 != 30 then
  return -1
endi

# insert values for specified columns
sql create table mul_st1 (ts timestamp, col1 int, col2 float, col3 binary(10)) tags (tag1 int, tag2 int, tag3 binary(8))
print =========== insert values for specified columns for multiple table in a query
$ts = 1500000000000
sql insert into mul_t10 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(0, 'tag3-0') values ( $ts , 00, 'binary00') ( $ts + 1s, 01, 'binary01') ( $ts + 2s, 02, 'binary02') mul_t11 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(1, 'tag3-0') values ( $ts , 10, 'binary10') ( $ts + 1s, 11, 'binary11') ( $ts + 2s, 12, 'binary12') mul_t12 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(2, 'tag3-0') values ( $ts , 20, 'binary20') ( $ts + 1s, 21, 'binary21') ( $ts + 2s, 22, 'binary22') mul_t13 (ts, col1, col3) using mul_st1 (tag1, tag3) tags(3, 'tag3-0') values ( $ts , 30, 'binary30') ( $ts + 1s, 31, 'binary31') ( $ts + 2s, 32, 'binary32')

sql select * from mul_st1
print rows = $rows
if $rows != 12 then
  return -1
endi
if $data02 != NULL then
  print "expect: NULL, act: $data03"
  return -1
endi
if $data03 != @binary00@ then
  return -1
endi
if $data92 != NULL then
  return -1
endi
if $data93 != @binary30@ then
  return -1
endi