basic0.sim 7.5 KB
Newer Older
P
plum-lihui 已提交
1 2 3 4 5 6 7 8 9
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sleep 50
sql connect

print =============== create database
sql create database d0
sql show databases
X
Xiaoyu Wang 已提交
10
if $rows != 2 then 
P
plum-lihui 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  return -1
endi

print $data00 $data01 $data02

sql use d0

print =============== create super table, include column type for count/sum/min/max/first
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned)

sql show stables
if $rows != 1 then 
  return -1
endi

print =============== create child table
sql create table ct1 using stb tags(1000)
sql create table ct2 using stb tags(2000)
P
plum-lihui 已提交
29
sql create table ct3 using stb tags(3000)
P
plum-lihui 已提交
30 31

sql show tables
P
plum-lihui 已提交
32
if $rows != 3 then 
P
plum-lihui 已提交
33 34 35 36 37 38 39 40 41 42 43 44
  return -1
endi


print =============== insert data, mode1: one row one table in sql
print =============== insert data, mode1: mulit rows one table in sql
print =============== insert data, mode1: one rows mulit table in sql
print =============== insert data, mode1: mulit rows mulit table in sql
sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3)
sql insert into ct2 values(now+0s, 10, 2.0, 3.0)
sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3)
X
Xiaoyu Wang 已提交
45 46
sql insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4)
sql insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6)
P
plum-lihui 已提交
47

P
plum-lihui 已提交
48 49
sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)

P
plum-lihui 已提交
50 51 52 53
#===================================================================
#===================================================================
print =============== query data from child table
sql select * from ct1
P
plum-lihui 已提交
54 55 56 57 58 59 60 61
print rows: $rows 
print $data00  $data01
print $data10  $data11 
print $data20  $data21
print $data30  $data31
print $data40  $data41
print $data50  $data51
print $data60  $data61
X
Xiaoyu Wang 已提交
62
if $rows != 7 then
P
plum-lihui 已提交
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
  return -1
endi
if $data01 != 10 then 
  return -1
endi
if $data02 != 2.00000 then 
  return -1
endi
if $data03 != 3.000000000 then 
  return -1
endi
#if $data41 != -14 then 
#  return -1
#endi
#if $data42 != -2.40000 then 
#  return -1
#endi
#if $data43 != -3.400000000 then 
#  return -1
#endi


print =============== select count(*) from child table
sql select count(*) from ct1
if $rows != 1 then 
  return -1
endi

print $data00 $data01 $data02
X
Xiaoyu Wang 已提交
92
if $data00 != 7 then 
P
plum-lihui 已提交
93 94 95 96 97 98
  return -1
endi

print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
print $data00 $data01 $data02  $data03
X
Xiaoyu Wang 已提交
99
if $data00 != 7 then 
P
plum-lihui 已提交
100 101
  return -1
endi
X
Xiaoyu Wang 已提交
102
if $data01 != 7 then 
P
plum-lihui 已提交
103 104
  return -1
endi
X
Xiaoyu Wang 已提交
105
if $data02 != 7 then 
P
plum-lihui 已提交
106 107
  return -1
endi
X
Xiaoyu Wang 已提交
108
if $data03 != 7 then 
P
plum-lihui 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121
  return -1
endi

#print =============== select first(*)/first(column) from child table
#sql select first(*) from ct1
#sql select first(ts), first(c1), first(c2), first(c3) from ct1

print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
print $data00 $data01 $data02  $data03
if $rows != 1 then 
  return -1
endi
X
Xiaoyu Wang 已提交
122
if $data00 != -16 then 
P
plum-lihui 已提交
123 124
  return -1
endi
X
Xiaoyu Wang 已提交
125
if $data01 != -2.60000 then 
P
plum-lihui 已提交
126 127
  return -1
endi
X
Xiaoyu Wang 已提交
128
if $data02 != -3.600000000 then 
P
plum-lihui 已提交
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
  return -1
endi

print =============== select max(column) from child table
sql select max(c1), max(c2), max(c3) from ct1
print $data00 $data01 $data02  $data03
if $rows != 1 then 
  return -1
endi
if $data00 != 13 then 
  return -1
endi
if $data01 != 2.30000 then 
  return -1
endi
if $data02 != 3.300000000 then 
  return -1
endi

print =============== select sum(column) from child table
sql select sum(c1), sum(c2), sum(c3) from ct1
print $data00 $data01 $data02  $data03
if $rows != 1 then 
  return -1
endi
X
Xiaoyu Wang 已提交
154
if $data00 != 1 then 
P
plum-lihui 已提交
155 156
  return -1
endi
X
Xiaoyu Wang 已提交
157
if $data01 != 1.099999905 then 
P
plum-lihui 已提交
158 159
  return -1
