basic0.sim 12.1 KB
Newer Older
P
plum-lihui 已提交
1 2 3 4 5 6 7 8
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
sql show databases
9
if $rows != 3 then
P
plum-lihui 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  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 已提交
28
sql create table ct3 using stb tags(3000)
P
plum-lihui 已提交
29 30

sql show tables
P
plum-lihui 已提交
31
if $rows != 3 then 
P
plum-lihui 已提交
32 33 34 35 36 37
  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 已提交
38 39
#print =============== insert data, mode1: one rows mulit table in sql
#print =============== insert data, mode1: mulit rows mulit table in sql
P
plum-lihui 已提交
40
sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
P
plum-lihui 已提交
41
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 已提交
42
sql insert into ct2 values(now+0s, 10, 2.0, 3.0)
P
plum-lihui 已提交
43 44 45
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)
#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 已提交
46

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

P
plum-lihui 已提交
49 50 51 52
#===================================================================
#===================================================================
print =============== query data from child table
sql select * from ct1
P
plum-lihui 已提交
53
print rows: $rows 
P
plum-lihui 已提交
54 55 56 57 58
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 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  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
P
plum-lihui 已提交
83 84
print rows: $rows 
print $data00  $data01 $data02 $data03
P
plum-lihui 已提交
85 86 87
if $rows != 1 then 
  return -1
endi
P
plum-lihui 已提交
88
if $data00 != 4 then 
P
plum-lihui 已提交
89 90 91 92 93
  return -1
endi

print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
P
plum-lihui 已提交
94 95 96
print rows: $rows 
print $data00  $data01 $data02 $data03
if $data00 != 4 then 
P
plum-lihui 已提交
97 98
  return -1
endi
P
plum-lihui 已提交
99
if $data01 != 4 then 
P
plum-lihui 已提交
100 101
  return -1
endi
P
plum-lihui 已提交
102
if $data02 != 4 then 
P
plum-lihui 已提交
103 104
  return -1
endi
P
plum-lihui 已提交
105
if $data03 != 4 then 
P
plum-lihui 已提交
106 107 108 109 110
  return -1
endi

#print =============== select first(*)/first(column) from child table
#sql select first(*) from ct1
P
plum-lihui 已提交
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
#print ====> select first(*) from ct1
#print rows: $rows 
#print $data00  $data01 $data02 $data03

sql select first(ts), first(c1), first(c2), first(c3) from ct1
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
print rows: $rows 
print $data00  $data01 $data02 $data03
if $rows != 1 then 
  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
P
plum-lihui 已提交
131 132 133

print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
P
plum-lihui 已提交
134 135
print rows: $rows 
print $data00  $data01 $data02 $data03
P
plum-lihui 已提交
136 137 138
if $rows != 1 then 
  return -1
endi
P
plum-lihui 已提交
139
if $data00 != -13 then 
P
plum-lihui 已提交
140 141
  return -1
endi
142 143
if $data01 != -2.30000 then
  print expect -2.30000, actual: $data01
P
plum-lihui 已提交
144 145
  return -1
endi
P
plum-lihui 已提交
146
if $data02 != -3.300000000 then 
P
plum-lihui 已提交
147 148 149 150 151 152 153 154 155
  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
P
plum-lihui 已提交
156
if $data00 != 11 then 
P
plum-lihui 已提交
157 158
  return -1
endi
P
plum-lihui 已提交
159
if $data01 != 2.10000 then 
P
plum-lihui 已提交
160 161
  return -1
endi
P
plum-lihui 已提交
162
if $data02 != 3.100000000 then 
P
plum-lihui 已提交
163 164 165 166 167 168 169 170 171
  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
P
plum-lihui 已提交
172
if $data00 != -4 then 
P
plum-lihui 已提交
173 174
  return -1
endi
P
plum-lihui 已提交
175
if $data01 != -0.400000095 then 
P
plum-lihui 已提交
176 177
  return -1
endi
P
plum-lihui 已提交
178
if $data02 != -0.400000000 then 
P
plum-lihui 已提交
179 180 181
  return -1
endi

P
plum-lihui 已提交
182
print =============== select column without timestamp, from child table
P
plum-lihui 已提交
183
sql select c1, c2, c3 from ct1
P
plum-lihui 已提交
184
print rows: $rows
P
plum-lihui 已提交
185
print $data00 $data01 $data02
P
plum-lihui 已提交
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
print $data10 $data11 $data12
print $data20 $data21 $data22
print $data30 $data31 $data32
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
P
plum-lihui 已提交
219 220 221 222 223 224 225 226
#===================================================================
#===================================================================

#print =============== query data from stb
#sql select * from stb
#if $rows != 4 then 
#  return -1
#endi
P
plum-lihui 已提交
227

P
plum-lihui 已提交
228 229
#print =============== select count(*) from supter table
#sql select count(*) from stb
P
plum-lihui 已提交
230
#print $data00 $data01 $data02
P
plum-lihui 已提交
231 232 233
#if $rows != 1 then 
#  return -1
#endi
P
plum-lihui 已提交
234
#if $data00 != 9 then 
P
plum-lihui 已提交
235 236
#  return -1
#endi
P
plum-lihui 已提交
237

P
plum-lihui 已提交
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
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
if $rows != 9 then 
  return -1
endi

# The order of data from different sub tables in the super table is random, 
# so this detection may fail randomly
256 257 258 259 260 261 262 263 264
if $data01 != 10 then 
  return -1
endi
if $data02 != 2.00000 then 
  return -1
