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

print =============== create database
sql create database d0
X
Xiaoyu Wang 已提交
8
sql select * from information_schema.ins_databases
9
if $rows != 3 then
P
plum-lihui 已提交
10 11 12 13 14 15 16 17 18 19 20
  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
G
Ganlin Zhao 已提交
21
if $rows != 1 then
P
plum-lihui 已提交
22 23 24 25 26 27
  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 已提交
28
sql create table ct3 using stb tags(3000)
P
plum-lihui 已提交
29 30

sql show tables
G
Ganlin Zhao 已提交
31
if $rows != 3 then
P
plum-lihui 已提交
32 33 34 35 36
  return -1
endi

print =============== insert data, mode1: one row one table in sql
print =============== insert data, mode1: mulit rows one table in sql
P
plum-lihui 已提交
37 38
#print =============== insert data, mode1: one rows mulit table in sql
#print =============== insert data, mode1: mulit rows mulit table in sql
P
plum-lihui 已提交
39
sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
P
plum-lihui 已提交
40
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)
P
plum-lihui 已提交
41
sql insert into ct2 values(now+0s, 10, 2.0, 3.0)
P
plum-lihui 已提交
42
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)
P
plum-lihui 已提交
43 44
sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)

P
plum-lihui 已提交
45 46 47 48
#===================================================================
#===================================================================
print =============== query data from child table
sql select * from ct1
G
Ganlin Zhao 已提交
49
print rows: $rows
P
plum-lihui 已提交
50 51 52 53 54
print $data00  $data01 $data02 $data03
print $data10  $data11 $data12 $data13
print $data20  $data21 $data22 $data23
print $data30  $data31 $data32 $data33
if $rows != 4 then
P
plum-lihui 已提交
55 56
  return -1
endi
H
Haojun Liao 已提交
57 58
if $data01 != 10 then
  print expect 10, actual: $data01
P
plum-lihui 已提交
59 60
  return -1
endi
G
Ganlin Zhao 已提交
61
if $data02 != 2.00000 then
P
plum-lihui 已提交
62 63
  return -1
endi
G
Ganlin Zhao 已提交
64
if $data03 != 3.000000000 then
P
plum-lihui 已提交
65 66 67 68 69
  return -1
endi

print =============== select count(*) from child table
sql select count(*) from ct1
G
Ganlin Zhao 已提交
70
print rows: $rows
P
plum-lihui 已提交
71
print $data00  $data01 $data02 $data03
G
Ganlin Zhao 已提交
72
if $rows != 1 then
P
plum-lihui 已提交
73 74
  return -1
endi
G
Ganlin Zhao 已提交
75
if $data00 != 4 then
P
plum-lihui 已提交
76 77 78 79 80
  return -1
endi

print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
G
Ganlin Zhao 已提交
81
print rows: $rows
P
plum-lihui 已提交
82
print $data00  $data01 $data02 $data03
G
Ganlin Zhao 已提交
83
if $data00 != 4 then
P
plum-lihui 已提交
84 85
  return -1
endi
G
Ganlin Zhao 已提交
86
if $data01 != 4 then
P
plum-lihui 已提交
87 88
  return -1
endi
G
Ganlin Zhao 已提交
89
if $data02 != 4 then
P
plum-lihui 已提交
90 91
  return -1
endi
G
Ganlin Zhao 已提交
92
if $data03 != 4 then
P
plum-lihui 已提交
93 94 95 96
  return -1
endi

#print =============== select first(*)/first(column) from child table
S
Shengliang Guan 已提交
97 98
sql select first(*) from ct1
print ====> select first(*) from ct1
G
Ganlin Zhao 已提交
99
print rows: $rows
S
Shengliang Guan 已提交
100
print $data00  $data01 $data02 $data03
P
plum-lihui 已提交
101 102 103

sql select first(ts), first(c1), first(c2), first(c3) from ct1
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
G
Ganlin Zhao 已提交
104
print rows: $rows
P
plum-lihui 已提交
105
print $data00  $data01 $data02 $data03
G
Ganlin Zhao 已提交
106
if $rows != 1 then
P
plum-lihui 已提交
107 108
  return -1
endi
G
Ganlin Zhao 已提交
109
if $data01 != 10 then
P
plum-lihui 已提交
110 111
  return -1
endi
G
Ganlin Zhao 已提交
112
if $data02 != 2.00000 then
P
plum-lihui 已提交
113 114
  return -1
endi
G
Ganlin Zhao 已提交
115
if $data03 != 3.000000000 then
P
plum-lihui 已提交
116 117
  return -1
endi
P
plum-lihui 已提交
118 119 120

print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
G
Ganlin Zhao 已提交
121
print rows: $rows
P
plum-lihui 已提交
122
print $data00  $data01 $data02 $data03
G
Ganlin Zhao 已提交
123
if $rows != 1 then
P
plum-lihui 已提交
124 125
  return -1
endi
G
Ganlin Zhao 已提交
126
if $data00 != -13 then
P
plum-lihui 已提交
127 128
  return -1
endi
129 130
if $data01 != -2.30000 then
  print expect -2.30000, actual: $data01
P
plum-lihui 已提交
131 132
  return -1
endi
G
Ganlin Zhao 已提交
133
if $data02 != -3.300000000 then
P
plum-lihui 已提交
134 135 136 137 138 139
  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
G
Ganlin Zhao 已提交
140
if $rows != 1 then
P
plum-lihui 已提交
141 142
  return -1
endi
G
Ganlin Zhao 已提交
143
if $data00 != 11 then
P
plum-lihui 已提交
144 145
  return -1
endi
G
Ganlin Zhao 已提交
146
if $data01 != 2.10000 then
P
plum-lihui 已提交
147 148
  return -1
endi
G
Ganlin Zhao 已提交
149
if $data02 != 3.100000000 then
P
plum-lihui 已提交
150 151 152 153 154 155
  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
G
Ganlin Zhao 已提交
156
if $rows != 1 then
P
plum-lihui 已提交
157 158
  return -1
endi
G
Ganlin Zhao 已提交
159
if $data00 != -4 then
P
plum-lihui 已提交
160 161
  return -1
endi
G
Ganlin Zhao 已提交
162
if $data01 != -0.400000095 then
P
plum-lihui 已提交
163 164
  return -1
endi
G
Ganlin Zhao 已提交
165
if $data02 != -0.400000000 then
P
plum-lihui 已提交
166 167 168
  return -1
endi

P
plum-lihui 已提交
169
print =============== select column without timestamp, from child table
P
plum-lihui 已提交
170
sql select c1, c2, c3 from ct1
P
plum-lihui 已提交
171
print rows: $rows
P
plum-lihui 已提交
172
print $data00 $data01 $data02
P
plum-lihui 已提交
173 174 175
print $data10 $data11 $data12
print $data20 $data21 $data22
print $data30 $data31 $data32
G
Ganlin Zhao 已提交
176
if $rows != 4 then
P
plum-lihui 已提交
177 178
  return -1
endi
G
Ganlin Zhao 已提交
179
if $data00 != 10 then
P
plum-lihui 已提交
180 181
  return -1
endi
G
Ganlin Zhao 已提交
182
if $data01 != 2.00000 then
P
plum-lihui 已提交
183 184
  return -1
endi
G
Ganlin Zhao 已提交
185
if $data02 != 3.000000000 then
P
plum-lihui 已提交
186 187
  return -1
endi
G
Ganlin Zhao 已提交
188
if $data10 != 11 then
P
plum-lihui 已提交
189 190
  return -1
endi
G
Ganlin Zhao 已提交
191
if $data11 != 2.10000 then
P
plum-lihui 已提交
192 193
  return -1
endi
G
Ganlin Zhao 已提交
194
if $data12 != 3.100000000 then
P
plum-lihui 已提交
195 196
  return -1
endi
G
Ganlin Zhao 已提交
197
if $data30 != -13 then
P
plum-lihui 已提交
198 199
  return -1
endi
G
Ganlin Zhao 已提交
200
if $data31 != -2.30000 then
P
plum-lihui 已提交
201 202
  return -1
endi
G
Ganlin Zhao 已提交
203
if $data32 != -3.300000000 then
P
plum-lihui 已提交
204 205
  return -1
endi
P
plum-lihui 已提交
206 207 208
#===================================================================

#print =============== query data from stb
S
Shengliang Guan 已提交
209 210
sql select * from stb
print $rows
G
Ganlin Zhao 已提交
211
if $rows != 9 then
S
Shengliang Guan 已提交
212 213
  return -1
endi
P
plum-lihui 已提交
214

P
plum-lihui 已提交
215
#print =============== select count(*) from supter table
S
Shengliang Guan 已提交
216 217
sql select count(*) from stb
print $data00 $data01 $data02
G
Ganlin Zhao 已提交
218
if $rows != 1 then
S
Shengliang Guan 已提交
219 220
  return -1
endi
G
Ganlin Zhao 已提交
221
if $data00 != 9 then
S
Shengliang Guan 已提交
222 223
  return -1
endi
P
plum-lihui 已提交
224

P
plum-lihui 已提交
225 226 227 228 229 230 231 232 233 234 235 236
print =============== select count(column) from supter table
sql select ts, c1, c2, c3 from stb
print rows: $rows
print $data00 $data01 $data02  $data03
print $data10 $data11 $data12  $data13
print $data20 $data21 $data22  $data23
print $data30 $data31 $data32  $data33
print $data40 $data41 $data42  $data43
print $data50 $data51 $data52  $data53
print $data60 $data61 $data62  $data63
print $data70 $data71 $data72  $data73
print $data80 $data81 $data82  $data83
G
Ganlin Zhao 已提交
237
if $rows != 9 then
P
plum-lihui 已提交
238 239 240
  return -1
endi

G
Ganlin Zhao 已提交
241
# The order of data from different sub tables in the super table is random,
P
plum-lihui 已提交
242
# so this detection may fail randomly
G
Ganlin Zhao 已提交
243
if $data01 != 10 then
244 245
  return -1
endi
G
Ganlin Zhao 已提交
246
if $data02 != 2.00000 then
247 248
  return -1
endi
G
Ganlin Zhao 已提交
249
if $data03 != 3.000000000 then
250 251
  return -1
endi
P
plum-lihui 已提交
252

P
plum-lihui 已提交
253
#print =============== select count(column) from supter table
S
Shengliang Guan 已提交
254 255 256
sql select count(ts), count(c1), count(c2), count(c3) from stb
print rows: $rows
print $data00 $data01 $data02  $data03
G
Ganlin Zhao 已提交
257
if $data00 != 9 then
S
Shengliang Guan 已提交
258 259
  return -1
endi
G
Ganlin Zhao 已提交
260
if $data01 != 9 then
S
Shengliang Guan 已提交
261 262
  return -1
endi
G
Ganlin Zhao 已提交
263
if $data02 != 9 then
S
Shengliang Guan 已提交
264 265
  return -1
endi
G
Ganlin Zhao 已提交
266
if $data03 != 9 then
S
Shengliang Guan 已提交
267 268
  return -1
endi
P
plum-lihui 已提交
269 270 271 272 273 274

#===================================================================
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

P
plum-lihui 已提交
275
print =============== query data from child table
P
plum-lihui 已提交
276
sql select * from ct1
G
Ganlin Zhao 已提交
277
print rows: $rows
P
plum-lihui 已提交
278 279 280 281 282
print $data00  $data01 $data02 $data03
print $data10  $data11 $data12 $data13
print $data20  $data21 $data22 $data23
print $data30  $data31 $data32 $data33
if $rows != 4 then
P
plum-lihui 已提交
283 284
  return -1
endi
G
Ganlin Zhao 已提交
285
if $data01 != 10 then
P
plum-lihui 已提交
286 287
  return -1
endi
G
Ganlin Zhao 已提交
288
if $data02 != 2.00000 then
P
plum-lihui 已提交
289 290
  return -1
endi
G
Ganlin Zhao 已提交
291
if $data03 != 3.000000000 then
P
plum-lihui 已提交
292 293 294 295 296
  return -1
endi

print =============== select count(*) from child table
sql select count(*) from ct1
G
Ganlin Zhao 已提交
297
print rows: $rows
P
plum-lihui 已提交
298
print $data00  $data01 $data02 $data03
G
Ganlin Zhao 已提交
299
if $rows != 1 then
P
plum-lihui 已提交
300 301
  return -1
endi
G
Ganlin Zhao 已提交
302
if $data00 != 4 then
P
plum-lihui 已提交
303 304 305 306 307
  return -1
endi

print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
G
Ganlin Zhao 已提交
308
print rows: $rows
P
plum-lihui 已提交
309
print $data00  $data01 $data02 $data03
G
Ganlin Zhao 已提交
310
if $data00 != 4 then
P
plum-lihui 已提交
311 312
  return -1
endi
G
Ganlin Zhao 已提交
313
if $data01 != 4 then
P
plum-lihui 已提交
314 315
  return -1
endi
G
Ganlin Zhao 已提交
316
if $data02 != 4 then
P
plum-lihui 已提交
317 318
  return -1
endi
G
Ganlin Zhao 已提交
319
if $data03 != 4 then
P
plum-lihui 已提交
320 321 322 323
  return -1
endi

#print =============== select first(*)/first(column) from child table
S
Shengliang Guan 已提交
324 325
sql select first(*) from ct1
print ====> select first(*) from ct1
G
Ganlin Zhao 已提交
326
print rows: $rows
S
Shengliang Guan 已提交
327
print $data00  $data01 $data02 $data03
P
plum-lihui 已提交
328 329 330

sql select first(ts), first(c1), first(c2), first(c3) from ct1
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
G
Ganlin Zhao 已提交
331
print rows: $rows
P
plum-lihui 已提交
332
print $data00  $data01 $data02 $data03
G
Ganlin Zhao 已提交
333
if $rows != 1 then
P
plum-lihui 已提交
334 335
  return -1
endi
G
Ganlin Zhao 已提交
336
if $data01 != 10 then
P
plum-lihui 已提交
337 338
  return -1
endi
G
Ganlin Zhao 已提交
339
if $data02 != 2.00000 then
P
plum-lihui 已提交
340 341
  return -1
endi
G
Ganlin Zhao 已提交
342
if $data03 != 3.000000000 then
P
plum-lihui 已提交
343 344
  return -1
endi
P
plum-lihui 已提交
345 346 347

print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
G
Ganlin Zhao 已提交
348
print rows: $rows
P
plum-lihui 已提交
349
print $data00  $data01 $data02 $data03
G
Ganlin Zhao 已提交
350
if $rows != 1 then
P
plum-lihui 已提交
351 352
  return -1
endi
G
Ganlin Zhao 已提交
353
if $data00 != -13 then
P
plum-lihui 已提交
354 355
  return -1
endi
G
Ganlin Zhao 已提交
356
if $data01 != -2.30000 then
P
plum-lihui 已提交
357 358
  return -1
endi
G
Ganlin Zhao 已提交
359
if $data02 != -3.300000000 then
P
plum-lihui 已提交
360 361 362 363 364 365
  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
G
Ganlin Zhao 已提交
366
if $rows != 1 then
P
plum-lihui 已提交
367 368
  return -1
endi
G
Ganlin Zhao 已提交
369
if $data00 != 11 then
P
plum-lihui 已提交
370 371
  return -1
endi
G
Ganlin Zhao 已提交
372
if $data01 != 2.10000 then
P
plum-lihui 已提交
373 374
  return -1
endi
G
Ganlin Zhao 已提交
375
if $data02 != 3.100000000 then
P
plum-lihui 已提交
376 377 378 379 380 381
  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
G
Ganlin Zhao 已提交
382
if $rows != 1 then
P
plum-lihui 已提交
383 384
  return -1
endi
G
Ganlin Zhao 已提交
385
if $data00 != -4 then
P
plum-lihui 已提交
386 387
  return -1
endi
G
Ganlin Zhao 已提交
388
if $data01 != -0.400000095 then
P
plum-lihui 已提交
389 390
  return -1
endi
G
Ganlin Zhao 已提交
391
if $data02 != -0.400000000 then
P
plum-lihui 已提交
392 393 394 395 396 397 398 399 400 401
  return -1
endi

print =============== select column without timestamp, from child table
sql select c1, c2, c3 from ct1
print rows: $rows
print $data00 $data01 $data02
print $data10 $data11 $data12
print $data20 $data21 $data22
print $data30 $data31 $data32
G
Ganlin Zhao 已提交
402
if $rows != 4 then
P
plum-lihui 已提交
403 404
  return -1
endi
G
Ganlin Zhao 已提交
405
if $data00 != 10 then
P
plum-lihui 已提交
406 407
  return -1
endi
G
Ganlin Zhao 已提交
408
if $data01 != 2.00000 then
P
plum-lihui 已提交
409 410
  return -1
endi
G
Ganlin Zhao 已提交
411
if $data02 != 3.000000000 then
P
plum-lihui 已提交
412 413
  return -1
endi
G
Ganlin Zhao 已提交
414
if $data10 != 11 then
P
plum-lihui 已提交
415 416
  return -1
endi
G
Ganlin Zhao 已提交
417
if $data11 != 2.10000 then
P
plum-lihui 已提交
418 419
  return -1
endi
G
Ganlin Zhao 已提交
420
if $data12 != 3.100000000 then
P
plum-lihui 已提交
421 422
  return -1
endi
G
Ganlin Zhao 已提交
423
if $data30 != -13 then
P
plum-lihui 已提交
424 425
  return -1
endi
G
Ganlin Zhao 已提交
426
if $data31 != -2.30000 then
P
plum-lihui 已提交
427 428
  return -1
endi
G
Ganlin Zhao 已提交
429
if $data32 != -3.300000000 then
P
plum-lihui 已提交
430 431 432
  return -1
endi

S
Shengliang Guan 已提交
433 434 435
#===================================================================
print =============== query data from stb
sql select * from stb
G
Ganlin Zhao 已提交
436
if $rows != 9 then
S
Shengliang Guan 已提交
437
  return -1
G
Ganlin Zhao 已提交
438
endi
P
plum-lihui 已提交
439

S
Shengliang Guan 已提交
440 441 442
print =============== select count(*) from supter table
sql select count(*) from stb
print $data00 $data01 $data02
G
Ganlin Zhao 已提交
443
if $rows != 1 then
S
Shengliang Guan 已提交
444 445
  return -1
endi
G
Ganlin Zhao 已提交
446
if $data00 != 9 then
S
Shengliang Guan 已提交
447 448
  return -1
endi
P
plum-lihui 已提交
449

P
plum-lihui 已提交
450 451 452 453 454 455 456 457 458 459 460 461
print =============== select count(column) from supter table
sql select ts, c1, c2, c3 from stb
print rows: $rows
print $data00 $data01 $data02  $data03
print $data10 $data11 $data12  $data13
print $data20 $data21 $data22  $data23
print $data30 $data31 $data32  $data33
print $data40 $data41 $data42  $data43
print $data50 $data51 $data52  $data53
print $data60 $data61 $data62  $data63
print $data70 $data71 $data72  $data73
print $data80 $data81 $data82  $data83
G
Ganlin Zhao 已提交
462
if $rows != 9 then
P
plum-lihui 已提交
463 464
  return -1
endi
G
Ganlin Zhao 已提交
465
# The order of data from different sub tables in the super table is random,
P
plum-lihui 已提交
466
# so this detection may fail randomly
G
Ganlin Zhao 已提交
467
if $data01 != 10 then
468 469
  return -1
endi
G
Ganlin Zhao 已提交
470
if $data02 != 2.00000 then
471 472
  return -1
endi
G
Ganlin Zhao 已提交
473
if $data03 != 3.000000000 then
474 475
  return -1
endi
P
plum-lihui 已提交
476

P
plum-lihui 已提交
477
#print =============== select count(column) from supter table
S
Shengliang Guan 已提交
478 479
sql select count(ts), count(c1), count(c2), count(c3) from stb
print $data00 $data01 $data02  $data03
G
Ganlin Zhao 已提交
480
if $data00 != 9 then
S
Shengliang Guan 已提交
481 482
  return -1
endi
G
Ganlin Zhao 已提交
483
if $data01 != 9 then
S
Shengliang Guan 已提交
484 485
  return -1
endi
G
Ganlin Zhao 已提交
486
if $data02 != 9 then
S
Shengliang Guan 已提交
487 488
  return -1
endi
G
Ganlin Zhao 已提交
489
if $data03 != 9 then
S
Shengliang Guan 已提交
490 491
  return -1
endi
P
plum-lihui 已提交
492

G
Ganlin Zhao 已提交
493
system sh/exec.sh -n dnode1 -s stop -x SIGINT