endi
X
Xiaoyu Wang 已提交
160
if $data02 != 2.100000000 then 
P
plum-lihui 已提交
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
  return -1
endi

print =============== select column, from child table
sql select c1, c2, c3 from ct1
print $data00 $data01 $data02
#if $rows != 4 then 
#  return -1
#endi
#if $data00 != 10 then 
#  return -1
#endi
#if $data01 != 2.00000 then 
#  return -1
#endi
#if $data02 != 3.000000000 then 
#  return -1
#endi
#if $data10 != 11 then 
#  return -1
#endi
#if $data11 != 2.10000 then 
#  return -1
#endi
#if $data12 != 3.100000000 then 
#  return -1
#endi
#if $data30 != 13 then 
#  return -1
#endi
#if $data31 != 2.30000 then 
#  return -1
#endi
#if $data32 != 3.300000000 then 
#  return -1
#endi
#===================================================================
#===================================================================

#print =============== query data from stb
#sql select * from stb
#if $rows != 4 then 
#  return -1
#endi
#print =============== select count(*) from supter table
#sql select count(*) from stb
#if $rows != 1 then 
#  return -1
#endi
#
#print $data00 $data01 $data02
#if $data00 != 8 then 
#  return -1
#endi
#
#print =============== select count(column) from supter table
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#print $data00 $data01 $data02  $data03
#if $data00 != 8 then 
#  return -1
#endi
#if $data01 != 8 then 
#  return -1
#endi
#if $data02 != 8 then 
#  return -1
#endi
#if $data03 != 8 then 
#  return -1
#endi


#===================================================================
#===================================================================

print =============== stop and restart taosd, then again do query above
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start

sleep 2000
sql select * from ct1
X
Xiaoyu Wang 已提交
242
if $rows != 7 then
P
plum-lihui 已提交
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
  return -1
endi
if $data01 != 10 then 
  return -1
endi
if $data02 != 2.00000 then 
  return -1
endi
if $data03 != 3.000000000 then 
  return -1
endi
#if $data41 != -14 then 
#  return -1
#endi
#if $data42 != -2.40000 then 
#  return -1
#endi
#if $data43 != -3.400000000 then 
#  return -1
#endi


print =============== select count(*) from child table
sql select count(*) from ct1
if $rows != 1 then 
  return -1
endi

print $data00 $data01 $data02
X
Xiaoyu Wang 已提交
272
if $data00 != 7 then 
P
plum-lihui 已提交
273 274 275 276 277 278
  return -1
endi

print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
print $data00 $data01 $data02  $data03
X
Xiaoyu Wang 已提交
279
if $data00 != 7 then 
P
plum-lihui 已提交
280 281
  return -1
endi
X
Xiaoyu Wang 已提交
282
if $data01 != 7 then 
P
plum-lihui 已提交
283 284
  return -1
endi
X
Xiaoyu Wang 已提交
285
if $data02 != 7 then 
P
plum-lihui 已提交
286 287
  return -1
endi
X
Xiaoyu Wang 已提交
288
if $data03 != 7 then 
P
plum-lihui 已提交
289 290 291 292 293 294 295 296 297 298 299 300 301
  return -1
endi

#print =============== select first(*)/first(column) from child table
#sql select first(*) from ct1
#sql select first(ts), first(c1), first(c2), first(c3) from ct1

print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
print $data00 $data01 $data02  $data03
if $rows != 1 then 
  return -1
endi
X
Xiaoyu Wang 已提交
302
if $data00 != -16 then 
P
plum-lihui 已提交
303 304
  return -1
endi
X
Xiaoyu Wang 已提交
305
if $data01 != -2.60000 then 
P
plum-lihui 已提交
306 307
  return -1
endi
X
Xiaoyu Wang 已提交
308
if $data02 != -3.600000000 then 
P
plum-lihui 已提交
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
  return -1
endi

print =============== select max(column) from child table
sql select max(c1), max(c2), max(c3) from ct1
print $data00 $data01 $data02  $data03
if $rows != 1 then 
  return -1
endi
if $data00 != 13 then 
  return -1
endi
if $data01 != 2.30000 then 
  return -1
endi
if $data02 != 3.300000000 then 
  return -1
endi

print =============== select sum(column) from child table
sql select sum(c1), sum(c2), sum(c3) from ct1
print $data00 $data01 $data02  $data03
if $rows != 1 then 
  return -1
endi
X
Xiaoyu Wang 已提交
334
if $data00 != 1 then 
P
plum-lihui 已提交
335 336
  return -1
endi
X
Xiaoyu Wang 已提交
337
if $data01 != 1.099999905 then 
P
plum-lihui 已提交
338 339
  return -1
endi
X
Xiaoyu Wang 已提交
340
if $data02 != 2.100000000 then 
P
plum-lihui 已提交
341 342 343 344
  return -1
endi

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