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# Some tests below connect/disconnect rapidly in a loop. This causes a race 24# where mysqld may not have time to register the previous disconnects before 25# new connects, and eventually we run out of connections. So we need to 26# increase the maximum. 27let $saved_max_connections = `SELECT @@global.max_connections`; 28SET GLOBAL max_connections = 1000; 29 30 31# ============================================================================ 32# 33# Test of mysqltest itself 34# 35# There are three rules that determines what belong to each command 36# 1. A normal command is delimited by the <delimiter> which by default is 37# set to ';' 38# 39# ex: | select * 40# | from t1; 41# | 42# Command: "select * from t1" 43# 44# 2. Special case is a line that starts with "--", this is a comment 45# ended when the new line character is reached. But the first word 46# in the comment may contain a valid command, which then will be 47# executed. This can be useful when sending commands that 48# contains <delimiter> 49# 50# 3. Special case is also a line that starts with '#' which is treated 51# as a comment and will be ended by new line character 52# 53# ============================================================================ 54 55# ---------------------------------------------------------------------------- 56# Positive case(statement) 57# ---------------------------------------------------------------------------- 58 59select otto from (select 1 as otto) as t1; 60# expectation = response 61--error 0 62select otto from (select 1 as otto) as t1; 63 64# ---------------------------------------------------------------------------- 65# Negative case(statement): 66# The derived table t1 does not contain a column named 'friedrich' . 67# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and 68# --> 1054: Unknown column 'friedrich' in 'field list' 69# ---------------------------------------------------------------------------- 70 71# expectation <> response 72#--error 0 73#select friedrich from (select 1 as otto) as t1 74--error 1 75--exec echo "select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1 76 77# expectation = response 78--error ER_BAD_FIELD_ERROR 79 80select friedrich from (select 1 as otto) as t1; 81 82# The following unmasked unsuccessful statement must give 83# 1. mysqltest gives a 'failed' 84# 2. does not produce a r/<test case>.reject file !!! 85# PLEASE uncomment it and check its effect 86#select friedrich from (select 1 as otto) as t1; 87 88 89# ---------------------------------------------------------------------------- 90# Tests for the new feature - SQLSTATE error code matching 91# Positive case(statement) 92# ---------------------------------------------------------------------------- 93 94# This syntax not allowed anymore, use --error S00000, see below 95# expectation = response 96#!S00000 select otto from (select 1 as otto) as t1; 97 98--error S00000 99select otto from (select 1 as otto) as t1; 100 101# expectation <> response 102#!S42S22 select otto from (select 1 as otto) as t1; 103#--error S42S22 104#select otto from (select 1 as otto) as t1; 105--error 1 106--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1 107 108# expecting a SQL-state for a command that can't give one should fail 109--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 110--error 1 111--exec echo "disable_warnings ; error S00000; remove_file $MYSQLTEST_VARDIR/tmp/test_nonexistent.tmp;" | $MYSQL_TEST 2>&1 112 113 114# ---------------------------------------------------------------------------- 115# Negative case(statement) 116# ---------------------------------------------------------------------------- 117 118# This syntax not allowed anymore, use --error S42S22, see below 119# expectation = response 120#!S42S22 select friedrich from (select 1 as otto) as t1; 121--error S42S22 122select friedrich from (select 1 as otto) as t1; 123 124# expectation !=response 125#!S00000 select friedrich from (select 1 as otto) as t1; 126#--error S00000 127#select friedrich from (select 1 as otto) as t1; 128--error 1 129--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1 130 131# ---------------------------------------------------------------------------- 132# test cases for $mysql_errno 133# 134# $mysql_errno is a builtin variable of mysqltest and contains the return code 135# of the last command sent to the server. 136# 137# The following test cases often initialize $mysql_errno to 1064 by 138# a command with wrong syntax. 139# Example: --error 1064 To prevent the abort after the error. 140# garbage ; 141# ---------------------------------------------------------------------------- 142 143# ---------------------------------------------------------------------------- 144# check mysql_errno = 0 after successful statement 145# ---------------------------------------------------------------------------- 146select otto from (select 1 as otto) as t1; 147echo $mysql_errname; 148eval select $mysql_errno as "after_successful_stmt_errno" ; 149 150#---------------------------------------------------------------------------- 151# check mysql_errno = 1064 after statement with wrong syntax 152# ---------------------------------------------------------------------------- 153--error ER_PARSE_ERROR 154 155garbage ; 156echo $mysql_errname; 157eval select $mysql_errno as "after_wrong_syntax_errno" ; 158 159# ---------------------------------------------------------------------------- 160# check if let $my_var= 'abc' ; affects $mysql_errno 161# ---------------------------------------------------------------------------- 162--error ER_PARSE_ERROR 163 164garbage ; 165let $my_var= 'abc' ; 166echo $mysql_errname; 167eval select $mysql_errno as "after_let_var_equal_value" ; 168 169# ---------------------------------------------------------------------------- 170# check if set @my_var= 'abc' ; affects $mysql_errno 171# ---------------------------------------------------------------------------- 172--error ER_PARSE_ERROR 173 174garbage ; 175set @my_var= 'abc' ; 176echo $mysql_errname; 177eval select $mysql_errno as "after_set_var_equal_value" ; 178 179# ---------------------------------------------------------------------------- 180# check if the setting of --disable-warnings itself affects $mysql_errno 181# (May be --<whatever> modifies $mysql_errno.) 182# ---------------------------------------------------------------------------- 183--error ER_PARSE_ERROR 184 185garbage ; 186--disable_warnings 187echo $mysql_errname; 188eval select $mysql_errno as "after_disable_warnings_command" ; 189 190# ---------------------------------------------------------------------------- 191# check if --disable-warnings + command with warning affects the errno 192# stored within $mysql_errno 193# (May be disabled warnings affect $mysql_errno.) 194# ---------------------------------------------------------------------------- 195drop table if exists t1 ; 196--error ER_PARSE_ERROR 197 198garbage ; 199drop table if exists t1 ; 200echo $mysql_errname; 201eval select $mysql_errno as "after_disable_warnings" ; 202--enable_warnings 203 204# ---------------------------------------------------------------------------- 205# check if masked errors affect $mysql_errno 206# ---------------------------------------------------------------------------- 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_minus_masked" ; 215--error ER_PARSE_ERROR 216 217garbage ; 218--error ER_NO_SUCH_TABLE 219 220select 3 from t1 ; 221echo $mysql_errname; 222eval select $mysql_errno as "after_!_masked" ; 223 224# ---------------------------------------------------------------------------- 225# Will manipulations of $mysql_errno be possible and visible ? 226# ---------------------------------------------------------------------------- 227--error ER_PARSE_ERROR 228 229garbage ; 230let $mysql_errno= -1; 231eval select $mysql_errno as "after_let_errno_equal_value" ; 232 233# ---------------------------------------------------------------------------- 234# How affect actions on prepared statements $mysql_errno ? 235# ---------------------------------------------------------------------------- 236# failing prepare 237--error ER_PARSE_ERROR 238 239garbage ; 240--error ER_NO_SUCH_TABLE 241 242prepare stmt from "select 3 from t1" ; 243echo $mysql_errname; 244eval select $mysql_errno as "after_failing_prepare" ; 245create table t1 ( f1 char(10)); 246 247# successful prepare 248--error ER_PARSE_ERROR 249 250garbage ; 251prepare stmt from "select 3 from t1" ; 252echo $mysql_errname; 253eval select $mysql_errno as "after_successful_prepare" ; 254 255# successful execute 256--error ER_PARSE_ERROR 257 258garbage ; 259execute stmt; 260echo $mysql_errname; 261eval select $mysql_errno as "after_successful_execute" ; 262 263# failing execute (table has been dropped) 264drop table t1; 265--error ER_PARSE_ERROR 266 267garbage ; 268--error ER_NO_SUCH_TABLE 269 270execute stmt; 271echo $mysql_errname; 272eval select $mysql_errno as "after_failing_execute" ; 273 274# failing execute (unknown statement) 275--error ER_PARSE_ERROR 276 277garbage ; 278--error ER_UNKNOWN_STMT_HANDLER 279 280execute __stmt_; 281echo $mysql_errname; 282eval select $mysql_errno as "after_failing_execute" ; 283 284# successful deallocate 285--error ER_PARSE_ERROR 286 287garbage ; 288deallocate prepare stmt; 289echo $mysql_errname; 290eval select $mysql_errno as "after_successful_deallocate" ; 291 292# failing deallocate ( statement handle does not exist ) 293--error ER_PARSE_ERROR 294 295garbage ; 296--error ER_UNKNOWN_STMT_HANDLER 297 298deallocate prepare __stmt_; 299echo $mysql_errname; 300eval select $mysql_errno as "after_failing_deallocate" ; 301 302 303# ---------------------------------------------------------------------------- 304# test cases for "--disable_abort_on_error" 305# 306# "--disable_abort_on_error" switches off the abort of mysqltest 307# after "unmasked" failing statements. 308# 309# The default is "--enable_abort_on_error". 310# 311# "Maskings" are 312# --error <error number> and --error <error number> 313# in the line before the failing statement. 314# 315# There are some additional test cases for $mysql_errno 316# because "--disable_abort_on_error" enables a new situation. 317# Example: "unmasked" statement fails + analysis of $mysql_errno 318# ---------------------------------------------------------------------------- 319 320# ---------------------------------------------------------------------------- 321# Switch off the abort on error and check the effect on $mysql_errno 322# ---------------------------------------------------------------------------- 323--error ER_PARSE_ERROR 324 325garbage ; 326--disable_abort_on_error 327echo $mysql_errname; 328eval select $mysql_errno as "after_--disable_abort_on_error" ; 329 330# ---------------------------------------------------------------------------- 331# "unmasked" failing statement should not cause an abort 332# ---------------------------------------------------------------------------- 333select 3 from t1 ; 334 335# ---------------------------------------------------------------------------- 336# masked failing statements 337# ---------------------------------------------------------------------------- 338# expected error = response 339--error ER_NO_SUCH_TABLE 340 341select 3 from t1 ; 342--error ER_NO_SUCH_TABLE 343 344select 3 from t1 ; 345echo $mysql_errname; 346eval select $mysql_errno as "after_!errno_masked_error" ; 347# expected error <> response 348# --error 1000 349# select 3 from t1 ; 350# --error 1000 351# select 3 from t1 ; 352--error 1 353--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $MYSQL_TEST 2>&1 354 355# ---------------------------------------------------------------------------- 356# Check some non-query statements that would fail 357# ---------------------------------------------------------------------------- 358--exec illegal_command 359--cat_file does_not_exist 360--perl 361 exit(2); 362EOF 363 364# ---------------------------------------------------------------------------- 365# Check backtick and query_get_value, result should be empty 366# ---------------------------------------------------------------------------- 367let $empty= `garbage`; 368echo $empty is empty; 369let $empty= query_get_value(nonsense, blabla, 1); 370echo $empty is empty; 371 372# ---------------------------------------------------------------------------- 373# Switch the abort on error on and check the effect on $mysql_errno 374# ---------------------------------------------------------------------------- 375--error ER_PARSE_ERROR 376 377garbage ; 378--enable_abort_on_error 379echo $mysql_errname; 380eval select $mysql_errno as "after_--enable_abort_on_error" ; 381 382# ---------------------------------------------------------------------------- 383# masked failing statements 384# ---------------------------------------------------------------------------- 385# expected error = response 386--error ER_NO_SUCH_TABLE 387 388select 3 from t1 ; 389 390# ---------------------------------------------------------------------------- 391# check that the old default behaviour is not changed 392# Please remove the '#' to get the abort on error 393# ---------------------------------------------------------------------------- 394#--error 1064 395#select 3 from t1 ; 396# 397#select 3 from t1 ; 398 399--error 1 400--exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1 401 402# ---------------------------------------------------------------------------- 403# Test --enable and --disable with ONCE 404# ---------------------------------------------------------------------------- 405 406--disable_abort_on_error ONCE 407garbage; 408--disable_abort_on_error ONCE 409--remove_file $MYSQLTEST_VARDIR/DoesNotExist 410 411--disable_result_log 412select 2; 413--enable_result_log ONCE 414select 3; 415select 5; 416--enable_result_log 417 418# ---------------------------------------------------------------------------- 419# Test cumulative ONCE 420# ---------------------------------------------------------------------------- 421 422--disable_abort_on_error ONCE 423--disable_query_log ONCE 424select 3 from t1; 425select 7; 426 427--error 1 428--exec echo "--disable_info OCNE" | $MYSQL_TEST 2>&1 429 430connect (con1,localhost,root,,); 431connection default; 432disconnect con1; 433 434# ---------------------------------------------------------------------------- 435# Test ONCE can be combined with --error or modifiers like lowercase 436# ---------------------------------------------------------------------------- 437 438--disable_result_log ONCE 439--error ER_NO_SUCH_TABLE 440select 5 from t1; 441 442--disable_query_log ONCE 443--lowercase_result 444select "CASE" as "LOWER"; 445 446--sorted_result 447--disable_query_log ONCE 448select "xyz" as name union select "abc" as name order by name desc; 449 450# ---------------------------------------------------------------------------- 451# Test --error with backtick operator or query_get_value 452# ---------------------------------------------------------------------------- 453 454--error 0,ER_NO_SUCH_TABLE 455let $empty= `SELECT foo from bar`; 456echo $empty is empty; 457 458--error 0,ER_BAD_FIELD_ERROR 459let $empty= query_get_value(SELECT bar as foo, baz, 1); 460echo $empty is empty; 461 462--error 0,ER_NO_SUCH_TABLE 463if (!`SELECT foo from bar`) { 464 echo "Yes it's empty"; 465} 466 467# ---------------------------------------------------------------------------- 468# Test comments 469# ---------------------------------------------------------------------------- 470 471# This is a comment 472# This is a ; comment 473# This is a -- comment 474# -- This is also a comment 475# -- # This is also a comment 476# -- This is also a ; comment 477 478# ---------------------------------------------------------------------------- 479# Test comments with embedded command 480# ---------------------------------------------------------------------------- 481 482--echo hello 483-- echo hello 484-- echo ;;;;;;;; 485 486--echo # MySQL: -- The 487 488# ---------------------------------------------------------------------------- 489# Test detect end of line "junk" 490# Most likely caused by a missing delimiter 491# ---------------------------------------------------------------------------- 492 493# Too many parameters to function 494--error 1 495--exec echo "sleep 5 6;" | $MYSQL_TEST 2>&1 496 497# Too many parameters to function 498--error 1 499--exec echo "--sleep 5 6" | $MYSQL_TEST 2>&1 500 501# 502# Missing delimiter 503# The comment will be "sucked into" the sleep command since 504# delimiter is missing until after "show status" 505--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 506sleep 4 507# A comment 508show status; 509EOF 510--error 1 511--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 512remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 513 514# 515# Missing delimiter until eof 516# The comment will be "sucked into" the sleep command since 517# delimiter is missing 518--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 519sleep 7 520# Another comment 521EOF 522--error 1 523--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 524remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 525 526# 527# Missing delimiter until "disable_query_log" 528# 529--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 530disconnect default 531 532# 533# comment 534# comment 3 535disable_query_log; 536EOF 537--error 1 538--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 539remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 540 541# 542# Missing delimiter until "disable_query_log" 543# 544--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 545disconnect default 546 547# 548# comment 549 550# comment 3 551disable_query_log; 552EOF 553--error 1 554--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 555remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 556 557# 558# Missing delimiter until eof 559# 560--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 561disconnect default 562 563# 564# comment 565# comment2 566 567# comment 3 568--disable_query_log 569EOF 570--error 1 571--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 572remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 573 574# 575# Missing delimiter until eof 576# 577--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 578disconnect default # comment 579# comment part2 580 581# comment 3 582--disable_query_log 583EOF 584--error 1 585--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 586 587remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 588 589# 590# Extra delimiter 591# 592--error 1 593--exec echo "--sleep 4;" | $MYSQL_TEST 2>&1 594--error 1 595--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1 596 597# 598# Extra text after `` 599# 600# Cannot use exec echo here as ` may or may not need to be escaped 601--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 602let $x= `select 1` BOO ; 603EOF 604--error 1 605--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 606remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 607--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 608--let $x= `select 1`; 609EOF 610--error 1 611--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 612remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 613--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 614# Missing ; in next line should be detected and cause failure 615let $x= `select 1` 616let $x= 2; 617echo $x; 618EOF 619--error 1 620--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 621remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 622 623 624# Allow trailing # comment 625--sleep 1 # Wait for insert delayed to be executed. 626--sleep 1 # Wait for insert delayed to be executed. 627 628# ---------------------------------------------------------------------------- 629# Test error 630# ---------------------------------------------------------------------------- 631 632# Missing argument 633--error 1 634--exec echo "error;" | $MYSQL_TEST 2>&1 635--error 1 636--exec echo "--error" | $MYSQL_TEST 2>&1 637 638# First char must be uppercase 'S' or 'E' or [0-9] 639--error 1 640--exec echo "--error s99999" | $MYSQL_TEST 2>&1 641--error 1 642--exec echo "--error e99999" | $MYSQL_TEST 2>&1 643--error 1 644--exec echo "--error 9eeeee" | $MYSQL_TEST 2>&1 645--error 1 646--exec echo "--error 1sssss" | $MYSQL_TEST 2>&1 647 648# First char 'S' but too long 649--error 1 650--exec echo "--error S999999" | $MYSQL_TEST 2>&1 651 652# First char 'S' but lowercase char found 653--error 1 654--exec echo "--error S99a99" | $MYSQL_TEST 2>&1 655 656# First char 'S' but too short 657--error 1 658--exec echo "--error S9999" | $MYSQL_TEST 2>&1 659 660# First char 'E' but not found in error array 661--error 1 662--exec echo "--error E9999" | $MYSQL_TEST 2>&1 663 664# First char [0-9] but contains chars 665--error 1 666--exec echo "--error 999e9" | $MYSQL_TEST 2>&1 667--error 1 668--exec echo "--error 9b" | $MYSQL_TEST 2>&1 669 670# Multiple errorcodes separated by ',' 671--error 1,1,1,1 672#--error 9,ER_PARSE_ERROR 673#--error ER_PARSE_ERROR 674#--error 9,ER_PARSE_ERROR,9,ER_PARSE_ERROR 675#--error 9, ER_PARSE_ERROR, 9, ER_PARSE_ERROR 676#--error 9,S00000,9,ER_PARSE_ERROR 677#--error 9,S00000,9,ER_PARSE_ERROR,ER_PARSE_ERROR,ER_PARSE_ERROR,9,10,11,12 678--error 9,S00000,9 679--error 9,S00000,9,9,10,11,12 680--error 9 ,10 681--error 9 , 10 682--error 9 , 10 683--error 9 , 10 684 685# Too many errorcodes specified 686--error 1 687--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11,12,13" | $MYSQL_TEST 2>&1 688 689 690# ---------------------------------------------------------------------------- 691# Test echo command 692# ---------------------------------------------------------------------------- 693 694echo MySQL; 695echo "MySQL"; 696echo MySQL: The world''s most popular open source database; 697echo "MySQL: The world's most popular open source database"; 698 699echo MySQL: The world''s 700 most popular open 701 source database; 702 703echo # MySQL: The world''s 704# most popular open 705# source database; 706 707echo - MySQL: The world''s 708- most popular open 709- source database; 710 711echo - MySQL: The world''s 712-- most popular 713-- open source database; 714 715echo # MySQL: The 716--world''s 717# most popular 718-- open 719- source database; 720 721echo "MySQL: The world's most popular; open source database"; 722echo "MySQL: The world's most popular ; open source database"; 723echo "MySQL: The world's most popular ;open source database"; 724echo echo message echo message; 725 726 727echo ; 728 729# Illegal use of echo 730 731#--error 1 732#--exec echo "echo \$;" | $MYSQL_TEST 2>&1 733 734 735# ---------------------------------------------------------------------------- 736# Test exec command 737# ---------------------------------------------------------------------------- 738 739# Illegal use of exec 740--error 1 741--exec echo "--exec " | $MYSQL_TEST 2>&1 742 743# ---------------------------------------------------------------------------- 744# Test let command 745# ---------------------------------------------------------------------------- 746 747let $message=MySQL; 748echo $message; 749 750let $message="MySQL"; 751echo $message; 752 753let $message= MySQL: The 754 world''s most 755 popular open 756 source database; 757echo $message; 758 759let $message= # MySQL: The 760# world''s most 761# popular open 762# source database; 763echo $message; 764 765let $message= -- MySQL: The 766-- world''s most 767-- popular 768-- open source database; 769echo $message; 770 771let $message= # MySQL: The 772- world''s most 773-- popular open 774# source database; 775echo $message; 776 777echo '$message'; 778echo "$message"; 779 780let $1=hej; 781echo $1; 782 783let $1 =hej ; 784echo $1; 785 786let $1 = hej; 787echo $1; 788 789let $1=1; 790let $2=$1; 791echo $2; 792let $5=$6; 793echo $5; 794echo $6; 795 796let $where=a long variable content; 797echo $where; 798 799let $where2= $where; 800echo $where2; 801 802let $where3=a long $where variable content; 803echo $where3; 804 805let $where3=a long \\\$where variable content; 806echo $where3; 807 808let $novar1= $novar2; 809echo $novar1; 810 811let $cat=na; 812let $cat=ba$cat$cat; 813echo banana = $cat; 814 815# ba\$cat\$cat should have been sufficient. 816# ba\\\$cat\\\$cat -> ba\$cat\$cat -> ba$cat$cat -> banana 817# Magnus' upcoming patch will fix the missing second interpretation. 818let $cat=ba\\\$cat\\\$cat; 819echo Not a banana: $cat; 820 821# Bug #55413 would cause this to fail 822let $escape= with\`some\"escaped\'quotes; 823echo $escape; 824 825--let $escape= with\`some\"escaped\'quotes 826echo $escape; 827 828# This only works with "--let" syntax 829--let $tick= single'tick`backtick 830echo $tick; 831 832# Test illegal uses of let 833 834--error 1 835--exec echo "let ;" | $MYSQL_TEST 2>&1 836 837--error 1 838--exec echo "let \$=hi;" | $MYSQL_TEST 2>&1 839 840--error 1 841--exec echo "let \$1 hi;" | $MYSQL_TEST 2>&1 842 843--error 1 844--exec echo "let \$m hi;" | $MYSQL_TEST 2>&1 845 846--error 1 847--exec echo "let \$hi;" | $MYSQL_TEST 2>&1 848 849--error 1 850--exec echo "let \$ hi;" | $MYSQL_TEST 2>&1 851 852--error 1 853--exec echo "let =hi;" | $MYSQL_TEST 2>&1 854 855--error 1 856--exec echo "let hi;" | $MYSQL_TEST 2>&1 857 858# More advanced test for Bug#17280 859let $success= 1; 860--echo # Execute: --echo # <whatever> success: \$success 861--echo # <whatever> success: $success 862--echo # Execute: echo # <whatever> success: \$success ; 863echo # <whatever> success: $success ; 864 865--echo # The next two variants work fine and expand the content of \$success 866--echo # Execute: --echo \$success 867--echo $success 868--echo # Execute: echo \$success ; 869echo $success ; 870 871 872# ---------------------------------------------------------------------------- 873# Test to assign let from variable 874# let $<var_name>=$<var_name>; 875# ---------------------------------------------------------------------------- 876 877--echo # Check if let \$B = \$A is an assignment per value. 878 879# Basic preparations: 880--echo let \$A = initial value of A; 881let $A = initial value of A; 882# --echo # Content of \$A is: $A 883--echo let \$B = initial value of B; 884let $B = initial value of B; 885# --echo # Content of \$B is: $B 886 887# Assign $B to $A: 888--echo let \$B = \$A 889let $A = $B; 890--echo # Content of \$A is: $A 891 892# Changes of $B must NOT affect $A and Changes of $A must NOT affect $B ! 893--echo let \$A = changed value of A; 894let $A = changed value of A; 895--echo # Content of \$B is: $B 896 897--echo let \$B = changed value of B; 898let $B = changed value of B; 899--echo # Content of \$A is: $A 900 901# ---------------------------------------------------------------------------- 902# Test let from query with $variable 903# let $<var_name>=`<query with $variable>`; 904# ---------------------------------------------------------------------------- 905 906let $var1=content of variable 1; 907let $var2= `select "$var1"`; 908let $var3= `select concat("$var1", " ", "$var2")`; 909echo var2: $var2; 910echo var3: $var3; 911if (`select length("$var3") > 0`) 912{ 913 echo length of var3 is longer than 0; 914} 915 916# ---------------------------------------------------------------------------- 917# Test to assign let from query 918# let $<var_name>=`<query>`; 919# ---------------------------------------------------------------------------- 920echo var1; 921let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`; 922echo $var1; 923 924echo var2; 925let $var2= `select 2 as "Column num 2"`; 926echo $var2; 927 928echo var2 again; 929let $var2= `select 2 as "Column num 2"`; 930echo $var2; 931 932echo var3 two columns with same name; 933let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`; 934echo $var3; 935 936echo var4 from query that returns NULL; 937let $var4= `select NULL`; 938 939echo var5 from query that returns no row; 940let $var5= `SHOW VARIABLES LIKE "nonexisting_variable"`; 941 942echo failing query in let; 943--write_file $MYSQLTEST_VARDIR/tmp/let.sql 944let $var2= `failing query`; 945echo $var2; 946EOF 947 948create table t1 (a varchar(100)); 949insert into t1 values ('`select 42`'); 950let $a= `select * from t1`; 951# This should output `select 42`, not evaluate it again to 42 952echo $a; 953insert into t1 values ('$dollar'); 954# These should also output the string without evaluating it. 955let $a= query_get_value(select * from t1 order by a, a, 1); 956echo $a; 957let $a= query_get_value(select * from t1 order by a, a, 2); 958echo $a; 959drop table t1; 960 961--error 1 962--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1 963 964remove_file $MYSQLTEST_VARDIR/tmp/let.sql; 965 966 967# ---------------------------------------------------------------------------- 968# Test source command 969# ---------------------------------------------------------------------------- 970 971# Test illegal uses of source 972 973--error 1 974--exec echo "source ;" | $MYSQL_TEST 2>&1 975 976# Fix win paths 977--replace_result \\ / 978# Source a nonexisting file 979--error 1 980--exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1 981 982# Too many source 983--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql 984--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 985--error 1 986--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $MYSQL_TEST 2>&1 987remove_file $MYSQLTEST_VARDIR/tmp/recursive.sql; 988 989# Source a file with error 990--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql 991--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 992--error 1 993--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $MYSQL_TEST 2>&1 994 995remove_file $MYSQLTEST_VARDIR/tmp/error.sql; 996 997# Test execution of source in a while loop 998--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc 999echo here is the sourced script; 1000EOF 1001--disable_query_log 1002let $outer= 2; # Number of outer loops 1003while ($outer) 1004{ 1005 eval SELECT '$outer = outer loop variable after while' AS ""; 1006 1007 --source $MYSQLTEST_VARDIR/tmp/sourced.inc 1008 1009 eval SELECT '$outer = outer loop variable before dec' AS ""; 1010 dec $outer; 1011 eval SELECT '$outer = outer loop variable after dec' AS ""; 1012} 1013 1014# Test source in an if in a while which is false on 1st iteration 1015# Also test --error and --disable_abort_on_error in same context 1016let $outer= 2; # Number of outer loops 1017let $ifval= 0; # false 1st time 1018while ($outer) 1019{ 1020 echo outer=$outer ifval=$ifval; 1021 1022 if ($ifval) { 1023 --source $MYSQLTEST_VARDIR/tmp/sourced.inc 1024 --error ER_NO_SUCH_TABLE 1025 SELECT * from nowhere; 1026 --disable_abort_on_error ONCE 1027# Statement giving a different error, to make sure we don't mask it 1028 SELECT * FROM nowhere else; 1029 } 1030 dec $outer; 1031 inc $ifval; 1032} 1033 1034 1035# Test execution of source in a while loop 1036--disable_abort_on_error 1037# Sourcing of a file within while loop, sourced file will 1038# source other file 1039let $num= 9; 1040while ($num) 1041{ 1042 SELECT 'In loop' AS ""; 1043 --source $MYSQLTEST_VARDIR/tmp/sourced.inc 1044 dec $num; 1045} 1046--enable_abort_on_error 1047--enable_query_log 1048 1049# Test source $variable/<filename> 1050--source $MYSQLTEST_VARDIR/tmp/sourced.inc 1051 1052--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc 1053 1054--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc 1055echo "hello"; 1056EOF 1057 1058let $x= sourced; 1059source $MYSQLTEST_VARDIR/tmp/$x.inc; 1060 1061let $x= $MYSQLTEST_VARDIR; 1062source $x/tmp/sourced.inc; 1063 1064--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc 1065 1066 1067# ---------------------------------------------------------------------------- 1068# Test sleep command 1069# ---------------------------------------------------------------------------- 1070 1071sleep 0.5; 1072sleep 1; 1073real_sleep 1; 1074 1075# Parameter from variable, legal and illegal 1076let $sleep_var= 0.1; 1077sleep $sleep_var; 1078let $sleep_var= 1; 1079--real_sleep $sleep_var 1080 1081--write_file $MYSQL_TMP_DIR/sleep.inc 1082let $sleep_var= xyz; 1083--sleep $sleep_var 1084EOF 1085--error 1 1086--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1 1087--remove_file $MYSQL_TMP_DIR/sleep.inc 1088 1089--write_file $MYSQL_TMP_DIR/sleep.inc 1090let $sleep_var= xyz; 1091real_sleep $sleep_var; 1092EOF 1093--error 1 1094--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1 1095--remove_file $MYSQL_TMP_DIR/sleep.inc 1096 1097# Missing parameter 1098--error 1 1099--exec echo "sleep ;" | $MYSQL_TEST 2>&1 1100--error 1 1101--exec echo "real_sleep ;" | $MYSQL_TEST 2>&1 1102 1103# Illegal parameter 1104--error 1 1105--exec echo "sleep abc;" | $MYSQL_TEST 2>&1 1106--error 1 1107--exec echo "real_sleep abc;" | $MYSQL_TEST 2>&1 1108 1109# ---------------------------------------------------------------------------- 1110# Test inc 1111# ---------------------------------------------------------------------------- 1112let $i= 0; 1113inc $i; 1114echo $i; 1115let $i=100; 1116inc $i; 1117echo $i; 1118let $i= -100; 1119inc $i; 1120echo $i; 1121 1122--error 1 1123--exec echo "inc;" | $MYSQL_TEST 2>&1 1124--error 1 1125--exec echo "inc i;" | $MYSQL_TEST 2>&1 1126--error 1 1127--exec echo "inc \$i;" | $MYSQL_TEST 2>&1 1128--error 1 1129--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1 1130--error 1 1131--exec echo "let \$i=text; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1 1132--error 1 1133--exec echo "let \$i=10cc; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1 1134 1135inc $i; inc $i; inc $i; --echo $i 1136echo $i; 1137 1138 1139# ---------------------------------------------------------------------------- 1140# Test dec 1141# ---------------------------------------------------------------------------- 1142 1143let $d= 0; 1144dec $d; 1145echo $d; 1146let $d=100; 1147dec $d; 1148echo $d; 1149 1150--error 1 1151--exec echo "dec;" | $MYSQL_TEST 2>&1 1152--error 1 1153--exec echo "dec i;" | $MYSQL_TEST 2>&1 1154--error 1 1155--exec echo "dec \$i;" | $MYSQL_TEST 2>&1 1156--error 1 1157--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1 1158--error 1 1159--exec echo "let \$i=text; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1 1160--error 1 1161--exec echo "let \$i=10cc; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1 1162 1163 1164# ---------------------------------------------------------------------------- 1165# Test system 1166# ---------------------------------------------------------------------------- 1167#system ls > /dev/null; 1168system echo "hej" > /dev/null; 1169#--system ls > /dev/null 1170--system echo "hej" > /dev/null; 1171 1172--error 1 1173--exec echo "system;" | $MYSQL_TEST 2>&1 1174--error 1 1175--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1 1176 1177--disable_abort_on_error ONCE 1178system NonExistsinfComamdn 2> /dev/null; 1179 1180 1181# ---------------------------------------------------------------------------- 1182# Test delimiter 1183# ---------------------------------------------------------------------------- 1184 1185delimiter stop; 1186echo teststop 1187delimiter ;stop 1188echo test2; 1189--delimiter stop 1190echo test3stop 1191--delimiter ; 1192echo test4; 1193 1194# ---------------------------------------------------------------------------- 1195# Test that delimiter within if() works in in various combinations 1196# ---------------------------------------------------------------------------- 1197 1198if (0) 1199{ 1200 delimiter ||; 1201 echo false-inner|| 1202 if (0) 1203 { 1204 delimiter *|| 1205 echo false-innerer* 1206 delimiter ||* 1207 } 1208 echo false-inner again|| 1209} 1210echo outer; 1211if (1) 1212{ 1213 delimiter /; 1214 echo true-inner/ 1215 if (0) 1216 { 1217 delimiter %/ 1218 echo true-innerer% 1219 } 1220 echo true-inner again/ 1221} 1222echo true-outer/ 1223delimiter ;/ 1224 1225 1226# ---------------------------------------------------------------------------- 1227# Test if 1228# ---------------------------------------------------------------------------- 1229 1230let $counter=10; 1231if ($counter) 1232{ 1233 echo Counter is greater than 0, (counter=10); 1234} 1235if (!$counter) 1236{ 1237 echo Counter is not 0, (counter=10); 1238} 1239if (! $counter) 1240{ 1241 let $counter=5; 1242} 1243echo Counter should still be 10, is $counter; 1244let $counter=0; 1245if($counter) 1246{ 1247 echo Counter is greater than 0, (counter=0); 1248} 1249if (!$counter) 1250{ 1251 echo Counter is not 0, (counter=0); 1252} 1253if (! $counter) 1254{ 1255 echo Not space var works; 1256} 1257 1258# ---------------------------------------------------------------------------- 1259# Test if with some non-numerics 1260# ---------------------------------------------------------------------------- 1261 1262let $counter=alpha; 1263if ($counter) 1264{ 1265 echo Counter is true, (counter=alpha); 1266} 1267let $counter= ; 1268if ($counter) 1269{ 1270 echo oops, space is true; 1271} 1272let $counter=-0; 1273if ($counter) 1274{ 1275 echo oops, -0 is true; 1276} 1277# This is no longer allowed, as a precaution against mistyped conditionals 1278# if (beta) 1279# { 1280# echo Beta is true; 1281# } 1282let $counter=gamma; 1283while ($counter) 1284{ 1285 echo while with string, only once; 1286 let $counter=000; 1287} 1288 1289# ---------------------------------------------------------------------------- 1290# Test if with compare conditions 1291# ---------------------------------------------------------------------------- 1292 1293let $ifvar= 5; 1294let $ifvar2= 6; 1295 1296if ($ifvar < 7) 1297{ 1298 echo 5<7; 1299} 1300if ($ifvar< 7) 1301{ 1302 echo 5<7 again; 1303} 1304if ($ifvar<7) 1305{ 1306 echo 5<7 still; 1307} 1308if ($ifvar < $ifvar2) 1309{ 1310 echo 5<6; 1311} 1312if ($ifvar <= 4) 1313{ 1314 echo 5<=4; 1315} 1316if ($ifvar >= 5) 1317{ 1318 echo 5>=5; 1319} 1320if ($ifvar>=5) 1321{ 1322 echo 5>=5 again; 1323} 1324if ($ifvar > 3) 1325{ 1326 echo 5>3; 1327} 1328if ($ifvar == 4) 1329{ 1330 echo 5==4; 1331} 1332if ($ifvar == 5) 1333{ 1334 echo 5==5; 1335} 1336if ($ifvar != 8) 1337{ 1338 echo 5!=8; 1339} 1340# Any number should compare unequal to any string 1341if ($ifvar != five) 1342{ 1343 echo 5!=five; 1344} 1345if ($ifvar == `SELECT 3+2`) 1346{ 1347 echo 5==3+2; 1348} 1349if ($ifvar == 5) 1350{ 1351 echo 5 == 5; 1352} 1353let $ifvar= hello; 1354if ($ifvar == hello there) 1355{ 1356 echo hello == hello there; 1357} 1358if ($ifvar == hello) 1359{ 1360 echo hello == hello; 1361} 1362if ($ifvar == hell) 1363{ 1364 echo hello == hell; 1365} 1366if ($ifvar == hello) 1367{ 1368 echo hello == hello; 1369} 1370if ($ifvar != goodbye) 1371{ 1372 echo hello != goodbye; 1373} 1374let $ifvar= 'quoted'; 1375if ($ifvar == ''quoted'') 1376{ 1377 echo 'quoted' == ''quoted''; 1378} 1379let $ifvar= two words; 1380if ($ifvar == two words) 1381{ 1382 echo two words; 1383} 1384if ($ifvar == 'two words') 1385{ 1386 echo 'two words'; 1387} 1388if ($ifvar == "two words") 1389{ 1390 echo "two words"; 1391} 1392if ($ifvar == `SELECT 'two words'`) 1393{ 1394 echo two words are two words; 1395} 1396if (42) 1397{ 1398 echo right answer; 1399} 1400if (0) 1401{ 1402 echo wrong answer; 1403} 1404# Non-empty string treated as 'true' 1405if (`SELECT 'something'`) 1406{ 1407 echo anything goes; 1408} 1409# Make sure 0 and string compare right 1410let $ifvar= 0; 1411if ($ifvar == string) 1412{ 1413 echo 0 == string; 1414} 1415if ($ifvar != string) 1416{ 1417 echo 0 != string; 1418} 1419--write_file $MYSQL_TMP_DIR/mysqltest.sql 1420let $var= 5; 1421if ($var >= four) 1422{ 1423 echo 5>=four; 1424} 1425EOF 1426--error 1 1427--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 1428remove_file $MYSQL_TMP_DIR/mysqltest.sql; 1429 1430--write_file $MYSQL_TMP_DIR/mysqltest.sql 1431let $var= 5; 1432if ($var ~= 6) 1433{ 1434 echo 5~=6; 1435} 1436EOF 1437--error 1 1438--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 1439remove_file $MYSQL_TMP_DIR/mysqltest.sql; 1440 1441--write_file $MYSQL_TMP_DIR/mysqltest.sql 1442let $var= text; 1443if (var == text) 1444{ 1445 echo Oops I forgot the $; 1446} 1447EOF 1448--error 1 1449--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 1450remove_file $MYSQL_TMP_DIR/mysqltest.sql; 1451 1452--error 1 1453--exec echo "if (\$var ==) {" | $MYSQL_TEST 2>&1 1454--error 1 1455--exec echo "if (\$var > ) {" | $MYSQL_TEST 2>&1 1456 1457# ---------------------------------------------------------------------------- 1458# Test while with compare conditions 1459# ---------------------------------------------------------------------------- 1460 1461let $counter= 2; 1462 1463while ($counter < 5) 1464{ 1465 echo counter is $counter; 1466 inc $counter; 1467} 1468let $ifvar=; 1469while ($ifvar != stop) 1470{ 1471 if ($counter >= 7) 1472 { 1473 let $ifvar= stop; 1474 } 1475 echo counter is $counter; 1476 inc $counter; 1477} 1478 1479# ---------------------------------------------------------------------------- 1480# Test while, { and } 1481# ---------------------------------------------------------------------------- 1482 1483let $i=1; 1484while ($i) 1485{ 1486 echo $i; 1487 dec $i; 1488} 1489# One liner 1490#let $i=1;while ($i){echo $i;dec $i;} 1491 1492let $i=0; 1493while (!$i) 1494{ 1495 echo Testing while with not; 1496 inc $i; 1497} 1498 1499# Exceed max nesting level 1500--write_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc 1501let $1 = 10; 1502while ($1) 1503{ 1504while ($1) 1505{ 1506while ($1) 1507{ 1508 while ($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 echo $1; 1601 dec $1; 1602} 1603} 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} 1638EOF 1639# Fix win path 1640--replace_result \\ / $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 1641--error 1 1642--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc;" | $MYSQL_TEST 2>&1 1643--remove_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc 1644--error 1 1645--exec echo "while \$i;" | $MYSQL_TEST 2>&1 1646--error 1 1647--exec echo "while (\$i;" | $MYSQL_TEST 2>&1 1648--error 1 1649--exec echo "let \$i=1; while (\$i) dec \$i;" | $MYSQL_TEST 2>&1 1650--error 1 1651--exec echo "};" | $MYSQL_TEST 2>&1 1652--error 1 1653--exec echo "end;" | $MYSQL_TEST 2>&1 1654--error 1 1655--exec echo "{;" | $MYSQL_TEST 2>&1 1656 1657--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1658while (0) 1659echo hej; 1660EOF 1661--error 1 1662--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 1663remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1664 1665--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1666while (0) 1667{echo hej; 1668EOF 1669--error 1 1670--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 1671remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1672 1673--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1674while (0){ 1675 echo hej; 1676EOF 1677--error 1 1678--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 1679 1680remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; 1681 1682# ---------------------------------------------------------------------------- 1683# Test error messages returned from comments starting with a command 1684# ---------------------------------------------------------------------------- 1685--error 1 1686--exec echo "--if the other server is down" | $MYSQL_TEST 2>&1 1687 1688--error 1 1689--exec echo "-- end when ..." | $MYSQL_TEST 2>&1 1690 1691# ---------------------------------------------------------------------------- 1692# Test replace 1693# ---------------------------------------------------------------------------- 1694--replace_result a b 1695select "a" as col1, "c" as col2; 1696 1697--replace_result a b c d 1698select "a" as col1, "c" as col2; 1699 1700--error 1 1701--exec echo "--replace_result a" | $MYSQL_TEST 2>&1 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--exec echo "replace_result a b; echo OK; exit;" | $MYSQL_TEST 2>&1 1709--error 1 1710--exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1 1711--error 1 1712--exec echo "replace_result a b c ;" | $MYSQL_TEST 2>&1 1713 1714 1715--replace_column 1 b 1716select "a" as col1, "c" as col2; 1717 1718--replace_column 1 b 2 d 1719select "a" as col1, "c" as col2; 1720 1721--error 1 1722--exec echo "--replace_column a" | $MYSQL_TEST 2>&1 1723 1724--error 1 1725--exec echo "--replace_column 1" | $MYSQL_TEST 2>&1 1726 1727--error 1 1728--exec echo "--replace_column a b" | $MYSQL_TEST 2>&1 1729--error 1 1730--exec echo "--replace_column a 1" | $MYSQL_TEST 2>&1 1731--error 1 1732--exec echo "--replace_column 1 b c " | $MYSQL_TEST 2>&1 1733 1734let $long_rep= 1234567890123456789012345678901234567890; 1735let $long_rep= $long_rep,$long_rep; 1736let $long_rep= $long_rep,$long_rep; 1737let $long_rep= $long_rep,$long_rep; 1738let $long_rep= $long_rep,$long_rep; 1739let $long_rep= $long_rep,$long_rep; 1740 1741# This tests from strings > 1024 (here 1311) 1742 1743--replace_result $long_rep LONG_STRING 1744eval select "$long_rep" as x; 1745 1746# Test replace within `` 1747 1748--replace_result cat dog 1749--let $animal= `select "cat" as pet` 1750--echo $animal 1751 1752# ---------------------------------------------------------------------------- 1753# Test sync_with_master 1754# ---------------------------------------------------------------------------- 1755--error 1 1756--exec echo "sync_with_master 10!;" | $MYSQL_TEST 2>&1 1757--error 1 1758--exec echo "sync_with_master a;" | $MYSQL_TEST 2>&1 1759 1760# ---------------------------------------------------------------------------- 1761# Test connect 1762# ---------------------------------------------------------------------------- 1763 1764--error 1 1765--exec echo "connect;" | $MYSQL_TEST 2>&1 1766--error 1 1767--exec echo "connect ();" | $MYSQL_TEST 2>&1 1768--error 1 1769--exec echo "connect (con2);" | $MYSQL_TEST 2>&1 1770--error 1 1771--exec echo "connect (con2,);" | $MYSQL_TEST 2>&1 1772--error 1 1773--exec echo "connect (con2,localhost,root,,illegal_db);" | $MYSQL_TEST 2>&1 1774--error 1 1775--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $MYSQL_TEST 2>&1 1776--error 1 1777--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1 1778 1779# Repeat connect/disconnect 1780--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql 1781let $i=200; 1782disable_connect_log; 1783while ($i) 1784{ 1785 connect (test_con1,localhost,root,,); 1786 disconnect test_con1; 1787 dec $i; 1788} 1789enable_connect_log; 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 1833connect (con1,localhost,root,,); 1834connection default; 1835connection con1; 1836--disable_query_log 1837# These should not be logged 1838connect (con2,localhost,root,,*NO-ONE*); 1839connection con2; 1840disconnect con2; 1841connection con1; 1842--enable_query_log 1843disconnect con1; 1844connection default; 1845 1846# ---------------------------------------------------------------------------- 1847# Test mysqltest arguments 1848# ---------------------------------------------------------------------------- 1849 1850# -x <file_name>, use the file specified after -x as the test file 1851--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc 1852--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc 1853--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc 1854# Fix Win paths 1855--replace_result \\ / 1856--error 1 1857--exec $MYSQL_TEST -x non_existing_file.inc 2>&1 1858 1859 1860# ---------------------------------------------------------------------------- 1861# TODO Test queries, especially their errormessages... so it's easy to debug 1862# new scripts and diagnose errors 1863# ---------------------------------------------------------------------------- 1864 1865# ---------------------------------------------------------------------------- 1866# Test Bug#12386 1867# ---------------------------------------------------------------------------- 1868let $num= 2; 1869while ($num) 1870{ 1871 --error ER_PARSE_ERROR 1872 1873 failing_statement; 1874 1875 dec $num; 1876} 1877 1878SELECT 1 as a; 1879 1880 1881# 1882# Bug#10251 Identifiers containing quotes not handled correctly 1883# 1884select 1 as `a'b`, 2 as `a"b`; 1885 1886# Test escaping of quotes 1887select 'aaa\\','aa''a',"aa""a"; 1888 1889# 1890# Check of include/show_msg.inc and include/show_msg80.inc 1891# 1892 1893# The message contains in most cases a string with the default character set 1894let $message= Here comes a message; 1895--source include/show_msg.inc 1896 1897# The message could also contain a string with character set utf8 1898let $message= `SELECT USER()`; 1899--source include/show_msg.inc 1900 1901# The message contains more then 80 characters on multiple lines 1902# and is kept between double quotes. 1903let $message= 1904"Here comes a very very long message that 1905 - is longer then 80 characters and 1906 - consists of several lines"; 1907--source include/show_msg80.inc 1908 1909# The message contains more then 80 characters on multiple lines 1910# and uses the auxiliary character "." at the beginning of the message lines. 1911let $message= . Here comes a very very long message that 1912 . - is longer then 80 characters and 1913 . - consists of several lines; 1914--source include/show_msg80.inc 1915 1916# 1917# Test --enable_parsing / disable_parsing 1918# 1919--disable_query_log 1920--disable_parsing 1921# The following will not enable query logging 1922--enable_query_log 1923select "this will not be executed"; 1924--enable_parsing 1925select "this will be executed"; 1926--enable_query_log 1927 1928# 1929# Test zero length result file. Should not pass 1930# 1931--exec echo '' > $MYSQLTEST_VARDIR/tmp/zero_length_file.result 1932--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql 1933--error 1 1934--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1 1935 1936remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result; 1937--disable_warnings 1938--error 0,1 1939remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject; 1940--error 0,1 1941remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.log; 1942--enable_warnings 1943 1944# 1945# Test that a test file that does not generate any output fails. 1946# 1947--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql 1948--error 1 1949--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1 1950 1951remove_file $MYSQLTEST_VARDIR/tmp/query.sql; 1952 1953# 1954# Test that mysqltest fails when there are no queries executed 1955# but a result file exists 1956# NOTE! This will never happen as long as it's not allowed to have 1957# test files that produce no output 1958#--exec echo "something" > $MYSQLTEST_VARDIR/tmp/result_file.result 1959#--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql 1960#--error 1 1961#--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1 1962 1963# 1964# Bug#11731 mysqltest in multi-statement queries ignores errors in 1965# non-1st queries 1966# 1967 1968echo Failing multi statement query; 1969# PS does not support multi statement 1970--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql 1971--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1972--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1973--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1974--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1975--exec echo "insertz 'error query'||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1976--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1977 1978--error 1 1979--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1 1980drop table t1; 1981 1982--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 1983--error 1 1984--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1 1985# The .out file should be non existent 1986--error 1 1987--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out 1988drop table t1; 1989 1990 1991echo Multi statement using expected error; 1992# PS does not support multi statement 1993--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql 1994--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1995--exec echo "--error 1064" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1996--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1997--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1998--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 1999--exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 2000--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 2001--exec echo "exit;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql 2002 2003# These two should work since the error is expected 2004--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1 2005drop table t1; 2006 2007--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1 2008# The .out file should exist 2009--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out 2010drop table t1; 2011remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out; 2012remove_file $MYSQLTEST_VARDIR/log/bug11731.log; 2013remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql; 2014 2015# 2016# Bug#19890 mysqltest "query" command is broken 2017# 2018 2019# It should be possible to use the command "query" to force mysqltest to 2020# send the command to the server although it's a builtin mysqltest command. 2021--error ER_PARSE_ERROR 2022 2023query sleep; 2024 2025--error ER_PARSE_ERROR 2026 2027--query sleep 2028 2029# Just an empty query command 2030--error ER_EMPTY_QUERY 2031 2032query ; 2033 2034# test for replace_regex 2035--replace_regex /at/b/ 2036select "at" as col1, "c" as col2; 2037 2038--replace_regex /at/b/i 2039select "at" as col1, "AT" as col2, "c" as col3; 2040 2041--replace_regex /a/b/ /ct/d/ 2042select "a" as col1, "ct" as col2; 2043 2044--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/ 2045select "strawberry","blueberry","potato"; 2046 2047--error 1 2048--exec echo "--replace_regex a" | $MYSQL_TEST 2>&1 2049--error 1 2050--exec echo "--replace_regex a;" | $MYSQL_TEST 2>&1 2051--error 1 2052--exec echo "replace_regex a;" | $MYSQL_TEST 2>&1 2053--error 1 2054--exec echo "replace_regex a ;" | $MYSQL_TEST 2>&1 2055--error 1 2056--exec echo "replace_regex a b; echo OK;" | $MYSQL_TEST 2>&1 2057--error 1 2058--exec echo "--replace_regex /a b c" | $MYSQL_TEST 2>&1 2059--error 1 2060--exec echo "replace_regex /a /b c ;" | $MYSQL_TEST 2>&1 2061 2062# REQUIREMENT 2063# replace_regex should replace substitutions from left to right in output 2064 2065create table t1 (a int, b int); 2066insert into t1 values (1,3); 2067insert into t1 values (2,4); 2068--replace_regex /A/C/ /B/D/i /3/2/ /2/1/ 2069select * from t1; 2070drop table t1; 2071 2072# Test usage with `` 2073 2074--replace_regex /x/y/ 2075--let $result= `select "x" as col` 2076--echo $result 2077 2078# Test usage with a variable as pattern list 2079 2080--disable_query_log 2081--let $patt= /a /b / /less/more/ 2082--replace_regex $patt 2083select "a is a and less is more" as txt; 2084--replace_regex $patt /and /or / 2085select "a is a and less is more" as txt2; 2086--let $patt= 2087--replace_regex $patt 2088select "a is a and less is more" as txt3; 2089--enable_query_log 2090 2091# 2092# different delimiters 2093# 2094--replace_regex (a)[b] /c/d/ <e>{f}i {g\/\}}/h/ 2095select 'ABCDEF abcdef g/}' as txt; 2096 2097#------------------------------------------------------------------------- 2098# BUG #11754855 : Passing variable to --error 2099#------------------------------------------------------------------------- 2100create table t2 ( a char(10)); 2101let $errno1=0; 2102let $errno2=ER_PARSE_ERROR; 2103let $errno3=ER_NO_SUCH_TABLE; 2104--error $errno2 2105garbage; 2106 2107--error $errno2,$errno3 2108garbage; 2109 2110--error $errno2,ER_NO_SUCH_TABLE 2111garbage; 2112 2113--error ER_NO_SUCH_TABLE,$errno2 2114insert into t1 values ("Abcd"); 2115 2116--error $errno1,ER_PARSE_ERROR 2117garbage; 2118 2119let $errno_multi = $errno1,ER_NO_SUCH_TABLE,$errno2,1062; 2120 2121--error $errno_multi 2122SELECT * FROM non_existing_table; 2123 2124drop table t2; 2125 2126 2127# ---------------------------------------------------------------------------- 2128# Tests of send 2129# ---------------------------------------------------------------------------- 2130 2131create table t1 ( f1 char(10)); 2132insert into t1 values ("Abcd"); 2133 2134# 1. Basic test 2135 2136send select * from t1; 2137reap; 2138 2139# 2. Test with error 2140 2141--send select * from t2; 2142--error ER_NO_SUCH_TABLE 2143--reap 2144 2145# 3. test send of next stmt 2146 2147--send 2148select * from t1; 2149--reap 2150 2151# 4. Non-query stmt betwen send and reap allowed 2152 2153--send select * from t1; 2154--sleep 0.05 2155--echo Result coming up 2156--reap 2157 2158# 5. Test of send_eval 2159 2160--let $my_stmt= select * from t1; 2161--send_eval $my_stmt 2162--reap 2163 2164# 6. Test that mysqltest does not allow query stmt between send and reap 2165# Untestable directly as it causes mysqltest to fail 2166 2167--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.in 2168--send select * from t1; 2169select 1; 2170--reap 2171EOF 2172--error 1 2173# Must filter unpredictable extra warning from output 2174--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.in > $MYSQL_TMP_DIR/mysqltest.out 2>&1 2175--perl 2176 my $dir= $ENV{'MYSQL_TMP_DIR'}; 2177 open (FILE, "$dir/mysqltest.out"); 2178 while (<FILE>) { 2179 print unless /Note: net_clear/; # This shows up on rare occations 2180 } 2181EOF 2182remove_file $MYSQL_TMP_DIR/mysqltest.out; 2183remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.in; 2184 2185drop table t1; 2186 2187# ---------------------------------------------------------------------------- 2188# test for remove_file 2189# ---------------------------------------------------------------------------- 2190 2191--disable_warnings 2192--error 1 2193--exec echo "remove_file ;" | $MYSQL_TEST 2>&1 2194 2195--error 1 2196remove_file $MYSQLTEST_VARDIR/non_existing_file; 2197--enable_warnings 2198 2199# ---------------------------------------------------------------------------- 2200# test for remove_files_wildcard 2201# ---------------------------------------------------------------------------- 2202 2203--error 1 2204--exec echo "remove_files_wildcard ;" | $MYSQL_TEST 2>&1 2205 2206--error 1 2207remove_files_wildcard $MYSQLTEST_VARDIR/non_existing_dir; 2208 2209--error 1 2210remove_files_wildcard $MYSQLTEST_VARDIR/non_existing_dir non_existing_file; 2211 2212# ---------------------------------------------------------------------------- 2213# test for write_file 2214# ---------------------------------------------------------------------------- 2215--error 1 2216--exec echo "write_file ;" | $MYSQL_TEST 2>&1 2217 2218--error 1 2219--exec echo "write_file $MYSQLTEST_VARDIR/filename ;" | $MYSQL_TEST 2>&1 2220 2221# Comment out this test as it confuses cmd.exe with unmatched " 2222#--error 1 2223#--exec echo "write_file filename \";" | $MYSQL_TEST 2>&1 2224 2225write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2226Content for test_file1 2227EOF 2228file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2229cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2230remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2231 2232write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER; 2233Content for test_file1 contains EOF 2234END_DELIMITER 2235file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2236 2237# write to already existing file 2238--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR 2239--error 1 2240--exec echo "write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;" | $MYSQL_TEST 2>&1 2241 2242remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2243 2244# ---------------------------------------------------------------------------- 2245# test for append_file 2246# ---------------------------------------------------------------------------- 2247 2248write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2249Content for test_file1 2250EOF 2251file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2252 2253append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2254Appended text 2255EOF 2256file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2257 2258remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2259append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2260Appended text on nonexisting file 2261EOF 2262 2263remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2264 2265# Test append_file within while 2266let $outer= 2; # Number of outer loops 2267while ($outer) 2268{ 2269 append_file $MYSQLTEST_VARDIR/tmp/app_while.tmp; 2270These lines should be repeated, 2271if things work as expected 2272EOF 2273 dec $outer; 2274} 2275 2276cat_file $MYSQLTEST_VARDIR/tmp/app_while.tmp; 2277remove_file $MYSQLTEST_VARDIR/tmp/app_while.tmp; 2278 2279# ---------------------------------------------------------------------------- 2280# test for cat_file 2281# ---------------------------------------------------------------------------- 2282 2283--write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp 2284Some data 2285for cat_file command 2286of mysqltest 2287EOF 2288cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2289remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2290 2291--replace_regex /my_errno=[0-9]*/(my_errno)/ 2292--error 1 2293--exec echo "cat_file non_existing_file;" | $MYSQL_TEST 2>&1 2294 2295# ---------------------------------------------------------------------------- 2296# test for diff_files 2297# ---------------------------------------------------------------------------- 2298 2299--write_file $MYSQLTEST_VARDIR/tmp/diff1.tmp 2300Some data 2301for diff_file command 2302of mysqltest 2303EOF 2304 2305--write_file $MYSQLTEST_VARDIR/tmp/diff2.tmp 2306Some data 2307for diff_file command 2308of mysqltest 2309EOF 2310 2311--write_file $MYSQLTEST_VARDIR/tmp/diff3.tmp 2312Some other data 2313for diff_file command 2314of mysqltest 2315EOF 2316 2317--write_file $MYSQLTEST_VARDIR/tmp/diff4.tmp 2318Some data 2319for diff_file command 2320of musqltest 2321EOF 2322 2323# Compare equal files 2324--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp 2325--diff_files $MYSQLTEST_VARDIR/tmp/diff2.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp 2326 2327# Compare files that differ in size 2328--error 2 2329--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp 2330--error 2 2331--diff_files $MYSQLTEST_VARDIR/tmp/diff3.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp 2332 2333# Compare files that differ only in content 2334--error 1 2335--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff4.tmp 2336--error 1 2337--diff_files $MYSQLTEST_VARDIR/tmp/diff4.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp 2338 2339# Compare equal files, again... 2340--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp 2341 2342--remove_file $MYSQLTEST_VARDIR/tmp/diff1.tmp 2343--remove_file $MYSQLTEST_VARDIR/tmp/diff2.tmp 2344--remove_file $MYSQLTEST_VARDIR/tmp/diff3.tmp 2345--remove_file $MYSQLTEST_VARDIR/tmp/diff4.tmp 2346 2347 2348# ---------------------------------------------------------------------------- 2349# test for file_exist 2350# ---------------------------------------------------------------------------- 2351--error 1 2352--exec echo "file_exists ;" | $MYSQL_TEST 2>&1 2353 2354--disable_warnings 2355--error 0,1 2356remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2357--enable_warnings 2358--error 1 2359file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2360write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2361Content for test_file1 2362EOF 2363file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2364remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2365--error 1 2366file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; 2367 2368 2369# ---------------------------------------------------------------------------- 2370# test for copy_file 2371# ---------------------------------------------------------------------------- 2372--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp 2373file1 2374EOF 2375 2376copy_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; 2377file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; 2378remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp; 2379remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; 2380 2381--error 1 2382--exec echo "copy_file ;" | $MYSQL_TEST 2>&1 2383 2384--error 1 2385--exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1 2386 2387 2388# ---------------------------------------------------------------------------- 2389# test for move_file 2390# ---------------------------------------------------------------------------- 2391 2392# - Check that if source file does not exist, nothing will be created. 2393 2394--disable_warnings 2395--error 1 2396file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; 2397--error 1 2398file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; 2399--error 1 2400move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; 2401--error 1 2402file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; 2403--error 1 2404file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; 2405--enable_warnings 2406 2407# - Check that if source file exists, everything works properly. 2408 2409--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp 2410file1 2411EOF 2412 2413move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; 2414--error 1 2415file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; 2416file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; 2417 2418# - Check that if destination file exists, everything works properly. 2419# (file2.tmp exists from the previous check; file1.tmp needs to be created) 2420 2421--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp 2422file1 2423EOF 2424 2425move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; 2426--error 1 2427file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; 2428file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; 2429remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; 2430 2431# - Check usage. 2432 2433--error 1 2434--exec echo "move_file ;" | $MYSQL_TEST 2>&1 2435 2436--error 1 2437--exec echo "move_file from_file;" | $MYSQL_TEST 2>&1 2438 2439# ---------------------------------------------------------------------------- 2440# test for chmod 2441# ---------------------------------------------------------------------------- 2442--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp 2443file1 2444EOF 2445 2446chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp; 2447# The below write fails, but --error is not implemented 2448# for write_file 2449#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp 2450#test should fail 2451#EOF 2452 2453chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp; 2454remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp; 2455--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp 2456test2 2457EOF 2458 2459remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp; 2460 2461--error 1 2462--exec echo "chmod ;" | $MYSQL_TEST 2>&1 2463 2464--error 1 2465--exec echo "chmod 0 $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1 2466 2467--error 1 2468--exec echo "chmod 08 $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1 2469 2470--error 1 2471--exec echo "chmod $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1 2472 2473--error 1 2474--exec echo "chmod ABZD $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1 2475 2476--error 1 2477--exec echo "chmod 06789 $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1 2478 2479 2480# ---------------------------------------------------------------------------- 2481# test for perl 2482# ---------------------------------------------------------------------------- 2483--perl 2484print "hello\n"; 2485EOF 2486 2487--perl EOF 2488print "hello\n"; 2489EOF 2490 2491--perl DELIMITER 2492print "hello\n"; 2493DELIMITER 2494 2495--error 1 2496--exec echo "perl TOO_LONG_DELIMITER ;" | $MYSQL_TEST 2>&1 2497 2498perl; 2499print "hello\n"; 2500EOF 2501 2502perl; 2503 # Print "hello" 2504 print "hello\n"; 2505EOF 2506 2507# Test perl within while, also with if being false first iteration 2508let $outer= 3; 2509let $ifval= 0; 2510while ($outer) { 2511 if ($ifval) { 2512 perl UNTIL; 2513 my $val= 5; 2514 print "val is $val\n"; 2515UNTIL 2516 } 2517 inc $ifval; 2518 dec $outer; 2519} 2520 2521# ---------------------------------------------------------------------------- 2522# test for die 2523# ---------------------------------------------------------------------------- 2524 2525--error 1 2526--exec echo "die test of die;" | $MYSQL_TEST 2>&1 2527 2528 2529# ---------------------------------------------------------------------------- 2530# test for exit 2531# ---------------------------------------------------------------------------- 2532 2533--exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1 2534 2535# ---------------------------------------------------------------------------- 2536# test for sorted_result 2537# ---------------------------------------------------------------------------- 2538 2539create table t1( a int, b char(255), c timestamp); 2540insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 2", '2007-04-05'); 2541insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05'); 2542select * from t1; 2543--sorted_result 2544select * from t1; 2545# Should not be sorted 2546select * from t1; 2547disable_result_log; 2548sorted_result; 2549select * from t1; 2550enable_result_log; 2551--sorted_result 2552select ''; 2553sorted_result; 2554select "h"; 2555--sorted_result 2556select "he"; 2557--sorted_result 2558select "hep"; 2559--sorted_result 2560select "hepp"; 2561 2562drop table t1; 2563 2564# 1. Assignment of result set sorting 2565sorted_result; 2566 SELECT 2 as "my_col" 2567UNION 2568SELECT 1; 2569# 2570--sorted_result 2571SELECT 2 as "my_col" UNION SELECT 1; 2572--sorted_result 2573SELECT 2 as "my_col" 2574UNION 2575SELECT 1; 2576 2577# 2. Ensure that the table header will be not sorted into the result 2578--sorted_result 2579SELECT '2' as "3" 2580UNION 2581SELECT '1'; 2582 2583# 3. Ensure that an empty result set does not cause problems 2584CREATE TABLE t1( a CHAR); 2585--sorted_result 2586SELECT * FROM t1; 2587DROP TABLE t1; 2588 2589# 4. Ensure that NULL values within the result set do not cause problems 2590SELECT NULL as "my_col1",2 AS "my_col2" 2591UNION 2592SELECT NULL,1; 2593--sorted_result 2594SELECT NULL as "my_col1",2 AS "my_col2" 2595UNION 2596SELECT NULL,1; 2597# 2598SELECT 2 as "my_col1",NULL AS "my_col2" 2599UNION 2600SELECT 1,NULL; 2601--sorted_result 2602SELECT 2 as "my_col1",NULL AS "my_col2" 2603UNION 2604SELECT 1,NULL; 2605 2606# 5. "sorted_result" changes nothing when applied to a non query statement. 2607sorted_result; 2608 SET @a = 17; 2609# 2610# 6. Show that "sorted_result;" before the "SET @a = 17;" above does not affect 2611# the now following query. 2612SELECT 2 as "my_col" 2613UNION 2614SELECT 1; 2615 2616# 7. Ensure that "sorted_result" in combination with $variables works 2617let $my_stmt=SELECT 2 as "my_col" 2618UNION 2619SELECT 1; 2620--sorted_result 2621eval $my_stmt; 2622 2623# 8. Ensure that "sorted_result " does not change the semantics of 2624# "--error ...." or the protocol output after such an expected failure 2625--sorted_result 2626--error ER_NO_SUCH_TABLE 2627 2628SELECT '2' as "my_col1",2 as "my_col2" 2629UNION 2630SELECT '1',1 from t2; 2631 2632# 9. Ensure that several result formatting options including "sorted_result" 2633# - have all an effect 2634# - "--sorted_result" does not need to be direct before the statement 2635# - Row sorting is applied after modification of the column content 2636--sorted_result 2637--replace_column 1 # 2638SELECT '1' as "my_col1",2 as "my_col2" 2639UNION 2640SELECT '2',1; 2641 2642# 10. Ensure that at least 1024 rows within a result set do not cause problems 2643# 2644CREATE TABLE t1 (f1 INT); 2645INSERT INTO t1 SET f1 = 1024; 2646INSERT INTO t1 SELECT f1 - 1 FROM t1; 2647INSERT INTO t1 SELECT f1 - 2 FROM t1; 2648INSERT INTO t1 SELECT f1 - 4 FROM t1; 2649INSERT INTO t1 SELECT f1 - 8 FROM t1; 2650INSERT INTO t1 SELECT f1 - 16 FROM t1; 2651INSERT INTO t1 SELECT f1 - 32 FROM t1; 2652INSERT INTO t1 SELECT f1 - 64 FROM t1; 2653INSERT INTO t1 SELECT f1 - 128 FROM t1; 2654INSERT INTO t1 SELECT f1 - 256 FROM t1; 2655INSERT INTO t1 SELECT f1 - 512 FROM t1; 2656--disable_result_log ONCE 2657--sorted_result 2658SELECT * FROM t1; 2659DROP TABLE t1; 2660 2661# ---------------------------------------------------------------------------- 2662# test for lowercase_result 2663# ---------------------------------------------------------------------------- 2664 2665# 1. Basic test 2666--lowercase_result 2667SELECT "500g BL�B�RSYLTET�Y" AS "WILL BE lower cased"; 2668 2669# 2. test that it does not apply to next statement 2670SELECT "UPPER" AS "WILL NOT BE lower cased"; 2671 2672# 3. test that it does not affect non-SQL or the following statement 2673--lowercase_result 2674--echo UP 2675SELECT 0 as "UP AGAIN"; 2676 2677# 4. test that it works with eval and variables 2678let $lower_stmt=SELECT "ABCdef" AS "uvwXYZ"; 2679--lowercase_result 2680eval $lower_stmt; 2681 2682# 5. test that it works in combination with sort 2683sorted_result; 2684lowercase_result; 2685SELECT "Xyz" AS Name UNION SELECT "Abc" as Name ORDER BY Name DESC; 2686 2687# 6. Test combination with replace, and that lower casing is done first 2688--lowercase_result 2689--replace_result old new 2690SELECT 1 as "SOME OLD TEXT"; 2691 2692# 7. Test missing lower casing of "unknown" characters 2693--character_set utf8 2694--lowercase_result 2695SELECT 0 as "WILL NOT lower case ���"; 2696--character_set latin1 2697 2698# ---------------------------------------------------------------------------- 2699# Some coverage tests 2700# ---------------------------------------------------------------------------- 2701 2702--disable_query_log 2703--exec $MYSQL_TEST --help 2>&1 > /dev/null 2704--exec $MYSQL_TEST --version 2>&1 > /dev/null 2705--enable_query_log 2706--disable_abort_on_error ONCE 2707--error 1 2708--exec $MYSQL_TEST a b c 2>&1 > /dev/null 2709 2710# ---------------------------------------------------------------------------- 2711# test for query_get_value 2712# ---------------------------------------------------------------------------- 2713 2714CREATE TABLE t1( 2715 a int, b varchar(255), c datetime 2716); 2717SHOW COLUMNS FROM t1; 2718 2719#------------ Positive tests ------------ 2720# 1. constant parameters 2721# value is simple string without spaces 2722let $value= query_get_value(SHOW COLUMNS FROM t1, Type, 1); 2723--echo statement=SHOW COLUMNS FROM t1 row_number=1, column_name="Type", Value=$value 2724let $value= query_get_value("SHOW COLUMNS FROM t1", Type, 1); 2725--echo statement="SHOW COLUMNS FROM t1" row_number=1, column_name="Type", Value=$value 2726# 2727# 2. $variables as parameters 2728# value IS NULL 2729let $my_show= SHOW COLUMNS FROM t1; 2730let $column_name= Default; 2731let $row_number= 1; 2732let $value= query_get_value($my_show, $column_name, $row_number); 2733--echo statement=$my_show row_number=$row_number, column_name=$column_name, Value=$value 2734# 2735# 3. result set of a SELECT (not recommended, because projection and 2736# selection could be done much better by pure SELECT functionality) 2737# value is string with space in the middle 2738let $value= query_get_value(SELECT 'A B' AS "MyColumn", MyColumn, 1); 2739--echo value= ->$value<- 2740# 2741# 4. column name with space 2742let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1); 2743--echo value= $value 2744# 2745# 4.1 Query containing , protected by quotes, quotes also on column 2746let $value= query_get_value('SELECT 1 as a, 2 as b', "b", 1); 2747--echo value= $value 2748# 2749#------------ Negative tests ------------ 2750# 5. Incomplete statement including missing parameters 2751# 5.1 incomplete statement 2752--error 1 2753--exec echo "let \$value= query_get_value(SHOW;" | $MYSQL_TEST 2>&1 2754# 5.2 missing query 2755--error 1 2756--exec echo "let \$value= query_get_value;" | $MYSQL_TEST 2>&1 2757# 5.3 missing column name 2758--error 1 2759--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1);" | $MYSQL_TEST 2>&1 2760# 5.4 missing row number 2761--error 1 2762--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field);" | $MYSQL_TEST 2>&1 2763# 2764# 6. Somehow "wrong" value of parameters 2765# 6.1 row parameter 2766# 6.1.1 non sense number 0 2767let $value= initialized; 2768let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 0); 2769--echo value= $value 2770# 6.1.2 after the last row 2771let $value= initialized; 2772let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 10); 2773--echo value= $value 2774# 6.1.3 invalid row number 2775--error 1 2776--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field, notnumber);" | $MYSQL_TEST 2>&1 2777# 6.2 column name parameter, name of not existing column 2778--error 1 2779--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, column_not_exists, 1);" | $MYSQL_TEST 2>&1 2780# 6.3. statement which never gives a result set 2781--error 1 2782--exec echo "let \$value= query_get_value(SET @A = 1, Field, 1);" | $MYSQL_TEST 2>&1 2783# 6.4. statement contains a "," 2784# Note: There is no need to improve this, because we need query_get_value 2785# for SHOW commands only. 2786--error 1 2787--exec echo "let \$value= query_get_value(SELECT 1 AS "A", 1 AS "B", 1);" | $MYSQL_TEST 2>&1 2788# 2789# 7. empty result set 2790let $value= initialized; 2791let $value= query_get_value(SELECT a FROM t1, a, 1); 2792--echo value= $value 2793# 2794# 9. failing statement 2795--error 1 2796--exec echo "let \$value= query_get_value(SHOW COLNS FROM t1, Field, 1);" | $MYSQL_TEST 2>&1 2797# 2798# 10. Artificial example how to process a complete SHOW result set: 2799let $show_statement= SHOW COLUMNS FROM t1; 2800let $rowno= 1; 2801let $run=1; 2802let $count= 0; 2803--echo 2804--echo Field Type Null Key Default Extra 2805while ($run) 2806{ 2807 let $Field= query_get_value($show_statement, Field, $rowno); 2808 if ($Field == No such row) 2809 { 2810 let $run= 0; 2811 } 2812 if ($Field != No such row) 2813 { 2814 let $Type= query_get_value($show_statement, Type, $rowno); 2815 let $Null= query_get_value($show_statement, Null, $rowno); 2816 if ($Null == YES) 2817 { 2818 inc $count; 2819 } 2820 let $Key= query_get_value($show_statement, Key, $rowno); 2821 let $Default= query_get_value($show_statement, Default, $rowno); 2822 let $Extra= query_get_value($show_statement, Extra, $rowno); 2823 --echo $Field $Type $Null ->$Key<- $Default $Extra 2824 inc $rowno; 2825 } 2826} 2827--echo 2828--echo Number of columns with Default NULL: $count 2829--echo 2830eval $show_statement; 2831 2832drop table t1; 2833 2834# ---------------------------------------------------------------------------- 2835# Test change_user command 2836# ---------------------------------------------------------------------------- 2837 2838--error 1 2839--exec echo "--change_user root,,inexistent" | $MYSQL_TEST 2>&1 2840 2841--error 1 2842--exec echo "--change_user inexistent,,test" | $MYSQL_TEST 2>&1 2843 2844--error 1 2845--exec echo "--change_user root,inexistent,test" | $MYSQL_TEST 2>&1 2846 2847--change_user 2848--change_user root 2849--change_user root,, 2850--change_user root,,test 2851 2852# ---------------------------------------------------------------------------- 2853# Test mkdir and rmdir command 2854# ---------------------------------------------------------------------------- 2855 2856mkdir $MYSQLTEST_VARDIR/tmp/testdir; 2857rmdir $MYSQLTEST_VARDIR/tmp/testdir; 2858 2859# Directory already exist 2860mkdir $MYSQLTEST_VARDIR/tmp/testdir; 2861--error 1 2862mkdir $MYSQLTEST_VARDIR/tmp/testdir; 2863 2864# Remove dir with file inside 2865write_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt; 2866hello 2867EOF 2868 2869# Verify that --replace_result also work on list_files 2870--replace_result file REPLACED_FILE 2871list_files $MYSQLTEST_VARDIR/tmp/testdir; 2872# list_files gets the directory list before creating the new file 2873list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *; 2874list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *2*; 2875list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt; 2876list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt; 2877diff_files $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir/file3.txt; 2878 2879cat_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt; 2880 2881list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file11.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt; 2882remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir file?.txt; 2883list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/dir-list.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt; 2884cat_file $MYSQLTEST_VARDIR/tmp/testdir/dir-list.txt; 2885remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir file*.txt; 2886list_files $MYSQLTEST_VARDIR/tmp/testdir; 2887remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir; 2888list_files $MYSQLTEST_VARDIR/tmp/testdir; 2889rmdir $MYSQLTEST_VARDIR/tmp/testdir; 2890 2891# 2892# Bug#36041 mysql-test-run doesn't seem to string match 100% effectively 2893# on Windows 2894# 2895 2896--replace_result c:\\a.txt z 2897SELECT 'c:\\a.txt' AS col; 2898 2899# ---------------------------------------------------------------------------- 2900# Test that -- is not allowed as comment, only as mysqltest builtin command 2901# ---------------------------------------------------------------------------- 2902 2903# valid 2904select 1; 2905--query select 1 2906--query -- a comment for the server 2907 2908# Not valid, "select" is not a mysqltest command 2909--error 1 2910--exec echo "--select 1;" | $MYSQL_TEST 2>&1 2911 2912 2913# ---------------------------------------------------------------------------- 2914# BUG#35701 please allow test language variables in connection and sync_slave_with_master 2915# Test that "connection $variable" works and that $CURRENT_CONNECTION has the right value. 2916# ---------------------------------------------------------------------------- 2917 2918connect (con1,localhost,root,,); 2919--echo $CURRENT_CONNECTION 2920connect (con2,localhost,root,,); 2921--echo $CURRENT_CONNECTION 2922 2923connection default; 2924--echo $CURRENT_CONNECTION 2925 2926connection con1; 2927--echo $CURRENT_CONNECTION 2928 2929connection con2; 2930--echo $CURRENT_CONNECTION 2931 2932let $x= con1; 2933let $y= con2; 2934 2935connection $x; 2936--echo $CURRENT_CONNECTION 2937 2938connection $y; 2939--echo $CURRENT_CONNECTION 2940 2941# Disconnect the not selected connection 2942disconnect $x; 2943--echo $CURRENT_CONNECTION 2944 2945# Disconnect the selected connection 2946disconnect $y; 2947--echo $CURRENT_CONNECTION 2948connection default; 2949 2950# 2951# MDEV-13187 incorrect backslash parsing in clients 2952# 2953set sql_mode=no_backslash_escapes; 2954select "foo\""bar"; 2955set sql_mode=default; 2956 2957--echo End of tests 2958 2959# Wait till we reached the initial number of concurrent sessions 2960--source include/wait_until_count_sessions.inc 2961 2962--disable_query_log 2963--eval SET GLOBAL max_connections = $saved_max_connections 2964--enable_query_log 2965