📄 mysqltest.test
字号:
# ----------------------------------------------------------------------------# Test delimiter# ----------------------------------------------------------------------------delimiter stop;echo teststopdelimiter ;stopecho test2;--delimiter stopecho test3stop--delimiter ;echo test4;# ----------------------------------------------------------------------------# Test if# ----------------------------------------------------------------------------let $counter=10;if ($counter){ echo Counter is greater than 0, (counter=10);}if (!$counter){ echo Counter is not 0, (counter=10);}let $counter=0;if ($counter){ echo Counter is greater than 0, (counter=0);}if (!$counter){ echo Counter is not 0, (counter=0);}# ----------------------------------------------------------------------------# Test while, { and }# ----------------------------------------------------------------------------let $i=1;while ($i){ echo $i; dec $i;}# One liner#let $i=1;while ($i){echo $i;dec $i;}let $i=0;while (!$i){ echo Testing while with not; inc $i;}# Exceed max nesting level# Fix win path--replace_result \\ /--error 1--exec echo "source include/mysqltest_while.inc;" | $MYSQL_TEST 2>&1--error 1--exec echo "while \$i;" | $MYSQL_TEST 2>&1--error 1--exec echo "while (\$i;" | $MYSQL_TEST 2>&1--error 1--exec echo "let \$i=1; while (\$i) dec \$i;" | $MYSQL_TEST 2>&1--error 1--exec echo "};" | $MYSQL_TEST 2>&1--error 1--exec echo "end;" | $MYSQL_TEST 2>&1--error 1--exec echo "{;" | $MYSQL_TEST 2>&1--system echo "while (0)" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--error 1--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1--system echo "while (0)" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "{echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--error 1--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1--system echo "while (0){" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--error 1--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1# ----------------------------------------------------------------------------# Test error messages returned from comments starting with a command# ------------------------------------------------------------------------------error 1--exec echo "--if the other server is down" | $MYSQL_TEST 2>&1--error 1--exec echo "-- end when ..." | $MYSQL_TEST 2>&1# ----------------------------------------------------------------------------# Test replace# ------------------------------------------------------------------------------replace_result a bselect "a" as col1, "c" as col2;--replace_result a b c dselect "a" as col1, "c" as col2;--error 1--exec echo "--replace_result a" | $MYSQL_TEST 2>&1--error 1--exec echo "--replace_result a;" | $MYSQL_TEST 2>&1--error 1--exec echo "replace_result a;" | $MYSQL_TEST 2>&1--error 1--exec echo "replace_result a ;" | $MYSQL_TEST 2>&1--exec echo "replace_result a b; echo OK;" | $MYSQL_TEST 2>&1--error 1--exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1--error 1--exec echo "replace_result a b c ;" | $MYSQL_TEST 2>&1--replace_column 1 bselect "a" as col1, "c" as col2;--replace_column 1 b 2 dselect "a" as col1, "c" as col2;--error 1--exec echo "--replace_column a" | $MYSQL_TEST 2>&1--error 1--exec echo "--replace_column 1" | $MYSQL_TEST 2>&1--error 1--exec echo "--replace_column a b" | $MYSQL_TEST 2>&1--error 1--exec echo "--replace_column a 1" | $MYSQL_TEST 2>&1--error 1--exec echo "--replace_column 1 b c " | $MYSQL_TEST 2>&1# ----------------------------------------------------------------------------# Test sync_with_master# ------------------------------------------------------------------------------error 1--exec echo "save_master_pos; sync_with_master 10!;" | $MYSQL_TEST 2>&1--error 1--exec echo "save_master_pos; sync_with_master 10 !;" | $MYSQL_TEST 2>&1--error 1--exec echo "save_master_pos; sync_with_master a;" | $MYSQL_TEST 2>&1# ----------------------------------------------------------------------------# Test connect# ------------------------------------------------------------------------------error 1--exec echo "connect;" | $MYSQL_TEST 2>&1--error 1--exec echo "connect ();" | $MYSQL_TEST 2>&1--error 1--exec echo "connect (con2);" | $MYSQL_TEST 2>&1--error 1--exec echo "connect (con2,);" | $MYSQL_TEST 2>&1--error 1--exec echo "connect (con2,localhost);" | $MYSQL_TEST 2>&1--error 1--exec echo "connect (con2, localhost, root);" | $MYSQL_TEST 2>&1--error 1--exec echo "connect (con2, localhost, root,);" | $MYSQL_TEST 2>&1--error 1--exec echo "connect (con2,localhost,root,,illegal_db);" | $MYSQL_TEST 2>&1--error 1--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $MYSQL_TEST 2>&1--error 1--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1# Repeat connect/disconnect--system echo "let \$i=100;" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "{" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "}" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK;" | $MYSQL_TEST 2>&1# Repeat connect/disconnect, exceed max number of connections--system echo "let \$i=200;" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "{" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "}" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR--error 1--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1# Select disconnected connection--system echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "connection test_con1;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR--error 1--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1# Connection name already used--system echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql--system echo "connect (test_con1,localhost,root,,);" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR--error 1--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1# connect when "disable_abort_on_error" caused "connection not found"--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT--disable_abort_on_errorconnect (con1,localhost,root,,);connection default;connection con1;--enable_abort_on_error# ----------------------------------------------------------------------------# Test mysqltest arguments# ----------------------------------------------------------------------------# -x <file_name>, use the file specified after -x as the test file--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc# Fix Win paths--replace_result \\ /--error 1--exec $MYSQL_TEST -x non_existing_file.inc 2>&1# ----------------------------------------------------------------------------# TODO Test queries, especially their errormessages... so it's easy to debug # new scripts and diagnose errors# ----------------------------------------------------------------------------# ----------------------------------------------------------------------------# Test bug#12386# ----------------------------------------------------------------------------let $num= 2;while ($num){ --error 1064 failing_statement; dec $num;}SELECT 1 as a;## Bug #10251: Identifiers containing quotes not handled correctly#select 1 as `a'b`, 2 as `a"b`;# Test escaping of quotesselect 'aaa\\','aa''a',"aa""a";## Check of include/show_msg.inc and include/show_msg80.inc## The message contains in most cases a string with the default character setlet $message= Here comes a message;--source include/show_msg.inc# The message could also contain a string with character set utf8let $message= `SELECT USER()`;--source include/show_msg.inc# The message contains more then 80 characters on multiple lines# and is kept between double quotes.let $message= "Here comes a very very long message that - is longer then 80 characters and - consists of several lines";--source include/show_msg80.inc# The message contains more then 80 characters on multiple lines# and uses the auxiliary character "." at the beginning of the message lines.let $message= . Here comes a very very long message that . - is longer then 80 characters and . - consists of several lines;--source include/show_msg80.inc## Test --enable_parsing / disable_parsing#--disable_query_log--disable_parsing# The following will not enable query logging--enable_query_logselect "this will not be executed";--enable_parsingselect "this will be executed";--enable_query_log## Test zero length result file. Should not pass#--exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql--error 1--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result 2>&1## Test that a test file that does not generate any output fails.#--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql--error 1--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1## Test that mysqltest fails when there are no queries executed# but a result file exists# NOTE! This will never happen as long as it's not allowed to have# test files that produce no output#--exec echo "something" > $MYSQLTEST_VARDIR/tmp/result_file.result#--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql#--error 1#--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1## Bug #11731 mysqltest in multi-statement queries ignores errors in# non-1st queries#echo Failing multi statement query;# PS does not support multi statement--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "insertz 'error query'||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--error 1--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1drop table t1;--error 1--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1# The .out file should be non existent--exec test ! -s $MYSQLTEST_VARDIR/tmp/bug11731.outdrop table t1;echo Multi statement using expected error;# PS does not support multi statement--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "--error 1064" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql# These two should work since the error is expected--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1drop table t1;--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1# The .out file should exist--exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.outdrop table t1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -