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

system sh/deploy.sh -n dnode1 -i 1
H
hjxilinx 已提交
4
system sh/cfg.sh -n dnode1 -c walLevel -v 0
S
slguan 已提交
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
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect
sql reset query cache

$dbPrefix = alt1_db

print ========== alter1.sim
$db = $dbPrefix

sql drop database if exists $db
sql create database $db
sql use $db

sql create table stb (ts timestamp, speed double, mileage double) tags(carId int, carModel int)
sql create table car1 using stb tags (1, 1)
sql create table car2 using stb tags (2, 1)
sql create table car3 using stb tags (3, 2)
sql insert into car1 values (now-1s, 100, 10000)
sql insert into car2 values (now, 100, 10000)
sql insert into car3 values (now, 100, 10000)
sql insert into car1 values (now, 120, 11000)
print ================== add a column
sql alter table stb add column c1 int
sql describe stb
if $rows != 6 then
  return -1
endi

sql select * from stb
print rows = $rows
if $rows != 4 then
  return -1
endi
39
if $data03 != NULL then
S
slguan 已提交
40 41
  return -1
endi
42
if $data13 != NULL then
S
slguan 已提交
43 44
  return -1
endi
45
if $data23 != NULL then
S
slguan 已提交
46 47
  return -1
endi
48
if $data33 != NULL then
S
slguan 已提交
49 50 51 52 53 54 55
  return -1
endi

sql select c1 from stb
if $rows != 4 then
  return -1
endi
56
if $data00 != NULL then
S
slguan 已提交
57 58
  return -1
endi
59
if $data30 != NULL then
S
slguan 已提交
60 61 62 63 64 65 66 67 68 69 70 71
  return -1
endi

sql select c1+speed from stb
if $rows != 4 then
  return -1
endi

sql select c1+speed from car1
if $rows != 2 then
  return -1
endi
72
if $data00 != NULL then
S
slguan 已提交
73 74
  return -1
endi
75
if $data10 != NULL then
S
slguan 已提交
76 77 78 79 80 81 82
  return -1
endi

sql select * from car1
if $rows != 2 then
  return -1
endi
83
if $data03 != NULL then
S
slguan 已提交
84 85
  return -1
endi
86
if $data13 != NULL then
S
slguan 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
  return -1
endi

sleep 3000
print ================== insert values into table
sql insert into car1 values (now, 1, 1,1 ) (now +1s, 2,2,2,) car2 values (now, 1,3,3)

sql select c1+speed from stb where c1 > 0
if $rows != 3 then
  return -1
endi

print ================== add a tag
sql alter table stb add tag t1 int
sql describe stb
if $rows != 7 then
  return -1
endi
if $data60 != t1 then
  return -1
endi

print ================== change a tag value
sql alter table car1 set tag carid=10
sql describe car1
if $rows != 7 then
  return -1
endi
if $data43 != 10 then
  return -1
endi

sql select * from stb where carid = 10
if $rows != 4 then
  return -1
endi

sql alter table car2 set tag carmodel = 2
sql select * from stb where carmodel = 2
print $rows
if $rows != 3 then
  return -1
endi

sql drop database $db
sql show databases
if $rows != 0 then 
  return -1
endi