mysqltest.test 29.2 KB
Newer Older
1 2 3 4 5

# ============================================================================
#
# Test of mysqltest itself
#
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# There are three rules that determines what belong to each command
# 1. A normal command is delimited by the <delimiter> which by default is
#    set to ';'
#
#   ex: | select *
#       |   from t1;
#       |
#   Command: "select * from t1"
#
# 2. Special case is a line that starts with "--", this is a comment
#    ended when the new line character is reached. But the first word
#    in the comment may contain a valid command, which then will be
#    executed. This can be useful when sending commands that
#    contains <delimiter>
#
# 3. Special case is also a line that starts with '#' which is treated
#     as a comment and will be ended by new line character
#
24 25
# ============================================================================

26 27 28 29 30 31 32 33 34
# ----------------------------------------------------------------------------
# $mysql_errno contains the return code of the last command
# send to the server.
# ----------------------------------------------------------------------------
# get $mysql_errno before the first statement
#     $mysql_errno should be -1
eval select $mysql_errno as "before_use_test" ;


35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
# ----------------------------------------------------------------------------
# Positive case(statement)
# ----------------------------------------------------------------------------

select otto from (select 1 as otto) as t1;
# expectation = response
--error 0
select otto from (select 1 as otto) as t1;

# expectation <> response
-- // --error 1054
-- // select otto from (select 1 as otto) as t1;


# ----------------------------------------------------------------------------
# Negative case(statement):
# The dervied table t1 does not contain a column named 'friedrich' . 
# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and
# --> 1054: Unknown column 'friedrich' in 'field list'
# ----------------------------------------------------------------------------

# expectation <> response
#--error 0
58 59 60
#select friedrich from (select 1 as otto) as t1
--error 1
--exec echo "select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST  2>&1
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

# expectation = response
--error 1054
select friedrich from (select 1 as otto) as t1;

# The following unmasked unsuccessful statement must give
# 1. mysqltest gives a 'failed'
# 2. does not produce a r/<test case>.reject file !!!
# PLEASE uncomment it and check it's effect
#select friedrich from (select 1 as otto) as t1;


# ----------------------------------------------------------------------------
# Tests for the new feature - SQLSTATE error code matching
# Positive case(statement)
# ----------------------------------------------------------------------------

78
# This syntax not allowed anymore, use --error S00000, see below
79
# expectation = response
80
#!S00000 select otto from (select 1 as otto) as t1;
81 82 83 84 85 86 87 88

--error S00000
select otto from (select 1 as otto) as t1;

# expectation <> response
#!S42S22 select otto from (select 1 as otto) as t1;
#--error S42S22
#select otto from (select 1 as otto) as t1;
89 90 91
--error 1
--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $MYSQL_TEST  2>&1

92 93 94 95 96 97


# ----------------------------------------------------------------------------
# Negative case(statement)
# ----------------------------------------------------------------------------

98
# This syntax not allowed anymore, use --error S42S22, see below
99
# expectation = response
100
#!S42S22 select friedrich from (select 1 as otto) as t1;
101 102 103 104 105 106 107
--error S42S22
select friedrich from (select 1 as otto) as t1;

# expectation !=response
#!S00000 select friedrich from (select 1 as otto) as t1;
#--error S00000
#select friedrich from (select 1 as otto) as t1;
108 109
--error 1
--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST  2>&1
110 111 112 113 114 115 116 117 118

# ----------------------------------------------------------------------------
# test cases for $mysql_errno
#
# $mysql_errno is a builtin variable of mysqltest and contains the return code
# of the last command send to the server.
#
#      The following test cases often initialize $mysql_errno to 1064 by 
#      a command with wrong syntax.
119
#      Example: --error 1064      To prevent the abort after the error.
120 121 122 123
#               garbage ;
# ----------------------------------------------------------------------------

# ----------------------------------------------------------------------------
124
# check mysql_errno = 0 after successful statement
125 126 127 128 129
# ----------------------------------------------------------------------------
select otto from (select 1 as otto) as t1;
eval select $mysql_errno as "after_successful_stmt_errno" ;

#----------------------------------------------------------------------------
130
# check mysql_errno = 1064 after statement with wrong syntax
131
# ----------------------------------------------------------------------------
132
--error 1064
133 134 135 136
garbage ;
eval select $mysql_errno as "after_wrong_syntax_errno" ;

# ----------------------------------------------------------------------------
137
# check if let $my_var= 'abc' ; affects $mysql_errno
138
# ----------------------------------------------------------------------------
139
--error 1064
140 141 142 143 144
garbage ;
let $my_var= 'abc' ;
eval select $mysql_errno as "after_let_var_equal_value" ;

# ----------------------------------------------------------------------------
145
# check if set @my_var= 'abc' ; affects $mysql_errno
146
# ----------------------------------------------------------------------------
147
--error 1064
148 149 150 151 152
garbage ;
set @my_var= 'abc' ;
eval select $mysql_errno as "after_set_var_equal_value" ;

# ----------------------------------------------------------------------------
153 154
#  check if the setting of --disable-warnings itself affects $mysql_errno
#  (May be --<whatever> modifies $mysql_errno.)
155
# ----------------------------------------------------------------------------
156
--error 1064
157 158 159 160 161
garbage ;
--disable_warnings
eval select $mysql_errno as "after_disable_warnings_command" ;

# ----------------------------------------------------------------------------
162 163 164
# check if --disable-warnings + command with warning affects the errno
# stored within $mysql_errno
# (May be disabled warnings affect $mysql_errno.)
165 166
# ----------------------------------------------------------------------------
drop table if exists t1 ;
167
--error 1064
168 169 170 171 172 173
garbage ;
drop table if exists t1 ;
eval select $mysql_errno as "after_disable_warnings" ;
--enable_warnings

# ----------------------------------------------------------------------------
174
# check if masked errors affect $mysql_errno
175
# ----------------------------------------------------------------------------
176
--error 1064
177 178 179 180
garbage ;
--error 1146
select 3 from t1 ;
eval select $mysql_errno as "after_minus_masked" ;
181
--error 1064
182
garbage ;
183
--error 1146
184 185 186 187
select 3 from t1 ;
eval select $mysql_errno as "after_!_masked" ;

# ----------------------------------------------------------------------------
188
# Will manipulations of $mysql_errno be possible and visible ?
189
# ----------------------------------------------------------------------------
190
--error 1064
191 192 193 194 195
garbage ;
let $mysql_errno= -1;
eval select $mysql_errno as "after_let_errno_equal_value" ;

# ----------------------------------------------------------------------------
196
# How affect actions on prepared statements $mysql_errno ?
197 198
# ----------------------------------------------------------------------------
# failing prepare
199
--error 1064
200
garbage ;
201
--error 1146
202 203 204 205 206
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_failing_prepare" ;
create table t1 ( f1 char(10));

# successful prepare
207
--error 1064
208 209 210 211 212
garbage ;
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_successful_prepare" ;

# successful execute
213
--error 1064
214 215 216 217 218 219
garbage ;
execute stmt;
eval select $mysql_errno as "after_successful_execute" ;

# failing execute (table dropped)
drop table t1;
220
--error 1064
221
garbage ;
222
--error 1146
223 224 225 226
execute stmt;
eval select $mysql_errno as "after_failing_execute" ;

# failing execute (unknown statement)
227
--error 1064
228
garbage ;
229
--error 1243
230 231 232 233
execute __stmt_;
eval select $mysql_errno as "after_failing_execute" ;

# successful deallocate
234
--error 1064
235 236 237 238 239
garbage ;
deallocate prepare stmt;
eval select $mysql_errno as "after_successful_deallocate" ;

# failing deallocate ( statement handle does not exist )
240
--error 1064
241
garbage ;
242
--error 1243
243 244 245 246 247 248 249 250 251 252 253 254 255
deallocate prepare __stmt_;
eval select $mysql_errno as "after_failing_deallocate" ;


# ----------------------------------------------------------------------------
# test cases for "--disable_abort_on_error"
#
# "--disable_abort_on_error" switches the abort of mysqltest
# after "unmasked" failing statements off.
#
# The default is "--enable_abort_on_error".
#
# "Maskings" are
256
#   --error <error number>  and  --error <error number>
257 258 259 260 261 262 263 264
# in the line before the failing statement.
#
# There are some additional test case for $mysql_errno
# because "--disable_abort_on_error" enables a new situation.
# Example: "unmasked" statement fails + analysis of $mysql_errno
# ----------------------------------------------------------------------------

# ----------------------------------------------------------------------------
265
# Switch the abort on error off and check the effect on $mysql_errno
266
# ----------------------------------------------------------------------------
267
--error 1064
268 269 270 271 272
garbage ;
--disable_abort_on_error
eval select $mysql_errno as "after_--disable_abort_on_error" ;

# ----------------------------------------------------------------------------
273
# "unmasked" failing statement should not cause an abort
274 275 276 277
# ----------------------------------------------------------------------------
select 3 from t1 ;

# ----------------------------------------------------------------------------
278
# masked failing statements
279 280 281 282
# ----------------------------------------------------------------------------
# expected error = response
--error 1146
select 3 from t1 ;
283
--error 1146
284 285 286 287 288
select 3 from t1 ;
eval select $mysql_errno as "after_!errno_masked_error" ;
# expected error <> response
# --error 1000
# select 3 from t1 ;
289
# --error 1000
290
# select 3 from t1 ;
291 292
--error 1
--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $MYSQL_TEST  2>&1
293 294

# ----------------------------------------------------------------------------
295
# Switch the abort on error on and check the effect on $mysql_errno
296
# ----------------------------------------------------------------------------
297
--error 1064
298 299 300 301 302
garbage ;
--enable_abort_on_error
eval select $mysql_errno as "after_--enable_abort_on_error" ;

# ----------------------------------------------------------------------------
303
# masked failing statements
304 305 306 307 308 309
# ----------------------------------------------------------------------------
# expected error = response
--error 1146
select 3 from t1 ;

# ----------------------------------------------------------------------------
310
# check that the old default behaviour is not changed
311 312 313 314 315 316
# Please remove the '#' to get the abort on error
# ----------------------------------------------------------------------------
#--error 1064
#select 3 from t1 ;
#
#select 3 from t1 ;
317

318
# End of 4.1 tests
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
--error 1
--exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST  2>&1


# ----------------------------------------------------------------------------
# Test comments
# ----------------------------------------------------------------------------

# This is a comment
# This is a ;  comment
# This is a -- comment
-- This is also a comment
-- # This is also a comment
-- This is also a ; comment

# ----------------------------------------------------------------------------
# Test comments with embedded command
# ----------------------------------------------------------------------------

--echo hello
--     echo hello
--    echo ;;;;;;;;

--echo # MySQL: -- The

# ----------------------------------------------------------------------------
# Test detect end of line "junk"
# Most likely causes by a missing delimiter
# ----------------------------------------------------------------------------

# Too many parameters to function
--error 1
--exec echo "sleep 5 6;" | $MYSQL_TEST 2>&1

# Too many parameters to function
--error 1
--exec echo "--sleep 5 6" | $MYSQL_TEST 2>&1

#
# Missing delimiter
# The comment will be "sucked into" the sleep command since
# delimiter is missing until after "show status"
361 362 363
--system echo "sleep 4" > var/tmp/mysqltest.sql
--system echo "# A comment" >> var/tmp/mysqltest.sql
--system echo "show status;" >> var/tmp/mysqltest.sql
364
--error 1
365
--exec $MYSQL_TEST < var/tmp/mysqltest.sql 2>&1
366 367 368 369 370 371

#
# Extra delimiter
#
--error 1
--exec echo "--sleep 4;" | $MYSQL_TEST 2>&1
372 373
--error 1
--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1
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


# Allow trailing # comment
--sleep 1 # Wait for insert delayed to be executed.
--sleep 1 	 # Wait for insert delayed to be executed.


# ----------------------------------------------------------------------------
# Test echo command
# ----------------------------------------------------------------------------

echo MySQL;
echo "MySQL";
echo MySQL: The world''s most popular open source database;
echo "MySQL: The world's most popular open source database";

echo MySQL: The world''s
     most popular open
     source database;

echo # MySQL: The world''s
# most popular open
# source database;

echo - MySQL: The world''s
- most popular open
- source database;

echo - MySQL: The world''s
-- most popular open
-- source database;

echo # MySQL: The
--world''s
# most popular
-- open
- source database;

echo "MySQL: The world's most popular; open source database";
echo "MySQL: The world's most popular ; open source database";
echo "MySQL: The world's most popular ;open source database";
echo echo message echo message;


echo ;

# Illegal use of echo

--error 1
--exec echo "echo $;" | $MYSQL_TEST 2>&1


# ----------------------------------------------------------------------------
# Test exec command
# ----------------------------------------------------------------------------

# Illegal use of exec
431 432
--error 1
--exec echo "--exec false" | $MYSQL_TEST 2>&1
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

--error 1
--exec echo "--exec " | $MYSQL_TEST 2>&1

# ----------------------------------------------------------------------------
# Test let command
# ----------------------------------------------------------------------------

let $message=MySQL;
echo $message;

let $message="MySQL";
echo $message;

let $message= MySQL: The
 world''s most
 popular open
 source database;
echo $message;

let $message= # MySQL: The
# world''s most
# popular open
# source database;
echo $message;

let $message=  -- MySQL: The
-- world''s most
-- popular open
-- source database;
echo $message;

let $message=  # MySQL: The
- world''s most
-- popular open
# source database;
echo $message;

echo '$message';
echo "$message";

let $1=hej;
echo $1;

let   $1   =hej ;
echo $1;

let $1 = hej;
echo $1;

483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
let $1=1;
let $2=$1;
echo $2;
let $5=$6;
echo $5;
echo $6;

let $where=a long variable content;
echo $where;

let $where2= $where;
echo $where2;

let $where3=a long $where variable content;
echo $where3;

let $novar1= $novar2;
echo $novar1;


503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 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

# Test illegal uses of let

--error 1
--exec echo "let ;" | $MYSQL_TEST 2>&1

--error 1
--exec echo "let $=hi;" | $MYSQL_TEST  2>&1

--error 1
--exec echo "let hi=hi;" | $MYSQL_TEST  2>&1

--error 1
--exec echo "let $1 hi;" | $MYSQL_TEST  2>&1

--error 1
--exec echo "let $m hi;" | $MYSQL_TEST  2>&1

--error 1
--exec echo "let $hi;" | $MYSQL_TEST  2>&1

--error 1
--exec echo "let $ hi;" | $MYSQL_TEST  2>&1

--error 1
--exec echo "let =hi;" | $MYSQL_TEST  2>&1

--error 1
--exec echo "let hi;" | $MYSQL_TEST  2>&1

# ----------------------------------------------------------------------------
# Test source command
# ----------------------------------------------------------------------------

# Test illegal uses of source

--error 1
--exec echo "source ;" | $MYSQL_TEST 2>&1

--error 1
--exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1

# Too many source
--exec echo "source var/tmp/recursive.sql;" > var/tmp/recursive.sql
--error 1
--exec echo "source var/tmp/recursive.sql;" | $MYSQL_TEST 2>&1

# Source a file with error
--exec echo "garbage ;" > var/tmp/error.sql
--error 1
--exec echo "source var/tmp/error.sql;" | $MYSQL_TEST 2>&1


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
# Test execution of source in a while loop
--exec echo "echo here is the sourced script;" > var/tmp/sourced.sql
--disable_query_log
let $outer= 2; # Number of outer loops
while ($outer)
{
  eval SELECT '$outer = outer loop variable after while' AS "";

  --source var/tmp/sourced.sql

  eval SELECT '$outer = outer loop variable before dec' AS "";
  dec $outer;
  eval SELECT '$outer = outer loop variable after dec' AS "";
}

let $outer= 2; # Number of outer loops
while ($outer)
{
  eval SELECT '$outer = outer loop variable after while' AS "";

  echo here is the sourced script;

  eval SELECT '$outer = outer loop variable before dec' AS "";
  dec $outer;
  eval SELECT '$outer = outer loop variable after dec' AS "";
}


# Test execution of source in a while loop
--exec echo "--source var/tmp/sourced.sql" > var/tmp/sourced1.sql
--disable_abort_on_error
# Sourcing of a file within while loop, sourced file will
# source other file
let $num= 9;
while ($num)
{
   SELECT 'In loop' AS "";
   --source var/tmp/sourced1.sql
   dec $num;
}
596
--enable_abort_on_error
597 598
--enable_query_log

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
# ----------------------------------------------------------------------------
# Test sleep command
# ----------------------------------------------------------------------------

sleep 0.5;
sleep 1;
real_sleep 1;

# Missing parameter
--error 1
--exec echo "sleep ;" | $MYSQL_TEST 2>&1

# Illegal parameter
--error 1
--exec echo "sleep abc;" | $MYSQL_TEST 2>&1

# ----------------------------------------------------------------------------
# Test inc
# ----------------------------------------------------------------------------
inc $i;
echo $i;
inc $i;
echo $i;
let $i=100;
inc $i;
echo $i;

let $i=hej;
echo $i;
inc $i;
echo $i;

--error 1
--exec echo "inc;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "inc i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1

inc $i; inc $i; inc $i; --echo $i
echo $i;


# ----------------------------------------------------------------------------
# Test dec
# ----------------------------------------------------------------------------

dec $d;
echo $d;
dec $d;
echo $d;
let $d=100;
dec $d;
echo $d;

let $d=hej;
echo $d;
dec $d;
echo $d;

--error 1
--exec echo "dec;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "dec i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1


# ----------------------------------------------------------------------------
# Test system
# ----------------------------------------------------------------------------
system ls > /dev/null;
system echo "hej" > /dev/null;
--system ls > /dev/null
--system echo "hej" > /dev/null;

--error 1
--exec echo "system;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1
679 680
--error 1
--exec echo "system false;" | $MYSQL_TEST 2>&1
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 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729

--disable_abort_on_error
system NonExistsinfComamdn;
--enable_abort_on_error


# ----------------------------------------------------------------------------
# Test delimiter
# ----------------------------------------------------------------------------

delimiter stop;
echo teststop
delimiter ;stop
echo test2;
--delimiter stop
echo test3stop
--delimiter ;
echo test4;

# ----------------------------------------------------------------------------
# Test while, { and }
# ----------------------------------------------------------------------------

let $i=1;
while ($i)
{
  echo $i;
  dec $i;
}
# One liner
#let $i=1;while ($i){echo $i;dec $i;}



# Exceed max nesting level
--error 1
--exec echo "source include/mysqltest_while.inc;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "while \$i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "while (\$i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "let \$i=1; while (\$i) dec \$i;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "};" | $MYSQL_TEST 2>&1
--error 1
--exec echo "end;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "{;" | $MYSQL_TEST 2>&1
730 731 732

--system echo "while (0)" > var/log/mysqltest.sql
--system echo "echo hej;" >> var/log/mysqltest.sql
733
--error 1
734 735 736 737
--exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1

--system echo "while (0)" > var/log/mysqltest.sql
--system echo "{echo hej;" >> var/log/mysqltest.sql
738
--error 1
739 740 741 742
--exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1

--system echo "while (0){" > var/log/mysqltest.sql
--system echo "echo hej;" >> var/log/mysqltest.sql
743
--error 1
744
--exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
745

746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808
# ----------------------------------------------------------------------------
# Test error messages returned from comments starting with a command
# ----------------------------------------------------------------------------
--error 1
--exec echo "--if the other server is down" | $MYSQL_TEST 2>&1

--error 1
--exec echo "-- end when ..." | $MYSQL_TEST 2>&1

# ----------------------------------------------------------------------------
# Test replace
# ----------------------------------------------------------------------------
--replace_result a b
select "a" as col1, "c" as col2;

--replace_result a b c d
select "a" as col1, "c" as col2;

--error 1
--exec echo "--replace_result a" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--replace_result a;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_result a;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_result a ;" | $MYSQL_TEST 2>&1
--exec echo "replace_result a b;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_result a b c ;" | $MYSQL_TEST 2>&1


--replace_column 1 b
select "a" as col1, "c" as col2;

--replace_column 1 b 2 d
select "a" as col1, "c" as col2;

--error 1
--exec echo "--replace_column a" | $MYSQL_TEST 2>&1

--error 1
--exec echo "--replace_column 1" | $MYSQL_TEST 2>&1

--error 1
--exec echo "--replace_column a b" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--replace_column a 1" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--replace_column 1 b c " | $MYSQL_TEST 2>&1


# ----------------------------------------------------------------------------
# Test sync_with_master
# ----------------------------------------------------------------------------
--error 1
--exec echo "save_master_pos; sync_with_master 10!;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "save_master_pos; sync_with_master 10 !;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "save_master_pos; sync_with_master a;" | $MYSQL_TEST 2>&1

809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868
# ----------------------------------------------------------------------------
# Test connect
# ----------------------------------------------------------------------------

--error 1
--exec echo "connect;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect ();" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2,);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2,localhost);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2, localhost, root);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2,  localhost, root,);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con2,localhost,root,,illegal_db);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $MYSQL_TEST 2>&1
--error 1
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1

# Repeat connect/disconnect
--exec echo "let \$i=100;"                              > var/tmp/con.sql
--exec echo "while (\$i)"                              >> var/tmp/con.sql
--exec echo "{"                                        >> var/tmp/con.sql
--exec echo " connect (test_con1,localhost,root,,); "  >> var/tmp/con.sql
--exec echo " disconnect test_con1; "                  >> var/tmp/con.sql
--exec echo " dec \$i;                               " >> var/tmp/con.sql
--exec echo "}"                                        >> var/tmp/con.sql
--exec echo "source var/tmp/con.sql;" | $MYSQL_TEST 2>&1

# Repeat connect/disconnect, exceed max number of connections
--exec echo "let \$i=200;"                              > var/tmp/con.sql
--exec echo "while (\$i)"                              >> var/tmp/con.sql
--exec echo "{"                                        >> var/tmp/con.sql
--exec echo " connect (test_con1,localhost,root,,); "  >> var/tmp/con.sql
--exec echo " disconnect test_con1; "                  >> var/tmp/con.sql
--exec echo " dec \$i;                               " >> var/tmp/con.sql
--exec echo "}"                                        >> var/tmp/con.sql
--error 1
--exec echo "source var/tmp/con.sql;" | $MYSQL_TEST 2>&1

# Select disconnected connection
--exec echo "connect (test_con1,localhost,root,,);"    > var/tmp/con.sql
--exec echo "disconnect test_con1; "                  >> var/tmp/con.sql
--exec echo "connection test_con1;"                   >> var/tmp/con.sql
--error 1
--exec echo "source var/tmp/con.sql;" | $MYSQL_TEST 2>&1

# Connection name already used
--exec echo "connect (test_con1,localhost,root,,);"    > var/tmp/con.sql
--exec echo "connect (test_con1,localhost,root,,);"   >> var/tmp/con.sql
--error 1
--exec echo "source var/tmp/con.sql;" | $MYSQL_TEST 2>&1


869 870 871 872 873 874

# ----------------------------------------------------------------------------
# Test mysqltest arguments
# ----------------------------------------------------------------------------

# -x <file_name>, use the file specified after -x as the test file
875 876 877 878 879
--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc
--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc
--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc
--error 1
--exec $MYSQL_TEST -x non_existing_file.inc 2>&1
880 881


882 883 884 885 886
# ----------------------------------------------------------------------------
# TODO Test queries, especially their errormessages... so it's easy to debug 
# new scripts and diagnose errors
# ----------------------------------------------------------------------------

887 888 889 890 891 892 893 894 895 896 897 898 899
# ----------------------------------------------------------------------------
# Test bug#12386
# ----------------------------------------------------------------------------
let $num= 2;
while ($num)
{
   --error 1064
   failing_statement;

   dec $num;
}

SELECT 1 as a;
900 901 902 903 904 905 906 907 908


#
# Bug #10251: Identifiers containing quotes not handled correctly
#
select 1 as `a'b`, 2 as `a"b`;

# Test escaping of quotes
select 'aaa\\','aa''a',"aa""a";
909 910

#
911
# Check of include/show_msg.inc and include/show_msg80.inc
912 913 914
#

# The message contains in most cases a string with the default character set
915
let $message= Here comes a message;
916 917 918
--source include/show_msg.inc

# The message could also contain a string with character set utf8
919
let $message= `SELECT USER()`;
920 921 922
--source include/show_msg.inc

# The message contains more then 80 characters on multiple lines
mleich@mysql.com's avatar
mleich@mysql.com committed
923
# and is kept between double quotes.
924 925 926 927
let $message= 
"Here comes a very very long message that
    - is longer then 80 characters    and
    - consists of several lines";
928 929
--source include/show_msg80.inc

mleich@mysql.com's avatar
mleich@mysql.com committed
930 931 932 933 934 935 936
# The message contains more then 80 characters on multiple lines
# and uses the auxiliary character "." at the beginning of the message lines.
let $message= . Here comes a very very long message that
              .      - is longer then 80 characters    and
              .      - consists of several lines;
--source include/show_msg80.inc

937 938 939 940 941 942 943 944 945 946 947
#
# Test --enable_parsning / disable_parsning
#
--disable_query_log
--disable_parsing
# The following will not enable query logging
--enable_query_log
select "this will not be executed";
--enable_parsing
select "this will be executed";
--enable_query_log
948 949 950 951 952 953 954 955


#
# Bug #11731 mysqltest in multi-statement queries ignores errors in
#            non-1st queries
#

# Failing multi statement query
956 957 958
# PS does not support multi statement
--exec echo "--disable_ps_protocol"                    > var/tmp/bug11731.sql
--exec echo "delimiter ||||;"                         >> var/tmp/bug11731.sql
959 960 961 962 963 964 965 966 967 968 969 970
--exec echo "create table t1 (a int primary key);"    >> var/tmp/bug11731.sql
--exec echo "insert into t1 values (1);"              >> var/tmp/bug11731.sql
--exec echo "select 'select-me';"                     >> var/tmp/bug11731.sql
--exec echo "insertz 'error query'||||"               >> var/tmp/bug11731.sql
--exec echo "delimiter ;||||"                         >> var/tmp/bug11731.sql

--error 1
--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql 2>&1
drop table t1;

--error 1
--exec $MYSQL_TEST --record -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql -R $MYSQL_TEST_DIR/var/tmp/bug11731.out
971
# The .out file should be empty
972
--error 1
973
--exec test -s $MYSQL_TEST_DIR/var/tmp/bug11731.out
974 975 976 977
drop table t1;


# Using expected error
978 979 980
# PS does not support multi statement
--exec echo "--disable_ps_protocol"                    > var/tmp/bug11731.sql
--exec echo "delimiter ||||;"                         >> var/tmp/bug11731.sql
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997
--exec echo "--error 1064"                            >> var/tmp/bug11731.sql
--exec echo "create table t1 (a int primary key);"    >> var/tmp/bug11731.sql
--exec echo "insert into t1 values (1);"              >> var/tmp/bug11731.sql
--exec echo "select 'select-me';"                     >> var/tmp/bug11731.sql
--exec echo "insertz "error query"||||"               >> var/tmp/bug11731.sql
--exec echo "delimiter ;||||"                         >> var/tmp/bug11731.sql

# These two should work since the error is expected
--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql  2>&1
drop table t1;

--exec $MYSQL_TEST --record -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql -R $MYSQL_TEST_DIR/var/tmp/bug11731.out
--exec cat $MYSQL_TEST_DIR/var/tmp/bug11731.out
drop table t1;