/mysql-test/t/mysqltest.test
Unknown | 2939 lines | 2445 code | 494 blank | 0 comment | 0 complexity | 101d155ce8b33bb2ddbd458ab7f76fdb MD5 | raw file
Large files files are truncated, but you can click here to view the full file
1# ---------------------------------------------------------------------------- 2# $mysql_errno contains the return code of the last command 3# sent to the server. 4# ---------------------------------------------------------------------------- 5# get $mysql_errno before the first statement 6# $mysql_errno should be -1 7# get $mysql_errname as well 8 9echo $mysql_errno before test; 10echo $mysql_errname before test; 11 12-- source include/have_log_bin.inc 13 14# This test should work in embedded server after mysqltest is fixed 15-- source include/not_embedded.inc 16 17# This test uses chmod, can't be run with root permissions 18-- source include/not_as_root.inc 19 20# Save the initial number of concurrent sessions 21--source include/count_sessions.inc 22 23# ============================================================================ 24# 25# Test of mysqltest itself 26# 27# There are three rules that determines what belong to each command 28# 1. A normal command is delimited by the <delimiter> which by default is 29# set to ';' 30# 31# ex: | select * 32# | from t1; 33# | 34# Command: "select * from t1" 35# 36# 2. Special case is a line that starts with "--", this is a comment 37# ended when the new line character is reached. But the first word 38# in the comment may contain a valid command, which then will be 39# executed. This can be useful when sending commands that 40# contains <delimiter> 41# 42# 3. Special case is also a line that starts with '#' which is treated 43# as a comment and will be ended by new line character 44# 45# ============================================================================ 46 47# ---------------------------------------------------------------------------- 48# Positive case(statement) 49# ---------------------------------------------------------------------------- 50 51select otto from (select 1 as otto) as t1; 52# expectation = response 53--error 0 54select otto from (select 1 as otto) as t1; 55 56# ---------------------------------------------------------------------------- 57# Negative case(statement): 58# The derived table t1 does not contain a column named 'friedrich' . 59# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and 60# --> 1054: Unknown column 'friedrich' in 'field list' 61# ---------------------------------------------------------------------------- 62 63# expectation <> response 64#--error 0 65#select friedrich from (select 1 as otto) as t1 66--error 1 67--exec echo "select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1 68 69# expectation = response 70--error ER_BAD_FIELD_ERROR 71 72select friedrich from (select 1 as otto) as t1; 73 74# The following unmasked unsuccessful statement must give 75# 1. mysqltest gives a 'failed' 76# 2. does not produce a r/<test case>.reject file !!! 77# PLEASE uncomment it and check its effect 78#select friedrich from (select 1 as otto) as t1; 79 80 81# ---------------------------------------------------------------------------- 82# Tests for the new feature - SQLSTATE error code matching 83# Positive case(statement) 84# ---------------------------------------------------------------------------- 85 86# This syntax not allowed anymore, use --error S00000, see below 87# expectation = response 88#!S00000 select otto from (select 1 as otto) as t1; 89 90--error S00000 91select otto from (select 1 as otto) as t1; 92 93# expectation <> response 94#!S42S22 select otto from (select 1 as otto) as t1; 95#--error S42S22 96#select otto from (select 1 as otto) as t1; 97--error 1 98--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1 99 100# expecting a SQL-state for a command that can't give one should fail 101--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 102--error 1 103--exec echo "error S00000; remove_file $MYSQLTEST_VARDIR/tmp/test_nonexistent.tmp;" | $MYSQL_TEST 2>&1 104 105 106# ---------------------------------------------------------------------------- 107# Negative case(statement) 108# ---------------------------------------------------------------------------- 109 110# This syntax not allowed anymore, use --error S42S22, see below 111# expectation = response 112#!S42S22 select friedrich from (select 1 as otto) as t1; 113--error S42S22 114select friedrich from (select 1 as otto) as t1; 115 116# expectation !=response 117#!S00000 select friedrich from (select 1 as otto) as t1; 118#--error S00000 119#select friedrich from (select 1 as otto) as t1; 120--error 1 121--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1 122 123# ---------------------------------------------------------------------------- 124# test cases for $mysql_errno 125# 126# $mysql_errno is a builtin variable of mysqltest and contains the return code 127# of the last command sent to the server. 128# 129# The following test cases often initialize $mysql_errno to 1064 by 130# a command with wrong syntax. 131# Example: --error 1064 To prevent the abort after the error. 132# garbage ; 133# ---------------------------------------------------------------------------- 134 135# ---------------------------------------------------------------------------- 136# check mysql_errno = 0 after successful statement 137# ---------------------------------------------------------------------------- 138select otto from (select 1 as otto) as t1; 139echo $mysql_errname; 140eval select $mysql_errno as "after_successful_stmt_errno" ; 141 142#---------------------------------------------------------------------------- 143# check mysql_errno = 1064 after statement with wrong syntax 144# ---------------------------------------------------------------------------- 145--error ER_PARSE_ERROR 146 147garbage ; 148echo $mysql_errname; 149eval select $mysql_errno as "after_wrong_syntax_errno" ; 150 151# ---------------------------------------------------------------------------- 152# check if let $my_var= 'abc' ; affects $mysql_errno 153# ---------------------------------------------------------------------------- 154--error ER_PARSE_ERROR 155 156garbage ; 157let $my_var= 'abc' ; 158echo $mysql_errname; 159eval select $mysql_errno as "after_let_var_equal_value" ; 160 161# ---------------------------------------------------------------------------- 162# check if set @my_var= 'abc' ; affects $mysql_errno 163# ---------------------------------------------------------------------------- 164--error ER_PARSE_ERROR 165 166garbage ; 167set @my_var= 'abc' ; 168echo $mysql_errname; 169eval select $mysql_errno as "after_set_var_equal_value" ; 170 171# ---------------------------------------------------------------------------- 172# check if the setting of --disable-warnings itself affects $mysql_errno 173# (May be --<whatever> modifies $mysql_errno.) 174# ---------------------------------------------------------------------------- 175--error ER_PARSE_ERROR 176 177garbage ; 178--disable_warnings 179echo $mysql_errname; 180eval select $mysql_errno as "after_disable_warnings_command" ; 181 182# ---------------------------------------------------------------------------- 183# check if --disable-warnings + command with warning affects the errno 184# stored within $mysql_errno 185# (May be disabled warnings affect $mysql_errno.) 186# ---------------------------------------------------------------------------- 187drop table if exists t1 ; 188--error ER_PARSE_ERROR 189 190garbage ; 191drop table if exists t1 ; 192echo $mysql_errname; 193eval select $mysql_errno as "after_disable_warnings" ; 194--enable_warnings 195 196# ---------------------------------------------------------------------------- 197# check if masked errors affect $mysql_errno 198# ---------------------------------------------------------------------------- 199--error ER_PARSE_ERROR 200 201garbage ; 202--error ER_NO_SUCH_TABLE 203 204select 3 from t1 ; 205echo $mysql_errname; 206eval select $mysql_errno as "after_minus_masked" ; 207--error ER_PARSE_ERROR 208 209garbage ; 210--error ER_NO_SUCH_TABLE 211 212select 3 from t1 ; 213echo $mysql_errname; 214eval select $mysql_errno as "after_!_masked" ; 215 216# ---------------------------------------------------------------------------- 217# Will manipulations of $mysql_errno be possible and visible ? 218# ---------------------------------------------------------------------------- 219--error ER_PARSE_ERROR 220 221garbage ; 222let $mysql_errno= -1; 223eval select $mysql_errno as "after_let_errno_equal_value" ; 224 225# ---------------------------------------------------------------------------- 226# How affect actions on prepared statements $mysql_errno ? 227# ---------------------------------------------------------------------------- 228# failing prepare 229--error ER_PARSE_ERROR 230 231garbage ; 232--error ER_NO_SUCH_TABLE 233 234prepare stmt from "select 3 from t1" ; 235echo $mysql_errname; 236eval select $mysql_errno as "after_failing_prepare" ; 237create table t1 ( f1 char(10)); 238 239# successful prepare 240--error ER_PARSE_ERROR 241 242garbage ; 243prepare stmt from "select 3 from t1" ; 244echo $mysql_errname; 245eval select $mysql_errno as "after_successful_prepare" ; 246 247# successful execute 248--error ER_PARSE_ERROR 249 250garbage ; 251execute stmt; 252echo $mysql_errname; 253eval select $mysql_errno as "after_successful_execute" ; 254 255# failing execute (table has been dropped) 256drop table t1; 257--error ER_PARSE_ERROR 258 259garbage ; 260--error ER_NO_SUCH_TABLE 261 262execute stmt; 263echo $mysql_errname; 264eval select $mysql_errno as "after_failing_execute" ; 265 266# failing execute (unknown statement) 267--error ER_PARSE_ERROR 268 269garbage ; 270--error ER_UNKNOWN_STMT_HANDLER 271 272execute __stmt_; 273echo $mysql_errname; 274eval select $mysql_errno as "after_failing_execute" ; 275 276# successful deallocate 277--error ER_PARSE_ERROR 278 279garbage ; 280deallocate prepare stmt; 281echo $mysql_errname; 282eval select $mysql_errno as "after_successful_deallocate" ; 283 284# failing deallocate ( statement handle does not exist ) 285--error ER_PARSE_ERROR 286 287garbage ; 288--error ER_UNKNOWN_STMT_HANDLER 289 290deallocate prepare __stmt_; 291echo $mysql_errname; 292eval select $mysql_errno as "after_failing_deallocate" ; 293 294 295# ---------------------------------------------------------------------------- 296# test cases for "--disable_abort_on_error" 297# 298# "--disable_abort_on_error" switches off the abort of mysqltest 299# after "unmasked" failing statements. 300# 301# The default is "--enable_abort_on_error". 302# 303# "Maskings" are 304# --error <error number> and --error <error number> 305# in the line before the failing statement. 306# 307# There are some additional test cases for $mysql_errno 308# because "--disable_abort_on_error" enables a new situation. 309# Example: "unmasked" statement fails + analysis of $mysql_errno 310# ---------------------------------------------------------------------------- 311 312# ---------------------------------------------------------------------------- 313# Switch off the abort on error and check the effect on $mysql_errno 314# ---------------------------------------------------------------------------- 315--error ER_PARSE_ERROR 316 317garbage ; 318--disable_abort_on_error 319echo $mysql_errname; 320eval select $mysql_errno as "after_--disable_abort_on_error" ; 321 322# ---------------------------------------------------------------------------- 323# "unmasked" failing statement should not cause an abort 324# ---------------------------------------------------------------------------- 325select 3 from t1 ; 326 327# ---------------------------------------------------------------------------- 328# masked failing statements 329# ---------------------------------------------------------------------------- 330# expected error = response 331--error ER_NO_SUCH_TABLE 332 333select 3 from t1 ; 334--error ER_NO_SUCH_TABLE 335 336select 3 from t1 ; 337echo $mysql_errname; 338eval select $mysql_errno as "after_!errno_masked_error" ; 339# expected error <> response 340# --error 1000 341# select 3 from t1 ; 342# --error 1000 343# select 3 from t1 ; 344--error 1 345--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $MYSQL_TEST 2>&1 346 347# ---------------------------------------------------------------------------- 348# Check some non-query statements that would fail 349# ---------------------------------------------------------------------------- 350--exec illegal_command 351--cat_file does_not_exist 352--perl 353 exit(2); 354EOF 355 356# ---------------------------------------------------------------------------- 357# Check backtick and query_get_value, result should be empty 358# ---------------------------------------------------------------------------- 359let $empty= `garbage`; 360echo $empty is empty; 361let $empty= query_get_value(nonsense, blabla, 1); 362echo $empty is empty; 363 364# ---------------------------------------------------------------------------- 365# Switch the abort on error on and check the effect on $mysql_errno 366# ---------------------------------------------------------------------------- 367--error ER_PARSE_ERROR 368 369garbage ; 370--enable_abort_on_error 371echo $mysql_errname; 372eval select $mysql_errno as "after_--enable_abort_on_error" ; 373 374# ---------------------------------------------------------------------------- 375# masked failing statements 376# ---------------------------------------------------------------------------- 377# expected error = response 378--error ER_NO_SUCH_TABLE 379 380select 3 from t1 ; 381 382# ---------------------------------------------------------------------------- 383# check that the old default behaviour is not changed 384# Please remove the '#' to get the abort on error 385# ---------------------------------------------------------------------------- 386#--error 1064 387#select 3 from t1 ; 388# 389#select 3 from t1 ; 390 391--error 1 392--exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1 393 394# ---------------------------------------------------------------------------- 395# Test --enable and --disable with ONCE 396# ---------------------------------------------------------------------------- 397 398--disable_abort_on_error ONCE 399garbage; 400--disable_abort_on_error ONCE 401--remove_file DoesNotExist 402 403--disable_result_log 404select 2; 405--enable_result_log ONCE 406select 3; 407select 5; 408--enable_result_log 409 410# ---------------------------------------------------------------------------- 411# Test cumulative ONCE 412# ---------------------------------------------------------------------------- 413 414--disable_abort_on_error ONCE 415--disable_query_log ONCE 416select 3 from t1; 417select 7; 418 419--error 1 420--exec echo "--disable_info OCNE" | $MYSQL_TEST 2>&1 421 422--enable_connect_log ONCE 423connect (con1,localhost,root,,); 424connection default; 425disconnect con1; 426 427# ---------------------------------------------------------------------------- 428# Test ONCE can be combined with --error or modifiers like lowercase 429# ---------------------------------------------------------------------------- 430 431--disable_result_log ONCE 432--error ER_NO_SUCH_TABLE 433select 5 from t1; 434 435--disable_query_log ONCE 436--lowercase_result 437select "CASE" as "LOWER"; 438 439--sorted_result 440--disable_query_log ONCE 441select "xyz" as name union select "abc" as name order by name desc; 442 443# ---------------------------------------------------------------------------- 444# Test --error with backtick operator or query_get_value 445# ---------------------------------------------------------------------------- 446 447--error 0,ER_NO_SUCH_TABLE 448let $empty= `SELECT foo from bar`; 449echo $empty is empty; 450 451--error 0,ER_BAD_FIELD_ERROR 452let $empty= query_get_value(SELECT bar as foo, baz, 1); 453echo $empty is empty; 454 455--error 0,ER_NO_SUCH_TABLE 456if (!`SELECT foo from bar`) { 457 echo "Yes it's empty"; 458} 459 460# ---------------------------------------------------------------------------- 461# Test comments 462# ---------------------------------------------------------------------------- 463 464# This is a comment 465# This is a ; comment 466# This is a -- comment 467# -- This is also a comment 468# -- # This is also a comment 469# -- This is also a ; comment 470 471# ---------------------------------------------------------------------------- 472# Test comments with embedded command 473# ---------------------------------------------------------------------------- 474 475--echo hello 476-- echo hello 477-- echo ;;;;;;;; 478 479--echo # MySQL: -- The 480 481# ---------------------------------------------------------------------------- 482# Test detect end of line "junk" 483# Most likely caused by a missing delimiter 484# ---------------------------------------------------------------------------- 485 486# Too many parameters to function 487--error 1 488--exec echo "sleep 5 6;" | $MYSQL_TEST 2>&1 489 490# Too many parameters to function 491--error 1 492--exec echo "--sleep 5 6" | $MYSQL_TEST 2>&1 493 494# 495# Missing delimiter 496# The comment will be "sucked into" the sleep command since 497# delimiter is missing until after "show status" 498--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 499sleep 4 500# A comment 501show status; 502EOF 503--error 1 504--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 505remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 506 507# 508# Missing delimiter until eof 509# The comment will be "sucked into" the sleep command since 510# delimiter is missing 511--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 512sleep 7 513# Another comment 514EOF 515--error 1 516--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 517remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 518 519# 520# Missing delimiter until "disable_query_log" 521# 522--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 523disconnect default 524 525# 526# comment 527# comment 3 528disable_query_log; 529EOF 530--error 1 531--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 532remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 533 534# 535# Missing delimiter until "disable_query_log" 536# 537--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 538disconnect default 539 540# 541# comment 542 543# comment 3 544disable_query_log; 545EOF 546--error 1 547--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 548remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 549 550# 551# Missing delimiter until eof 552# 553--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 554disconnect default 555 556# 557# comment 558# comment2 559 560# comment 3 561--disable_query_log 562EOF 563--error 1 564--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 565remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 566 567# 568# Missing delimiter until eof 569# 570--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 571disconnect default # comment 572# comment part2 573 574# comment 3 575--disable_query_log 576EOF 577--error 1 578--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 579 580remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 581 582# 583# Extra delimiter 584# 585--error 1 586--exec echo "--sleep 4;" | $MYSQL_TEST 2>&1 587--error 1 588--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1 589 590# 591# Extra text after `` 592# 593# Cannot use exec echo here as ` may or may not need to be escaped 594--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 595let $x= `select 1` BOO ; 596EOF 597--error 1 598--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 599remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 600--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 601--let $x= `select 1`; 602EOF 603--error 1 604--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 605remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 606--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 607# Missing ; in next line should be detected and cause failure 608let $x= `select 1` 609let $x= 2; 610echo $x; 611EOF 612--error 1 613--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 614remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 615 616 617# Allow trailing # comment 618--sleep 1 # Wait for insert delayed to be executed. 619--sleep 1 # Wait for insert delayed to be executed. 620 621# ---------------------------------------------------------------------------- 622# Test error 623# ---------------------------------------------------------------------------- 624 625# Missing argument 626--error 1 627--exec echo "error;" | $MYSQL_TEST 2>&1 628--error 1 629--exec echo "--error" | $MYSQL_TEST 2>&1 630 631# First char must be uppercase 'S' or 'E' or [0-9] 632--error 1 633--exec echo "--error s99999" | $MYSQL_TEST 2>&1 634--error 1 635--exec echo "--error e99999" | $MYSQL_TEST 2>&1 636--error 1 637--exec echo "--error 9eeeee" | $MYSQL_TEST 2>&1 638--error 1 639--exec echo "--error 1sssss" | $MYSQL_TEST 2>&1 640 641# First char 'S' but too long 642--error 1 643--exec echo "--error S999999" | $MYSQL_TEST 2>&1 644 645# First char 'S' but lowercase char found 646--error 1 647--exec echo "--error S99a99" | $MYSQL_TEST 2>&1 648 649# First char 'S' but too short 650--error 1 651--exec echo "--error S9999" | $MYSQL_TEST 2>&1 652 653# First char 'E' but not found in error array 654--error 1 655--exec echo "--error E9999" | $MYSQL_TEST 2>&1 656 657# First char [0-9] but contains chars 658--error 1 659--exec echo "--error 999e9" | $MYSQL_TEST 2>&1 660--error 1 661--exec echo "--error 9b" | $MYSQL_TEST 2>&1 662 663# Multiple errorcodes separated by ',' 664--error 1,1,1,1 665#--error 9,ER_PARSE_ERROR 666#--error ER_PARSE_ERROR 667#--error 9,ER_PARSE_ERROR,9,ER_PARSE_ERROR 668#--error 9, ER_PARSE_ERROR, 9, ER_PARSE_ERROR 669#--error 9,S00000,9,ER_PARSE_ERROR 670#--error 9,S00000,9,ER_PARSE_ERROR,ER_PARSE_ERROR,ER_PARSE_ERROR,9,10,11,12 671--error 9,S00000,9 672--error 9,S00000,9,9,10,11,12 673--error 9 ,10 674--error 9 , 10 675--error 9 , 10 676--error 9 , 10 677 678# Too many errorcodes specified 679--error 1 680--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $MYSQL_TEST 2>&1 681 682 683# ---------------------------------------------------------------------------- 684# Test echo command 685# ---------------------------------------------------------------------------- 686 687echo MySQL; 688echo "MySQL"; 689echo MySQL: The world''s most popular open source database; 690echo "MySQL: The world's most popular open source database"; 691 692echo MySQL: The world''s 693 most popular open 694 source database; 695 696echo # MySQL: The world''s 697# most popular open 698# source database; 699 700echo - MySQL: The world''s 701- most popular open 702- source database; 703 704echo - MySQL: The world''s 705-- most popular 706-- open source database; 707 708echo # MySQL: The 709--world''s 710# most popular 711-- open 712- source database; 713 714echo "MySQL: The world's most popular; open source database"; 715echo "MySQL: The world's most popular ; open source database"; 716echo "MySQL: The world's most popular ;open source database"; 717echo echo message echo message; 718 719 720echo ; 721 722# Illegal use of echo 723 724#--error 1 725#--exec echo "echo \$;" | $MYSQL_TEST 2>&1 726 727 728# ---------------------------------------------------------------------------- 729# Test exec command 730# ---------------------------------------------------------------------------- 731 732# Illegal use of exec 733--error 1 734--exec echo "--exec " | $MYSQL_TEST 2>&1 735 736# Multi-line exec 737exec $MYSQL 738 test -e "select 1"; 739exec $MYSQL test -e "select 740 2"; 741let $query = select 3 742 as X; 743exec $MYSQL test -e "$query"; 744 745# ---------------------------------------------------------------------------- 746# Test let command 747# ---------------------------------------------------------------------------- 748 749let $message=MySQL; 750echo $message; 751 752let $message="MySQL"; 753echo $message; 754 755let $message= MySQL: The 756 world''s most 757 popular open 758 source database; 759echo $message; 760 761let $message= # MySQL: The 762# world''s most 763# popular open 764# source database; 765echo $message; 766 767let $message= -- MySQL: The 768-- world''s most 769-- popular 770-- open source database; 771echo $message; 772 773let $message= # MySQL: The 774- world''s most 775-- popular open 776# source database; 777echo $message; 778 779echo '$message'; 780echo "$message"; 781 782let $1=hej; 783echo $1; 784 785let $1 =hej ; 786echo $1; 787 788let $1 = hej; 789echo $1; 790 791let $1=1; 792let $2=$1; 793echo $2; 794let $5=$6; 795echo $5; 796echo $6; 797 798let $where=a long variable content; 799echo $where; 800 801let $where2= $where; 802echo $where2; 803 804let $where3=a long $where variable content; 805echo $where3; 806 807let $where3=a long \\\$where variable content; 808echo $where3; 809 810let $novar1= $novar2; 811echo $novar1; 812 813let $cat=na; 814let $cat=ba$cat$cat; 815echo banana = $cat; 816 817# ba\$cat\$cat should have been sufficient. 818# ba\\\$cat\\\$cat -> ba\$cat\$cat -> ba$cat$cat -> banana 819# Magnus' upcoming patch will fix the missing second interpretation. 820let $cat=ba\\\$cat\\\$cat; 821echo Not a banana: $cat; 822 823# Bug #55413 would cause this to fail 824let $escape= with\`some\"escaped\'quotes; 825echo $escape; 826 827--let $escape= with\`some\"escaped\'quotes 828echo $escape; 829 830# This only works with "--let" syntax 831--let $tick= single'tick`backtick 832echo $tick; 833 834# Test illegal uses of let 835 836--error 1 837--exec echo "let ;" | $MYSQL_TEST 2>&1 838 839--error 1 840--exec echo "let \$=hi;" | $MYSQL_TEST 2>&1 841 842--error 1 843--exec echo "let \$1 hi;" | $MYSQL_TEST 2>&1 844 845--error 1 846--exec echo "let \$m hi;" | $MYSQL_TEST 2>&1 847 848--error 1 849--exec echo "let \$hi;" | $MYSQL_TEST 2>&1 850 851--error 1 852--exec echo "let \$ hi;" | $MYSQL_TEST 2>&1 853 854--error 1 855--exec echo "let =hi;" | $MYSQL_TEST 2>&1 856 857--error 1 858--exec echo "let hi;" | $MYSQL_TEST 2>&1 859 860# More advanced test for Bug#17280 861let $success= 1; 862--echo # Execute: --echo # <whatever> success: \$success 863--echo # <whatever> success: $success 864--echo # Execute: echo # <whatever> success: \$success ; 865echo # <whatever> success: $success ; 866 867--echo # The next two variants work fine and expand the content of \$success 868--echo # Execute: --echo \$success 869--echo $success 870--echo # Execute: echo \$success ; 871echo $success ; 872 873 874# ---------------------------------------------------------------------------- 875# Test to assign let from variable 876# let $<var_name>=$<var_name>; 877# ---------------------------------------------------------------------------- 878 879--echo # Check if let \$B = \$A is an assignment per value. 880 881# Basic preparations: 882--echo let \$A = initial value of A; 883let $A = initial value of A; 884# --echo # Content of \$A is: $A 885--echo let \$B = initial value of B; 886let $B = initial value of B; 887# --echo # Content of \$B is: $B 888 889# Assign $B to $A: 890--echo let \$B = \$A 891let $A = $B; 892--echo # Content of \$A is: $A 893 894# Changes of $B must NOT affect $A and Changes of $A must NOT affect $B ! 895--echo let \$A = changed value of A; 896let $A = changed value of A; 897--echo # Content of \$B is: $B 898 899--echo let \$B = changed value of B; 900let $B = changed value of B; 901--echo # Content of \$A is: $A 902 903# ---------------------------------------------------------------------------- 904# Test let from query with $variable 905# let $<var_name>=`<query with $variable>`; 906# ---------------------------------------------------------------------------- 907 908let $var1=content of variable 1; 909let $var2= `select "$var1"`; 910let $var3= `select concat("$var1", " ", "$var2")`; 911echo var2: $var2; 912echo var3: $var3; 913if (`select length("$var3") > 0`) 914{ 915 echo length of var3 is longer than 0; 916} 917 918# ---------------------------------------------------------------------------- 919# Test to assign let from query 920# let $<var_name>=`<query>`; 921# ---------------------------------------------------------------------------- 922echo var1; 923let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`; 924echo $var1; 925 926echo var2; 927let $var2= `select 2 as "Column num 2"`; 928echo $var2; 929 930echo var2 again; 931let $var2= `select 2 as "Column num 2"`; 932echo $var2; 933 934echo var3 two columns with same name; 935let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`; 936echo $var3; 937 938echo var4 from query that returns NULL; 939let $var4= `select NULL`; 940 941echo var5 from query that returns no row; 942let $var5= `SHOW VARIABLES LIKE "nonexisting_variable"`; 943 944echo failing query in let; 945--write_file $MYSQLTEST_VARDIR/tmp/let.sql 946let $var2= `failing query`; 947echo $var2; 948EOF 949 950create table t1 (a varchar(100)); 951insert into t1 values ('`select 42`'); 952let $a= `select * from t1`; 953# This should output `select 42`, not evaluate it again to 42 954echo $a; 955insert into t1 values ('$dollar'); 956# These should also output the string without evaluating it. 957let $a= query_get_value(select * from t1 order by a, a, 1); 958echo $a; 959let $a= query_get_value(select * from t1 order by a, a, 2); 960echo $a; 961drop table t1; 962 963--error 1 964--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1 965 966remove_file $MYSQLTEST_VARDIR/tmp/let.sql; 967 968 969# ---------------------------------------------------------------------------- 970# Test source command 971# ---------------------------------------------------------------------------- 972 973# Test illegal uses of source 974 975--error 1 976--exec echo "source ;" | $MYSQL_TEST 2>&1 977 978# Fix win paths 979--replace_result \\ / 980# Source a nonexisting file 981--error 1 982--exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1 983 984# Too many source 985--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql 986--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 987--error 1 988--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $MYSQL_TEST 2>&1 989remove_file $MYSQLTEST_VARDIR/tmp/recursive.sql; 990 991# Source a file with error 992--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql 993--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 994--error 1 995--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $MYSQL_TEST 2>&1 996 997remove_file $MYSQLTEST_VARDIR/tmp/error.sql; 998 999# Test execution of source in a while loop 1000--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc 1001echo here is the sourced script; 1002EOF 1003--disable_query_log 1004let $outer= 2; # Number of outer loops 1005while ($outer) 1006{ 1007 eval SELECT '$outer = outer loop variable after while' AS ""; 1008 1009 --source $MYSQLTEST_VARDIR/tmp/sourced.inc 1010 1011 eval SELECT '$outer = outer loop variable before dec' AS ""; 1012 dec $outer; 1013 eval SELECT '$outer = outer loop variable after dec' AS ""; 1014} 1015 1016# Test source in an if in a while which is false on 1st iteration 1017# Also test --error and --disable_abort_on_error in same context 1018let $outer= 2; # Number of outer loops 1019let $ifval= 0; # false 1st time 1020while ($outer) 1021{ 1022 echo outer=$outer ifval=$ifval; 1023 1024 if ($ifval) { 1025 --source $MYSQLTEST_VARDIR/tmp/sourced.inc 1026 --error ER_NO_SUCH_TABLE 1027 SELECT * from nowhere; 1028 --disable_abort_on_error ONCE 1029# Statement giving a different error, to make sure we don't mask it 1030 SELECT * FROM nowhere else; 1031 } 1032 dec $outer; 1033 inc $ifval; 1034} 1035 1036 1037# Test execution of source in a while loop 1038--disable_abort_on_error 1039# Sourcing of a file within while loop, sourced file will 1040# source other file 1041let $num= 9; 1042while ($num) 1043{ 1044 SELECT 'In loop' AS ""; 1045 --source $MYSQLTEST_VARDIR/tmp/sourced.inc 1046 dec $num; 1047} 1048--enable_abort_on_error 1049--enable_query_log 1050 1051# Test source $variable/<filename> 1052--source $MYSQLTEST_VARDIR/tmp/sourced.inc 1053 1054--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc 1055 1056--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc 1057echo "hello"; 1058EOF 1059 1060let $x= sourced; 1061source $MYSQLTEST_VARDIR/tmp/$x.inc; 1062 1063let $x= $MYSQLTEST_VARDIR; 1064source $x/tmp/sourced.inc; 1065 1066--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc 1067 1068 1069# ---------------------------------------------------------------------------- 1070# Test sleep command 1071# ---------------------------------------------------------------------------- 1072 1073sleep 0.5; 1074sleep 1; 1075real_sleep 1; 1076 1077# Parameter from variable, legal and illegal 1078let $sleep_var= 0.1; 1079sleep $sleep_var; 1080let $sleep_var= 1; 1081--real_sleep $sleep_var 1082 1083--write_file $MYSQL_TMP_DIR/sleep.inc 1084let $sleep_var= xyz; 1085--sleep $sleep_var 1086EOF 1087--error 1 1088--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1 1089--remove_file $MYSQL_TMP_DIR/sleep.inc 1090 1091--write_file $MYSQL_TMP_DIR/sleep.inc 1092let $sleep_var= xyz; 1093real_sleep $sleep_var; 1094EOF 1095--error 1 1096--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1 1097--remove_file $MYSQL_TMP_DIR/sleep.inc 1098 1099# Missing parameter 1100--error 1 1101--exec echo "sleep ;" | $MYSQL_TEST 2>&1 1102--error 1 1103--exec echo "real_sleep ;" | $MYSQL_TEST 2>&1 1104 1105# Illegal parameter 1106--error 1 1107--exec echo "sleep abc;" | $MYSQL_TEST 2>&1 1108--error 1 1109--exec echo "real_sleep abc;" | $MYSQL_TEST 2>&1 1110 1111# ---------------------------------------------------------------------------- 1112# Test inc 1113# ---------------------------------------------------------------------------- 1114let $i= 0; 1115inc $i; 1116echo $i; 1117let $i=100; 1118inc $i; 1119echo $i; 1120let $i= -100; 1121inc $i; 1122echo $i; 1123 1124--error 1 1125--exec echo "inc;" | $MYSQL_TEST 2>&1 1126--error 1 1127--exec echo "inc i;" | $MYSQL_TEST 2>&1 1128--error 1 1129--exec echo "inc \$i;" | $MYSQL_TEST 2>&1 1130--error 1 1131--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1 1132--error 1 1133--exec echo "let \$i=text; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1 1134--error 1 1135--exec echo "let \$i=10cc; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1 1136 1137inc $i; inc $i; inc $i; --echo $i 1138echo $i; 1139 1140 1141# ---------------------------------------------------------------------------- 1142# Test dec 1143# ---------------------------------------------------------------------------- 1144 1145let $d= 0; 1146dec $d; 1147echo $d; 1148let $d=100; 1149dec $d; 1150echo $d; 1151 1152--error 1 1153--exec echo "dec;" | $MYSQL_TEST 2>&1 1154--error 1 1155--exec echo "dec i;" | $MYSQL_TEST 2>&1 1156--error 1 1157--exec echo "dec \$i;" | $MYSQL_TEST 2>&1 1158--error 1 1159--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1 1160--error 1 1161--exec echo "let \$i=text; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1 1162--error 1 1163--exec echo "let \$i=10cc; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1 1164 1165 1166# ---------------------------------------------------------------------------- 1167# Test system 1168# ---------------------------------------------------------------------------- 1169#system ls > /dev/null; 1170system echo "hej" > /dev/null; 1171#--system ls > /dev/null 1172--system echo "hej" > /dev/null; 1173 1174--error 1 1175--exec echo "system;" | $MYSQL_TEST 2>&1 1176--error 1 1177--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1 1178 1179--disable_abort_on_error ONCE 1180system NonExistsinfComamdn 2> /dev/null; 1181 1182 1183# ---------------------------------------------------------------------------- 1184# Test delimiter 1185# ---------------------------------------------------------------------------- 1186 1187delimiter stop; 1188echo teststop 1189delimiter ;stop 1190echo test2; 1191--delimiter stop 1192echo test3stop 1193--delimiter ; 1194echo test4; 1195 1196# ---------------------------------------------------------------------------- 1197# Test that delimiter within if() works in in various combinations 1198# ---------------------------------------------------------------------------- 1199 1200if (0) 1201{ 1202 delimiter ||; 1203 echo false-inner|| 1204 if (0) 1205 { 1206 delimiter *|| 1207 echo false-innerer* 1208 delimiter ||* 1209 } 1210 echo false-inner again|| 1211} 1212echo outer; 1213if (1) 1214{ 1215 delimiter /; 1216 echo true-inner/ 1217 if (0) 1218 { 1219 delimiter %/ 1220 echo true-innerer% 1221 } 1222 echo true-inner again/ 1223} 1224echo true-outer/ 1225delimiter ;/ 1226 1227 1228# ---------------------------------------------------------------------------- 1229# Test if 1230# ---------------------------------------------------------------------------- 1231 1232let $counter=10; 1233if ($counter) 1234{ 1235 echo Counter is greater than 0, (counter=10); 1236} 1237if (!$counter) 1238{ 1239 echo Counter is not 0, (counter=10); 1240} 1241if (! $counter) 1242{ 1243 let $counter=5; 1244} 1245echo Counter should still be 10, is $counter; 1246let $counter=0; 1247if($counter) 1248{ 1249 echo Counter is greater than 0, (counter=0); 1250} 1251if (!$counter) 1252{ 1253 echo Counter is not 0, (counter=0); 1254} 1255if (! $counter) 1256{ 1257 echo Not space var works; 1258} 1259 1260# ---------------------------------------------------------------------------- 1261# Test if with some non-numerics 1262# ---------------------------------------------------------------------------- 1263 1264let $counter=alpha; 1265if ($counter) 1266{ 1267 echo Counter is true, (counter=alpha); 1268} 1269let $counter= ; 1270if ($counter) 1271{ 1272 echo oops, space is true; 1273} 1274let $counter=-0; 1275if ($counter) 1276{ 1277 echo oops, -0 is true; 1278} 1279# This is no longer allowed, as a precaution against mistyped conditionals 1280# if (beta) 1281# { 1282# echo Beta is true; 1283# } 1284let $counter=gamma; 1285while ($counter) 1286{ 1287 echo while with string, only once; 1288 let $counter=000; 1289} 1290 1291# ---------------------------------------------------------------------------- 1292# Test if with compare conditions 1293# ---------------------------------------------------------------------------- 1294 1295let $ifvar= 5; 1296let $ifvar2= 6; 1297 1298if ($ifvar < 7) 1299{ 1300 echo 5<7; 1301} 1302if ($ifvar< 7) 1303{ 1304 echo 5<7 again; 1305} 1306if ($ifvar<7) 1307{ 1308 echo 5<7 still; 1309} 1310if ($ifvar < $ifvar2) 1311{ 1312 echo 5<6; 1313} 1314if ($ifvar <= 4) 1315{ 1316 echo 5<=4; 1317} 1318if ($ifvar >= 5) 1319{ 1320 echo 5>=5; 1321} 1322if ($ifvar>=5) 1323{ 1324 echo 5>=5 again; 1325} 1326if ($ifvar > 3) 1327{ 1328 echo 5>3; 1329} 1330if ($ifvar == 4) 1331{ 1332 echo 5==4; 1333} 1334if ($ifvar == 5) 1335{ 1336 echo 5==5; 1337} 1338if ($ifvar != 8) 1339{ 1340 echo 5!=8; 1341} 1342# Any number should compare unequal to any string 1343if ($ifvar != five) 1344{ 1345 echo 5!=five; 1346} 1347if ($ifvar == `SELECT 3+2`) 1348{ 1349 echo 5==3+2; 1350} 1351if ($ifvar == 5) 1352{ 1353 echo 5 == 5; 1354} 1355let $ifvar= hello; 1356if ($ifvar == hello there) 1357{ 1358 echo hello == hello there; 1359} 1360if ($ifvar == hello) 1361{ 1362 echo hello == hello; 1363} 1364if ($ifvar == hell) 1365{ 1366 echo hello == hell; 1367} 1368if ($ifvar == hello) 1369{ 1370 echo hello == hello; 1371} 1372if ($ifvar != goodbye) 1373{ 1374 echo hello != goodbye; 1375} 1376let $ifvar= 'quoted'; 1377if ($ifvar == ''quoted'') 1378{ 1379 echo 'quoted' == ''quoted''; 1380} 1381let $ifvar= two words; 1382if ($ifvar == two words) 1383{ 1384 echo two words; 1385} 1386if ($ifvar == 'two words') 1387{ 1388 echo 'two words'; 1389} 1390if ($ifvar == "two words") 1391{ 1392 echo "two words"; 1393} 1394if ($ifvar == `SELECT 'two words'`) 1395{ 1396 echo two words are two words; 1397} 1398if (42) 1399{ 1400 echo right answer; 1401} 1402if (0) 1403{ 1404 echo wrong answer; 1405} 1406# Non-empty string treated as 'true' 1407if (`SELECT 'something'`) 1408{ 1409 echo anything goes; 1410} 1411# Make sure 0 and string compare right 1412let $ifvar= 0; 1413if ($ifvar == string) 1414{ 1415 echo 0 == string; 1416} 1417if ($ifvar != string) 1418{ 1419 echo 0 != string; 1420} 1421--write_file $MYSQL_TMP_DIR/mysqltest.sql 1422let $var= 5; 1423if ($var >= four) 1424{ 1425 echo 5>=four; 1426} 1427EOF 1428--error 1 1429--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 1430remove_file $MYSQL_TMP_DIR/mysqltest.sql; 1431 1432--write_file $MYSQL_TMP_DIR/mysqltest.sql 1433let $var= 5; 1434if ($var ~= 6) 1435{ 1436 echo 5~=6; 1437} 1438EOF 1439--error 1 1440--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 1441remove_file $MYSQL_TMP_DIR/mysqltest.sql; 1442 1443--write_file $MYSQL_TMP_DIR/mysqltest.sql 1444let $var= text; 1445if (var == text) 1446{ 1447 echo Oops I forgot the $; 1448} 1449EOF 1450--error 1 1451--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 1452remove_file $MYSQL_TMP_DIR/mysqltest.sql; 1453 1454--error 1 1455--exec echo "if (\$var ==) {" | $MYSQL_TEST 2>&1 1456--error 1 1457--exec echo "if (\$var > ) {" | $MYSQL_TEST 2>&1 1458 1459# ---------------------------------------------------------------------------- 1460# Test while with compare conditions 1461# ---------------------------------------------------------------------------- 1462 1463let $counter= 2; 1464 1465while ($counter < 5) 1466{ 1467 echo counter is $counter; 1468 inc $counter; 1469} 1470let $ifvar=; 1471while ($ifvar != stop) 1472{ 1473 if ($counter >= 7) 1474 { 1475 let $ifvar= stop; 1476 } 1477 echo counter is $counter; 1478 inc $counter; 1479} 1480 1481# ---------------------------------------------------------------------------- 1482# Test while, { and } 1483# ---------------------------------------------------------------------------- 1484 1485let $i=1; 1486while ($i) 1487{ 1488 echo $i; 1489 dec $i; 1490} 1491# One liner 1492#let $i=1;while ($i){echo $i;dec $i;} 1493 1494let $i=0; 1495while (!$i) 1496{ 1497 echo Testing while with not; 1498 inc $i; 1499} 1500 1501# Exceed max nesting level 1502--write_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc 1503let $1 = 10; 1504while ($1) 1505{ 1506while ($1) 1507{ 1508while ($1) 1509{ 1510 while ($1) 1511{ 1512 while ($1) 1513{ 1514 while ($1) 1515{ 1516 while ($1) 1517{ 1518 while ($1) 1519{ 1520 while ($1) 1521{ 1522 while ($1) 1523{ 1524 while ($1) 1525{ 1526 while ($1) 1527{ 1528 while ($1) 1529{ 1530 while ($1) 1531{ 1532 while ($1) 1533{ 1534 while ($1) 1535{ 1536 while ($1) 1537{ 1538 while ($1) 1539{ 1540 while ($1) 1541{ 1542 while ($1) 1543{ 1544 while ($1) 1545{ 1546 while ($1) 1547{ 1548 while ($1) 1549{ 1550 while ($1) 1551{ 1552 while ($1) 1553{ 1554 while ($1) 1555{ 1556 while ($1) 1557{ 1558 while ($1) 1559{ 1560 while ($1) 1561{ 1562 while ($1) 1563{ 1564 while ($1) 1565{ 1566 while ($1) 1567{ 1568 while ($1) 1569{ 1570 while ($1) 1571{ 1572 while ($1) 1573{ 1574 while ($1) 1575{ 1576 while ($1) 1577{ 1578 while ($1) 1579{ 1580 while ($1) 1581{ 1582 while ($1) 1583{ 1584 while ($1) 1585{ 1586 while ($1) 1587{ 1588 while ($1) 1589{ 1590 while ($1) 1591{ 1592 while ($1) 1593{ 1594 while ($1) 1595{ 1596 while ($1) 1597{ 1598 while ($1) 1599{ 1600 while ($1) 1601{ 1602 echo $1; 1603 dec $1; 1604} 1605} 1606} 1607} 1608} 1609} 1610} 1611} 1612} 1613} 1614} 1615} 1616} 1617} 1618} 1619} 1620} 1621} 1622} 1623} 1624} 1625} 1626} 1627} 1628} 1629} 1630} 1631} 1632} 1633} 1634} 1635} 1636} 1637} 1638} 1639} 1640EOF 1641# Fix win path 1642--replace_result \\ / $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 1643--error 1 1644--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc;" | $MYSQL_TEST 2>&1 1645--remove_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc 1646--error 1 1647--exec echo "while \$i;" | $MYSQL_TEST 2>&1 1648--error 1 1649--exec echo "while (\$i;" | $MYSQL_TEST 2>&1 1650--error 1 1651--exec echo "let \$i=1; while (\$i) dec \$i;" | $MYSQL_TEST 2>&1 1652--error 1 1653--exec echo "};" | $MYSQL_TEST 2>&1 1654--error 1 1655--exec echo "end;" | $MYSQL_TEST 2>&1 1656--error 1 1657--exec echo "{;" | $MYSQL_TEST 2>&1 1658 1659--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1660while (0) 1661echo hej; 1662EOF 1663--error 1 1664--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 1665remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1666 1667--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1668while (0) 1669{echo hej; 1670EOF 1671--error 1 1672--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 1673remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1674 1675--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1676while (0){ 1677 echo hej; 1678EOF 1679--error 1 1680--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 1681 1682remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1683 1684# ---------------------------------------------------------------------------- 1685# Test error messages returned from comments starting with a command 1686# ---------------------------------------------------------------------------- 1687--error 1 1688--exec echo "--if the other server is down" | $MYSQL_TEST 2>&1 1689 1690--error 1 1691--exec echo "-- end when ..." | $MYSQL_TEST 2>&1 1692 1693# ---------------------------------------------------------------------------- 1694# Test replace 1695# ---------------------------------------------------------------------------- 1696--replace_result a b 1697select "a" as col1, "c" as col2; 1698 1699--replace_result a b c d 1700select "a" as col1, "c" as col2; 1701 1702--error 1 1703--exec echo "--replace_result a" | $MYSQL_TEST 2>&1 1704--error 1 1705--exec echo "--replace_result a;" | $MYSQL_TEST 2>&1 1706--error 1 1707--exec echo "replace_result a;" | $MYSQL_TEST 2>&1 1708--error 1 1709--exec echo "replace_result a ;" | $MYSQL_TEST 2>&1 1710--exec echo "replace_result a b; echo OK; exit;" | $MYSQL_TEST 2>&1 1711--error 1 1712--exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1 1713--error 1 1714--exec echo "replace_result a b c ;" | $MYSQL_TEST 2>&1 1715 1716 1717--replace_column 1 b 1718select "a" as col1, "c" as col2; 1719 1720--replace_column 1 b 2 d 1721select "a" as col1, "c" as col2; 1722 1723--error 1 1724--exec echo "--replace_column a" | $MYSQL_TEST 2>&1 1725 1726--error 1 1727--exec echo "--replace_column 1" | $MYSQL_TEST 2>&1 1728 1729--error 1 1730--exec echo "--replace_column a b" | $MYSQL_TEST 2>&1 1731--error 1 1732--exec echo "--replace_column a 1" | $MYSQL_TEST 2>&1 1733--error 1 1734--exec echo "--replace_column 1 b c " | $MYSQL_TEST 2>&1 1735 1736let $long_rep= 1234567890123456789012345678901234567890; 1737let $long_rep= $long_rep,$long_rep; 1738let $long_rep= $long_rep,$long_rep; 1739let $long_rep= $long_rep,$long_rep; 1740let $long_rep= $long_rep,$long_rep; 1741let $long_rep= $long_rep,$long_rep; 1742 1743# This tests from strings > 1024 (here 1311) 1744 1745--replace_result $long_rep LONG_STRING 1746eval select "$long_rep" as x; 1747 1748# Test replace within `` 1749 1750--replace_result cat dog 1751--let $animal= `select "cat" as pet` 1752--echo $animal 1753 1754# ---------------------------------------------------------------------------- 1755# Test sync_with_master 1756# ---------------------------------------------------------------------------- 1757--error 1 1758--exec echo "sync_with_master 10!;" | $MYSQL_TEST 2>&1 1759--error 1 1760--exec echo "sync_with_master a;" | $MYSQL_TEST 2>&1 1761 1762# ---------------------------------------------------------------------------- 1763# Test connect 1764# ---------------------------------------------------------------------------- 1765 1766--error 1 1767--exec echo "connect;" | $MYSQL_TEST 2>&1 1768--error 1 1769--exec echo "connect ();" | $MYSQL_TEST 2>&1 1770--error 1 1771--exec echo "connect (con2);" | $MYSQL_TEST 2>&1 1772--error 1 1773--exec echo "connect (con2,);" | $MYSQL_TEST 2>&1 1774--error 1 1775--exec echo "connect (con2,localhost,root,,illegal_db);" | $MYSQL_TEST 2>&1 1776--error 1 1777--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $MYSQL_TEST 2>&1 1778--error 1 1779--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1 1780 1781# Repeat connect/disconnect 1782--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1783let $i=200; 1784while ($i) 1785{ 1786 connect (test_con1,localhost,root,,); 1787 disconnect test_con1; 1788 dec $i; 1789} 1790echo 200 connects succeeded; 1791EOF 1792--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1 1793remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1794 1795# Select disconnected connection 1796--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1797connect (test_con1,localhost,root,,); 1798disconnect test_con1; 1799connection test_con1; 1800EOF 1801--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 1802--error 1 1803--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1 1804remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1805 1806# Connection name already used 1807--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1808connect (test_con1,localhost,root,,); 1809connect (test_con1,localhost,root,,); 1810EOF 1811--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 1812--error 1 1813--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1 1814 1815remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1816 1817# connect when "disable_abort_on_error" caused "connection not found" 1818--disable_abort_on_error 1819connect (con1,localhost,root,,); 1820connection default; 1821connection con1; 1822disconnect con1; 1823--enable_abort_on_error 1824 1825# Test connect without a database 1826connect (con2,localhost,root,,*NO-ONE*); 1827--error ER_NO_DB_ERROR 1828show tables; 1829disconnect con2; 1830connection default; 1831 1832# Test enable_connect_log 1833--enable_connect_log 1834connect (con1,localhost,root,,); 1835connection default; 1836connection con1; 1837--disable_query_log 1838# These should not be logged 1839connect (con2,localhost,root,,*NO-ONE*); 1840connection con2; 1841disconnect con2; 1842connection con1; 1843--enable_query_log 1844disconnect con1; 1845connection default; 1846--disable_connect_log 1847 1848# ---------------------------------------------------------------------------- 1849# Test mysqltest arguments 1850# ---------------------------------------------------------------------------- 1851 1852# -x <file_name>, use the file specified after -x as the test file 1853--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc 1854--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc 1855--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc 1856# Fix Win paths 1857--replace_result \\ / 1858--error 1 1859--exec $MYSQL_TEST -x non_existing_file.inc 2>&1 1860 1861 1862# ---------------------------------------------------------------------------- 1863# TODO Test queries, especially their errormessages... so it's easy to debug 1864# new scripts and diagnose errors 1865# ---------------------------------------------------------------------------- 1866 1867# ---------------------------------------------------------------------------- 1868# Test Bug#12386 1869# ---------------------------------------------------------------------------- 1870let $num= 2; 1871while ($num) 1872{ 1873 --error ER_PARSE_ERROR 1874 1875 failing_statement; 1876 1877 dec $num; 1878} 1879 1880SELECT 1 as a; 1881 1882 1883# 1884# Bug#10251 Identifiers containing quotes not handled correctly 1885# 1886select 1 as `a'b`, 2 as `a"b`; 1887 1888# Test escaping of quotes 1889select 'aaa\\','aa''a',"aa""a"; 1890 1891# 1892# Check of include/show_msg.inc and include/show_msg80.inc 1893# 1894 1895# The message contains in most cases a string with the default character set 1896let $message= Here comes a message; 1897--source include/show_msg.inc 1898 1899# The message could also contain a string with character set utf8 1900let $message= `SELECT USER()`; 1901--source include/show_msg.inc 1902 1903# The message contains more then 80 characters on multiple lines 1904# and is kept between double quotes. 1905let $message= 1906"Here comes a very very long message that 1907 - is longer then 80 characters and 1908 - consists of several lines"; 1909--source include/show_msg80.inc 1910 1911# The message contains more then 80 characters on multiple lines 1912# and uses the auxiliary character "." at the beginning of the message lines. 1913let $message= . Here comes a very very long message that 1914 . - is longer then 80 characters and 1915 . - consists of several lines; 1916--source include/show_msg80.inc 1917 1918# 1919# Test --enable_parsing / disable_parsing 1920# 1921--disable_query_log 1922--disable_parsing 1923# The following will not enable query logging 1924--enable_query_log 1925select "this will not be executed"; 1926--enable_parsing 1927select "this will be executed"; 1928--enable_query_log 1929 1930# 1931# Test zero length result file. Should not pass 1932# 1933--exec echo '' > $MYSQLTEST_VARDIR/tmp/zero_length_file.result 1934--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql 1935--error 1 1936--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1 1937 1938remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result; 1939--error 0,1 1940remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject; 1941--error 0,1 1942remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.log; 1943--error 0,1 1944remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject; 1945 1946# 1947# Test that a test file that does not generate any output fails. 1948# 1949--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql 1950--error 1 1951--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1 1952 1953remove_file $MYSQLTEST_VARDIR/tmp/query.sql; 1954 1955# 1956# Test that mysqltest fails when there are no queries executed 1957# but a result file exists 1958# NOTE! This will never happen as long as it's not allowed to have 1959# test files that produce no output 1960#--exec echo "something" > $MYSQLTEST_VARDIR/tmp/result_file.result 1961#--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql 1962#--error 1 1963#--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1 1964 1965# 1966# Bug#11731 mysqltest in multi-statement queries ignores errors in 1967# non-1st queries 1968# 1969 1970echo Failing multi statement query; 1971# PS does not support multi statement 1972--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql 1973--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1974--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1975--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1976--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1977--exec echo "insertz 'error query'||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1978--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1979 1980--error 1 1981--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1 1982drop table t1; 1983 1984--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 1985--error 1 1986--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1 1987# The .out file should be non existent 1988--error 1 1989--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out 1990drop table t1; 1991 1992 1993echo Multi statement using expected error; 1994# PS does not support multi statement 1995--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql 1996--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1997--exec echo "--error 1064" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1998--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1999--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 2000--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 2001--exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 2002--exec echo "delimiter ;||||…
Large files files are truncated, but you can click here to view the full file