📄 mysqltest.test
字号:
# This test should work in embedded server after mysqltest is fixed-- source include/not_embedded.inc# ============================================================================## Test of mysqltest itself## There are three rules that determines what belong to each command# 1. A normal command is delimited by the <delimiter> which by default is# set to ';'## ex: | select *# | from t1;# |# Command: "select * from t1"## 2. Special case is a line that starts with "--", this is a comment# ended when the new line character is reached. But the first word# in the comment may contain a valid command, which then will be# executed. This can be useful when sending commands that# contains <delimiter>## 3. Special case is also a line that starts with '#' which is treated# as a comment and will be ended by new line character## ============================================================================# ----------------------------------------------------------------------------# $mysql_errno contains the return code of the last command# send to the server.# ----------------------------------------------------------------------------# get $mysql_errno before the first statement# $mysql_errno should be -1eval select $mysql_errno as "before_use_test" ;# ----------------------------------------------------------------------------# Positive case(statement)# ----------------------------------------------------------------------------select otto from (select 1 as otto) as t1;# expectation = response--error 0select otto from (select 1 as otto) as t1;# expectation <> response-- // --error 1054-- // select otto from (select 1 as otto) as t1;# ----------------------------------------------------------------------------# Negative case(statement):# The dervied table t1 does not contain a column named 'friedrich' . # --> ERROR 42S22: Unknown column 'friedrich' in 'field list and# --> 1054: Unknown column 'friedrich' in 'field list'# ----------------------------------------------------------------------------# expectation <> response#--error 0#select friedrich from (select 1 as otto) as t1--error 1--exec echo "select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1# expectation = response--error 1054select friedrich from (select 1 as otto) as t1;# The following unmasked unsuccessful statement must give# 1. mysqltest gives a 'failed'# 2. does not produce a r/<test case>.reject file !!!# PLEASE uncomment it and check it's effect#select friedrich from (select 1 as otto) as t1;# ----------------------------------------------------------------------------# Tests for the new feature - SQLSTATE error code matching# Positive case(statement)# ----------------------------------------------------------------------------# This syntax not allowed anymore, use --error S00000, see below# expectation = response#!S00000 select otto from (select 1 as otto) as t1;--error S00000select otto from (select 1 as otto) as t1;# expectation <> response#!S42S22 select otto from (select 1 as otto) as t1;#--error S42S22#select otto from (select 1 as otto) as t1;--error 1--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1# ----------------------------------------------------------------------------# Negative case(statement)# ----------------------------------------------------------------------------# This syntax not allowed anymore, use --error S42S22, see below# expectation = response#!S42S22 select friedrich from (select 1 as otto) as t1;--error S42S22select friedrich from (select 1 as otto) as t1;# expectation !=response#!S00000 select friedrich from (select 1 as otto) as t1;#--error S00000#select friedrich from (select 1 as otto) as t1;--error 1--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1# ----------------------------------------------------------------------------# test cases for $mysql_errno## $mysql_errno is a builtin variable of mysqltest and contains the return code# of the last command send to the server.## The following test cases often initialize $mysql_errno to 1064 by # a command with wrong syntax.# Example: --error 1064 To prevent the abort after the error.# garbage ;# ----------------------------------------------------------------------------# ----------------------------------------------------------------------------# check mysql_errno = 0 after successful statement# ----------------------------------------------------------------------------select otto from (select 1 as otto) as t1;eval select $mysql_errno as "after_successful_stmt_errno" ;#----------------------------------------------------------------------------# check mysql_errno = 1064 after statement with wrong syntax# ------------------------------------------------------------------------------error 1064garbage ;eval select $mysql_errno as "after_wrong_syntax_errno" ;# ----------------------------------------------------------------------------# check if let $my_var= 'abc' ; affects $mysql_errno# ------------------------------------------------------------------------------error 1064garbage ;let $my_var= 'abc' ;eval select $mysql_errno as "after_let_var_equal_value" ;# ----------------------------------------------------------------------------# check if set @my_var= 'abc' ; affects $mysql_errno# ------------------------------------------------------------------------------error 1064garbage ;set @my_var= 'abc' ;eval select $mysql_errno as "after_set_var_equal_value" ;# ----------------------------------------------------------------------------# check if the setting of --disable-warnings itself affects $mysql_errno# (May be --<whatever> modifies $mysql_errno.)# ------------------------------------------------------------------------------error 1064garbage ;--disable_warningseval select $mysql_errno as "after_disable_warnings_command" ;# ----------------------------------------------------------------------------# check if --disable-warnings + command with warning affects the errno# stored within $mysql_errno# (May be disabled warnings affect $mysql_errno.)# ----------------------------------------------------------------------------drop table if exists t1 ;--error 1064garbage ;drop table if exists t1 ;eval select $mysql_errno as "after_disable_warnings" ;--enable_warnings# ----------------------------------------------------------------------------# check if masked errors affect $mysql_errno# ------------------------------------------------------------------------------error 1064garbage ;--error 1146select 3 from t1 ;eval select $mysql_errno as "after_minus_masked" ;--error 1064garbage ;--error 1146select 3 from t1 ;eval select $mysql_errno as "after_!_masked" ;# ----------------------------------------------------------------------------# Will manipulations of $mysql_errno be possible and visible ?# ------------------------------------------------------------------------------error 1064garbage ;let $mysql_errno= -1;eval select $mysql_errno as "after_let_errno_equal_value" ;# ----------------------------------------------------------------------------# How affect actions on prepared statements $mysql_errno ?# ----------------------------------------------------------------------------# failing prepare--error 1064garbage ;--error 1146prepare stmt from "select 3 from t1" ;eval select $mysql_errno as "after_failing_prepare" ;create table t1 ( f1 char(10));# successful prepare--error 1064garbage ;prepare stmt from "select 3 from t1" ;eval select $mysql_errno as "after_successful_prepare" ;# successful execute--error 1064garbage ;execute stmt;eval select $mysql_errno as "after_successful_execute" ;# failing execute (table dropped)drop table t1;--error 1064garbage ;--error 1146execute stmt;eval select $mysql_errno as "after_failing_execute" ;# failing execute (unknown statement)--error 1064garbage ;--error 1243execute __stmt_;eval select $mysql_errno as "after_failing_execute" ;# successful deallocate--error 1064garbage ;deallocate prepare stmt;eval select $mysql_errno as "after_successful_deallocate" ;# failing deallocate ( statement handle does not exist )--error 1064garbage ;--error 1243deallocate prepare __stmt_;eval select $mysql_errno as "after_failing_deallocate" ;# ----------------------------------------------------------------------------# test cases for "--disable_abort_on_error"## "--disable_abort_on_error" switches the abort of mysqltest# after "unmasked" failing statements off.## The default is "--enable_abort_on_error".## "Maskings" are# --error <error number> and --error <error number># in the line before the failing statement.## There are some additional test case for $mysql_errno# because "--disable_abort_on_error" enables a new situation.# Example: "unmasked" statement fails + analysis of $mysql_errno# ----------------------------------------------------------------------------# ----------------------------------------------------------------------------# Switch the abort on error off and check the effect on $mysql_errno# ------------------------------------------------------------------------------error 1064garbage ;--disable_abort_on_erroreval select $mysql_errno as "after_--disable_abort_on_error" ;# ----------------------------------------------------------------------------# "unmasked" failing statement should not cause an abort# ----------------------------------------------------------------------------select 3 from t1 ;# ----------------------------------------------------------------------------# masked failing statements# ----------------------------------------------------------------------------# expected error = response--error 1146select 3 from t1 ;--error 1146select 3 from t1 ;eval select $mysql_errno as "after_!errno_masked_error" ;# expected error <> response# --error 1000# select 3 from t1 ;# --error 1000# select 3 from t1 ;--error 1--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $MYSQL_TEST 2>&1# ----------------------------------------------------------------------------# Switch the abort on error on and check the effect on $mysql_errno# ------------------------------------------------------------------------------error 1064garbage ;--enable_abort_on_erroreval select $mysql_errno as "after_--enable_abort_on_error" ;# ----------------------------------------------------------------------------# masked failing statements# ----------------------------------------------------------------------------# expected error = response--error 1146select 3 from t1 ;# ----------------------------------------------------------------------------# check that the old default behaviour is not changed# Please remove the '#' to get the abort on error# ----------------------------------------------------------------------------#--error 1064#select 3 from t1 ;##select 3 from t1 ;# End of 4.1 tests--error 1--exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1# ----------------------------------------------------------------------------# Test comments# ----------------------------------------------------------------------------# This is a comment# This is a ; comment# This is a -- comment-- This is also a comment-- # This is also a comment-- This is also a ; comment# ----------------------------------------------------------------------------# Test comments with embedded command# ------------------------------------------------------------------------------echo hello-- echo hello-- echo ;;;;;;;;--echo # MySQL: -- The# ----------------------------------------------------------------------------# Test detect end of line "junk"# Most likely causes by a missing delimiter# ----------------------------------------------------------------------------# Too many parameters to function--error 1--exec echo "sleep 5 6;" | $MYSQL_TEST 2>&1# Too many parameters to function--error 1--exec echo "--sleep 5 6" | $MYSQL_TEST 2>&1## Missing delimiter# The comment will be "sucked into" the sleep command since# delimiter is missing until after "show status"--system echo "sleep 4" > var/tmp/mysqltest.sql--system echo "# A comment" >> var/tmp/mysqltest.sql
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -