charScalarFunction.sim 21.7 KB
Newer Older
P
plum-lihui 已提交
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
#### length, char_length, lower, upper, ltrim, rtrim, concat, concat_ws, substr.

system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1
system sh/exec.sh -n dnode1 -s start

$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

sql connect

$vgroups  = 4
$dbNamme  = db

print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
#print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29

sql use $dbNamme

print =============== create super table
sql create table stb (ts timestamp, c1 binary(128), c2 nchar(128)) tags (t1 binary(128), t2 nchar(128))

print =============== create child table and normal table, insert data
sql create table ctb0 using stb tags("tag-binary-0" , "tag-nchar-0" )
sql create table ntb0 (ts timestamp, c1 binary(128), c2 nchar(128))
sql insert into ctb0 values ("2022-01-01 00:00:00.000" , "lenByte0=11" , "lenByte0=44" )
sql insert into ntb0 values ("2022-01-01 00:00:00.000" , "lenByte0=11" , "lenByte0=44" )
sql insert into ctb0 values ("2022-01-01 00:00:00.001" , "lenByte01=12" , "lenByte01=48" )
sql insert into ntb0 values ("2022-01-01 00:00:00.001" , "lenByte01=12" , "lenByte01=48" )
sql insert into ctb0 values ("2022-01-01 00:00:00.002" , "lenChar01=12" , "lenChar01=48" )
sql insert into ntb0 values ("2022-01-01 00:00:00.002" , "lenChar01=12" , "lenChar01=48" )
sql insert into ctb0 values ("2022-01-01 00:00:00.003" , "lenChar0001=14" , "lenChar0001=56" )
sql insert into ntb0 values ("2022-01-01 00:00:00.003" , "lenChar0001=14" , "lenChar0001=56" )

sql create table ctb1 using stb tags("tag-binary-1" , "tag-nchar-1" )
sql create table ntb1 (ts timestamp, c1 binary(128), c2 nchar(128))
sql insert into ctb1 values ("2022-01-01 00:00:00.000" , "ABCD1234" , "ABCD1234" )
sql insert into ntb1 values ("2022-01-01 00:00:00.000" , "ABCD1234" , "ABCD1234" )
sql insert into ctb1 values ("2022-01-01 00:00:00.001" , "AaBbCcDd1234" , "AaBbCcDd1234" )
sql insert into ntb1 values ("2022-01-01 00:00:00.001" , "AaBbCcDd1234" , "AaBbCcDd1234" )

sql create table ctb2 using stb tags("tag-binary-2" , "tag-nchar-2" )
sql create table ntb2 (ts timestamp, c1 binary(128), c2 nchar(128))
sql insert into ctb2 values ("2022-01-01 00:00:00.000" , "abcd1234" , "abcd1234" )
sql insert into ntb2 values ("2022-01-01 00:00:00.000" , "abcd1234" , "abcd1234" )
sql insert into ctb2 values ("2022-01-01 00:00:00.001" , "AaBbCcDd1234" , "AaBbCcDd1234" )
sql insert into ntb2 values ("2022-01-01 00:00:00.001" , "AaBbCcDd1234" , "AaBbCcDd1234" )

sql create table ctb3 using stb tags("tag-binary-3" , "tag-nchar-3" )
sql create table ntb3 (ts timestamp, c1 binary(128), c2 nchar(128))
sql insert into ctb3 values ("2022-01-01 00:00:00.000" , "  abcd  1234  " , "  abcd  1234  " )
sql insert into ntb3 values ("2022-01-01 00:00:00.000" , "  abcd  1234  " , "  abcd  1234  " )

sql create table stb2 (ts timestamp, c1 binary(128), c2 nchar(128), c3 binary(128), c4 nchar(128)) tags (t1 binary(128), t2 nchar(128), t3 binary(128), t4 nchar(128))
sql create table ctb4 using stb2 tags("tag-binary-4" , "tag-nchar-4", "tag-binary-4" , "tag-nchar-4")
sql create table ntb4 (ts timestamp, c1 binary(128), c2 nchar(128), c3 binary(128), c4 nchar(128))
sql insert into ctb4 values ("2022-01-01 00:00:00.000" , " ab 12 " , " ab 12 " , " cd 34 " , " cd 34 "  )
sql insert into ntb4 values ("2022-01-01 00:00:00.000" , " ab 12 " , " ab 12 " , " cd 34 " , " cd 34 "  )

sql create table ctb5 using stb tags("tag-binary-5" , "tag-nchar-5")
sql create table ntb5 (ts timestamp, c1 binary(128), c2 nchar(128))
sql insert into ctb5 values ("2022-01-01 00:00:00.000" , "0123456789" , "0123456789" )
sql insert into ntb5 values ("2022-01-01 00:00:00.000" , "0123456789" , "0123456789" )
sql insert into ctb5 values ("2022-01-01 00:00:00.001" , NULL , NULL )
sql insert into ntb5 values ("2022-01-01 00:00:00.001" , NULL , NULL )

C
cpwu 已提交
86 87 88 89 90 91 92 93
sql create table stb3 (ts timestamp, c1 binary(64), c2 nchar(64), c3 nchar(64) ) tags (t1 nchar(64))
sql create table ctb6 using stb3 tags("tag-nchar-6")
sql create table ntb6 (ts timestamp, c1 binary(64), c2 nchar(64), c3 nchar(64) )
sql insert into ctb6 values ("2022-01-01 00:00:00.000" , "0123456789" , "中文测试1" , "中文测试2" )
sql insert into ntb6 values ("2022-01-01 00:00:00.000" , "0123456789" , "中文测试01", "中文测试01" )
sql insert into ctb6 values ("2022-01-01 00:00:00.001" , NULL , NULL, NULL )
sql insert into ntb6 values ("2022-01-01 00:00:00.001" , NULL , NULL, NULL )

P
plum-lihui 已提交
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
$loop_test = 0
loop_test_pos:

print ====> length
print ====> select c1, length(c1), c2, length(c2) from ctb0
sql select c1, length(c1), c2, length(c2) from ctb0
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
  return -1
endi
if $data01 != 11 then
  return -1
endi
if $data03 != 44 then
  return -1
endi
if $data11 != 12 then
  return -1
endi
if $data13 != 48 then
  return -1
endi

print ====> select c1, length(c1), c2, length(c2) from ntb0
sql select c1, length(c1), c2, length(c2) from ntb0
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
  return -1
endi
if $data01 != 11 then
  return -1
endi
if $data03 != 44 then
  return -1
endi
if $data11 != 12 then
  return -1
endi
if $data13 != 48 then
  return -1
endi

print ====> select length("abcd1234"), char_length("abcd1234=-+*") from ntb0
sql select length("abcd1234"), char_length("abcd1234=-+*") from ntb0
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
  return -1
endi
if $data00 != 8 then
  return -1
endi
if $data01 != 12 then
  return -1
endi

C
cpwu 已提交
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 242 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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 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 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
print ====> select c2 ,length(c2), char_length(c2) from ctb6
sql select c2 ,length(c2), char_length(c2) from ctb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data01 != 20 then
  return -1
endi
if $data02 != 5 then
  return -1
endi
if $data11 != NULL then
  return -1
endi

print ====> select c2 ,length(c2),char_length(c2) from ntb6
sql select c2 ,length(c2),char_length(c2) from ntb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data01 != 24 then
  return -1
endi
if $data02 != 6 then
  return -1
endi
if $data11 != NULL then
  return -1
endi

print ====> select c2 ,lower(c2), upper(c2) from ctb6
sql select c2 ,lower(c2), upper(c2) from ctb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data01 != 中文测试1 then
  return -1
endi
if $data02 != 中文测试1 then
  return -1
endi
if $data11 != NULL then
  return -1
endi

print ====> select c2 ,lower(c2), upper(c2) from ntb6
sql select c2 ,lower(c2), upper(c2) from ntb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data01 != 中文测试01 then
  return -1
endi
if $data02 != 中文测试01 then
  return -1
endi
if $data11 != NULL then
  return -1
endi

print ====> select c2, ltrim(c2), ltrim(c2) from ctb6
sql select c2, ltrim(c2), ltrim(c2) from ctb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data01 != 中文测试1 then
  return -1
endi
if $data02 != 中文测试1 then
  return -1
endi
if $data11 != NULL then
  return -1
endi

print ====> select c2, ltrim(c2), ltrim(c2) from ntb6
sql select c2, ltrim(c2), ltrim(c2) from ntb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data01 != 中文测试01 then
  return -1
endi
if $data02 != 中文测试01 then
  return -1
endi
if $data11 != NULL then
  return -1
endi

print ====> select c2, c3 , concat(c2,c3) from ctb6
sql select c2, c3 , concat(c2,c3) from ctb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data02 != 中文测试01中文测试01 then
  return -1
endi
if $data12 != NULL then
  return -1
endi

print ====> select c2, c3 , concat(c2,c3) from ntb6
sql select c2, c3 , concat(c2,c3) from ntb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data02 != 中文测试01中文测试01 then
  return -1
endi
if $data12 != NULL then
  return -1
endi

print ====> select c2, c3 , concat_ws('_', c2, c3) from ctb6
sql select c2, c3 , concat_ws('_', c2, c3) from ctb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data02 != 中文测试01_中文测试01 then
  return -1
endi
if $data12 != NULL then
  return -1
endi

print ====> select c2, c3 , concat_ws('_', c2, c3) from ntb6
sql select c2, c3 , concat_ws('_', c2, c3) from ntb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data02 != 中文测试01_中文测试01 then
  return -1
endi
if $data12 != NULL then
  return -1
endi

print ====> select  c2, substr(c2,1, 4) from ctb6
sql select  c2, substr(c2,1, 4) from ctb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data01 != 中文测试01 then
  return -1
endi
if $data02 != 中文测试01 then
  return -1
endi
if $data11 != NULL then
  return -1
endi

print ====> select  c2, substr(c2,1, 4) from ntb6
sql select  c2, substr(c2,1, 4) from ntb6
print ====> rows: $rows
print ====> $data00 $data01 $data02
print ====> $data10 $data11 $data12
if $rows != 2 then
  return -1
endi
if $data01 != 中文测试01 then
  return -1
endi
if $data02 != 中文测试01 then
  return -1
endi
if $data11 != NULL then
  return -1
endi

P
plum-lihui 已提交
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 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 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
#sql_error select c1, length(t1), c2, length(t2) from ctb0

print ====> char_length
print ====> select c1, char_length(c1), c2, char_length(c2) from ctb0
sql select c1, char_length(c1), c2, char_length(c2) from ctb0
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
  return -1
endi
if $data21 != 12 then
  return -1
endi
if $data23 != 12 then
  return -1
endi
if $data31 != 14 then
  return -1
endi
if $data33 != 14 then
  return -1
endi

print ====> select c1, char_length(c1), c2, char_length(c2) from ntb0
sql select c1, char_length(c1), c2, char_length(c2) from ntb0
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
  return -1
endi
if $data21 != 12 then
  return -1
endi
if $data23 != 12 then
  return -1
endi
if $data31 != 14 then
  return -1
endi
if $data33 != 14 then
  return -1
endi

#sql_error select c1, char_length(t1), c2, char_length(t2) from ctb0

print ====> lower
sql select c1, lower(c1), c2, lower(c2), lower("abcdEFGH=-*&%") from ntb1
print ====> select c1, lower(c1), c2, lower(c2), lower("abcdEFGH=-*&%") from ctb1
sql select c1, lower(c1), c2, lower(c2), lower("abcdEFGH=-*&%") from ctb1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
  return -1
endi
if $data01 != abcd1234 then
  return -1
endi
if $data03 != abcd1234 then
  return -1
endi
if $data04 != abcdefgh=-*&% then
  return -1
endi
if $data11 != aabbccdd1234 then
  return -1
endi
if $data13 != aabbccdd1234 then
  return -1
endi
if $data14 != abcdefgh=-*&% then
  return -1
endi

#sql_error select c1, lower(t1), c2, lower(t2) from ctb1

print ====> upper
sql select c1, upper(c1), c2, upper(c2), upper("abcdEFGH=-*&%") from ntb2
print ====> select c1, upper(c1), c2, upper(c2), upper("abcdEFGH=-*&%") from ctb2
sql select c1, upper(c1), c2, upper(c2), upper("abcdEFGH=-*&%") from ctb2
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
  return -1
endi
if $data01 != ABCD1234 then
  return -1
endi
if $data03 != ABCD1234 then
  return -1
endi
if $data04 != ABCDEFGH=-*&% then
  return -1
endi
if $data11 != AABBCCDD1234 then
  return -1
endi
if $data13 != AABBCCDD1234 then
  return -1
endi
if $data14 != ABCDEFGH=-*&% then
  return -1
endi

#sql_error select c1, upper(t1), c2, upper(t2) from ctb2

print ====> ltrim
sql select c1, ltrim(c1), c2, ltrim(c2), ltrim("  abcdEFGH  =-*&%  ") from ntb3
print ====> select c1, ltrim(c1), c2, ltrim(c2), ltrim("  abcdEFGH  =-*&%  ") from ctb3
sql select c1, ltrim(c1), c2, ltrim(c2), ltrim("  abcdEFGH  =-*&%  ") from ctb3
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 1 then
  return -1
endi
if $data01 != @abcd  1234  @ then
  return -1
endi
if $data03 != @abcd  1234  @ then
  return -1
endi
if $data04 != @abcdEFGH  =-*&%  @ then
  return -1
endi

#sql_error select c1, ltrim(t1), c2, ltrim(t2) from ctb3


P
plum-lihui 已提交
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
print ====> rtrim
sql select c1, rtrim(c1), c2, rtrim(c2), rtrim("  abcdEFGH  =-*&%  ") from ntb3
print ====> select c1, rtrim(c1), c2, rtrim(c2), rtrim("  abcdEFGH  =-*&%  ") from ctb3
sql select c1, rtrim(c1), c2, rtrim(c2), rtrim("  abcdEFGH  =-*&%  ") from ctb3
print ====> rows: $rows
print ====> [ $data00 ] [ $data01 ] [ $data02 ] [ $data03 ] [ $data04 ] [ $data05 ] [ $data06 ]
print ====> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 1 then
  return -1
endi
if $data01 != @  abcd  1234@ then
  return -1
endi
if $data03 != @  abcd  1234@ then
  return -1
endi
if $data04 != @  abcdEFGH  =-*&%@ then
  return -1
endi
P
plum-lihui 已提交
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707

#sql_error select c1, rtrim(t1), c2, rtrim(t2) from ctb3

print ====> concat
sql select c1, c3, concat(c1, c3), c2, c4, concat(c2, c4), concat("binary+", c1, c3), concat("nchar+", c2, c4) from ntb4
print ====> select c1, c3, concat(c1, c3), c2, c4, concat(c2, c4), concat("binary+", c1, c3), concat("nchar+", c2, c4) from ctb4
sql select c1, c3, concat(c1, c3), c2, c4, concat(c2, c4), concat("binary+", c1, c3), concat("nchar+", c2, c4) from ctb4
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05 $data06
print ====> $data10 $data11 $data12 $data13 $data14 $data15 $data16
if $rows != 1 then
  return -1
endi
if $data02 != @ ab 12  cd 34 @ then
  return -1
endi
if $data05 != @ ab 12  cd 34 @ then
  return -1
endi
if $data06 != @binary+ ab 12  cd 34 @ then
  return -1
endi
if $data07 != @nchar+ ab 12  cd 34 @ then
  return -1
endi

sql select c1, c3, concat("bin-", c1, "-a1-", "a2-", c3, "-a3-", "a4-", "END"), c2, c4, concat("nchar-", c2, "-a1-", "-a2-", c4, "-a3-", "a4-", "END") from ntb4
print ====> select c1, c3, concat("bin-", c1, "-a1-", "a2-", c3, "-a3-", "a4-", "END"), c2, c4, concat("nchar-", c2, "-a1-", "a2-", c4, "-a3-", "a4-", "END") from ctb4
sql select c1, c3, concat("bin-", c1, "-a1-", "a2-", c3, "-a3-", "a4-", "END"), c2, c4, concat("nchar-", c2, "-a1-", "a2-", c4, "-a3-", "a4-", "END") from ctb4
print ====> rows: $rows
print ====> [ $data00 ] [ $data01 ] [ $data02 ] [ $data03 ] [ $data04 ] [ $data05 ] [ $data06 ]
print ====> $data10 $data11 $data12 $data13 $data14 $data15 $data16
if $rows != 1 then
  return -1
endi
if $data02 != @bin- ab 12 -a1-a2- cd 34 -a3-a4-END@ then
  return -1
endi
if $data05 != @nchar- ab 12 -a1-a2- cd 34 -a3-a4-END@ then
  return -1
endi

#sql_error select c1, c2, concat(c1, c2), c3, c4, concat(c3, c4) from ctb4
#sql_error select t1, t2, concat(t1, t2), t3, t4, concat(t3, t4) from ctb4
#sql_error select t1, t3, concat(t1, t3), t2, t4, concat(t2, t4) from ctb4

print ====> concat_ws
sql select c1, c3, concat_ws("*", c1, c3), c2, c4, concat_ws("*", c2, c4), concat_ws("*", "binary+", c1, c3), concat_ws("*", "nchar+", c2, c4) from ntb4
print ====> select c1, c3, concat_ws("*", c1, c3), c2, c4, concat_ws("*", c2, c4), concat_ws("*", "binary+", c1, c3), concat_ws("*", "nchar+", c2, c4) from ctb4
sql select c1, c3, concat_ws("*", c1, c3), c2, c4, concat_ws("*", c2, c4), concat_ws("*", "binary+", c1, c3), concat_ws("*", "nchar+", c2, c4) from ctb4
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05 $data06
print ====> $data10 $data11 $data12 $data13 $data14 $data15 $data16
if $rows != 1 then
  return -1
endi
if $data02 != @ ab 12 * cd 34 @ then
  return -1
endi
if $data05 != @ ab 12 * cd 34 @ then
  return -1
endi
if $data06 != @binary+* ab 12 * cd 34 @ then
  return -1
endi
if $data07 != @nchar+* ab 12 * cd 34 @ then
  return -1
endi

print ====> select c1, c3, concat_ws("*", "b0", c1, "b1", c3, "b2", "E0", "E1", "E2"), c2, c4, concat_ws("*", "n0", c2, c4, "n1", c2, c4, "n2", "END") from ctb4
sql select c1, c3, concat_ws("*", "b0", c1, "b1", c3, "b2", "E0", "E1", "E2"), c2, c4, concat_ws("*", "n0", c2, c4, "n1", c2, c4, "n2", "END") from ctb4
print ====> rows: $rows
print ====> [ $data00 ] [ $data01 ] [ $data02 ] [ $data03 ] [ $data04 ] [ $data05 ] [ $data06 ]
print ====> $data10 $data11 $data12 $data13 $data14 $data15 $data16
if $rows != 1 then
  return -1
endi
if $data02 != @b0* ab 12 *b1* cd 34 *b2*E0*E1*E2@ then
  return -1
endi
if $data05 != @n0* ab 12 * cd 34 *n1* ab 12 * cd 34 *n2*END@ then
  return -1
endi

#sql_error select c1, c2, concat_ws("*", c1, c2), c3, c4, concat_ws("*", c3, c4) from ctb4
#sql_error select t1, t2, concat_ws("*", t1, t2), t3, t4, concat_ws("*", t3, t4) from ctb4
#sql_error select t1, t3, concat_ws("*", t1, t3), t2, t4, concat_ws("*", t2, t4) from ctb4


print ====> substr
#sql select c1, substr(c1, 3, 3), substr(c1, -5, 3), c2, substr(c2, 3, 3), substr(c2, -5, 3), substr("abcdefg", 3, 3), substr("abcdefg", -3, 3) from ntb5
#print ====> select c1, substr(c1, 3, 3), substr(c1, -5, 3), c2, substr(c2, 3, 3), substr(c2, -5, 3), substr("abcdefg", 3, 3), substr("abcdefg", -3, 3) from ctb5
#sql select c1, substr(c1, 3, 3), substr(c1, -5, 3), c2, substr(c2, 3, 3), substr(c2, -5, 3), substr("abcdefg", 3, 3), substr("abcdefg", -3, 3) from ctb5
#print ====> rows: $rows
#print ====> $data00 $data01 $data02 $data03 $data04 $data05 $data06
#print ====> $data10 $data11 $data12 $data13 $data14 $data15 $data16
#if $rows != 1 then
#  return -1
#endi
#if $data01 != 345 then
#  return -1
#endi
#if $data02 != 456 then
#  return -1
#endi
#if $data04 != 345 then
#  return -1
#endi
#if $data05 != 456 then
#  return -1
#endi
#if $data06 != def then
#  return -1
#endi
#if $data07 != efg then
#  return -1
#endi
#if $data11 != NULL then
#  return -1
#endi
#if $data12 != NULL then
#  return -1
#endi
#if $data14 != NULL then
#  return -1
#endi
#if $data15 != NULL then
#  return -1
#endi
#if $data16 != def then
#  return -1
#endi
#if $data17 != efg then
#  return -1
#endi
#
#sql select c1, substr(c1, 3), substr(c1, -5), c2, substr(c2, 3), substr(c2, -5), substr("abcdefg", 3), substr("abcdefg", -3) from ntb5
#print ====> select c1, substr(c1, 3), substr(c1, -5), c2, substr(c2, 3), substr(c2, -5), substr("abcdefg", 3), substr("abcdefg", -3) from ctb5
#sql select c1, substr(c1, 3), substr(c1, -5), c2, substr(c2, 3), substr(c2, -5), substr("abcdefg", 3), substr("abcdefg", -3) from ctb5
#print ====> rows: $rows
#print ====> $data00 $data01 $data02 $data03 $data04 $data05 $data06
#print ====> $data10 $data11 $data12 $data13 $data14 $data15 $data16
#if $rows != 1 then
#  return -1
#endi
#if $data01 != 3456789 then
#  return -1
#endi
#if $data02 != 456789 then
#  return -1
#endi
#if $data04 != 3456789 then
#  return -1
#endi
#if $data05 != 456789 then
#  return -1
#endi
#if $data06 != defg then
#  return -1
#endi
#if $data07 != efg then
#  return -1
#endi
#if $data11 != NULL then
#  return -1
#endi
#if $data12 != NULL then
#  return -1
#endi
#if $data14 != NULL then
#  return -1
#endi
#if $data15 != NULL then
#  return -1
#endi
#if $data16 != defg then
#  return -1
#endi
#if $data17 != efg then
#  return -1
#endi

#sql_error select t1, substr(t1, 3, 2), substr(t1, -3, 2), t2, substr(t2, 3, 2), substr(t2, -3, 2) from ctb5

if $loop_test == 0 then
  print =============== stop and restart taosd
  system sh/exec.sh -n dnode1 -s stop -x SIGINT
  system sh/exec.sh -n dnode1 -s start
C
cpwu 已提交
708

P
plum-lihui 已提交
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
  $loop_cnt = 0
  check_dnode_ready_0:
  	$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_0
  endi

C
cpwu 已提交
726
  $loop_test = 1
P
plum-lihui 已提交
727 728 729 730
  goto loop_test_pos
endi

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