endi
if $data03 != 3.000000000 then 
  return -1
endi
P
plum-lihui 已提交
265

P
plum-lihui 已提交
266 267
#print =============== select count(column) from supter table
#sql select count(ts), count(c1), count(c2), count(c3) from stb
P
plum-lihui 已提交
268
#print rows: $rows
P
plum-lihui 已提交
269
#print $data00 $data01 $data02  $data03
P
plum-lihui 已提交
270 271 272 273
#print $data10 $data11 $data12  $data13
#print $data20 $data21 $data22  $data23
#print $data30 $data31 $data32  $data33
#if $data00 != 9 then 
P
plum-lihui 已提交
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
#  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

P
plum-lihui 已提交
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
$loop_cnt = 0
check_dnode_ready:
	$loop_cnt = $loop_cnt + 1
	sleep 200
	if $loop_cnt == 10 then
	  print ====> dnode not ready!
		return -1
	endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
  return -1
endi
if $data04 != ready then
  goto check_dnode_ready
endi

print =============== query data from child table
P
plum-lihui 已提交
311
sql select * from ct1
P
plum-lihui 已提交
312 313 314 315 316 317
print rows: $rows 
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 已提交
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
  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
P
plum-lihui 已提交
342 343
print rows: $rows 
print $data00  $data01 $data02 $data03
P
plum-lihui 已提交
344 345 346
if $rows != 1 then 
  return -1
endi
P
plum-lihui 已提交
347
if $data00 != 4 then 
P
plum-lihui 已提交
348 349 350 351 352
  return -1
endi

print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
P
plum-lihui 已提交
353 354 355
print rows: $rows 
print $data00  $data01 $data02 $data03
if $data00 != 4 then 
P
plum-lihui 已提交
356 357
  return -1
endi
P
plum-lihui 已提交
358
if $data01 != 4 then 
P
plum-lihui 已提交
359 360
  return -1
endi
P
plum-lihui 已提交
361
if $data02 != 4 then 
P
plum-lihui 已提交
362 363
  return -1
endi
P
plum-lihui 已提交
364
if $data03 != 4 then 
P
plum-lihui 已提交
365 366 367 368 369
  return -1
endi

#print =============== select first(*)/first(column) from child table
#sql select first(*) from ct1
P
plum-lihui 已提交
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
#print ====> select first(*) from ct1
#print rows: $rows 
#print $data00  $data01 $data02 $data03

sql select first(ts), first(c1), first(c2), first(c3) from ct1
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
print rows: $rows 
print $data00  $data01 $data02 $data03
if $rows != 1 then 
  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
P
plum-lihui 已提交
390 391 392

print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
P
plum-lihui 已提交
393 394
print rows: $rows 
print $data00  $data01 $data02 $data03
P
plum-lihui 已提交
395 396 397
if $rows != 1 then 
  return -1
endi
P
plum-lihui 已提交
398
if $data00 != -13 then 
P
plum-lihui 已提交
399 400
  return -1
endi
P
plum-lihui 已提交
401
if $data01 != -2.30000 then 
P
plum-lihui 已提交
402 403
  return -1
endi
P
plum-lihui 已提交
404
if $data02 != -3.300000000 then 
P
plum-lihui 已提交
405 406 407 408 409 410 411 412 413
  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
P
plum-lihui 已提交
414
if $data00 != 11 then 
P
plum-lihui 已提交
415 416
  return -1
endi
P
plum-lihui 已提交
417
if $data01 != 2.10000 then 
P
plum-lihui 已提交
418 419
  return -1
endi
P
plum-lihui 已提交
420
if $data02 != 3.100000000 then 
P
plum-lihui 已提交
421 422 423 424 425 426 427 428 429
  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
P
plum-lihui 已提交
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
if $data00 != -4 then 
  return -1
endi
if $data01 != -0.400000095 then 
  return -1
endi
if $data02 != -0.400000000 then 
  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
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 
P
plum-lihui 已提交
466 467
  return -1
endi
P
plum-lihui 已提交
468
if $data30 != -13 then 
P
plum-lihui 已提交
469 470
  return -1
endi
P
plum-lihui 已提交
471
if $data31 != -2.30000 then 
P
plum-lihui 已提交
472 473
  return -1
endi
P
plum-lihui 已提交
474 475 476 477 478 479 480 481 482 483
if $data32 != -3.300000000 then 
  return -1
endi
#===================================================================
#===================================================================

#print =============== query data from stb
#sql select * from stb
#if $rows != 4 then 
#  return -1
P
plum-lihui 已提交
484 485
#endi      

P
plum-lihui 已提交
486 487
#print =============== select count(*) from supter table
#sql select count(*) from stb
P
plum-lihui 已提交
488
#print $data00 $data01 $data02
P
plum-lihui 已提交
489 490 491
#if $rows != 1 then 
#  return -1
#endi
P
plum-lihui 已提交
492
#if $data00 != 9 then 
P
plum-lihui 已提交
493 494
#  return -1
#endi
P
plum-lihui 已提交
495

P
plum-lihui 已提交
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
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
if $rows != 9 then 
  return -1
endi
# The order of data from different sub tables in the super table is random, 
# so this detection may fail randomly
513 514 515 516 517 518 519 520 521
if $data01 != 10 then 
  return -1
endi
if $data02 != 2.00000 then 
  return -1
endi
if $data03 != 3.000000000 then 
  return -1
endi
P
plum-lihui 已提交
522

P
plum-lihui 已提交
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538
#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

P
plum-lihui 已提交
539

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