2004-10-22 05:56:27 +02:00
|
|
|
|
|
|
|
# ============================================================================
|
|
|
|
#
|
|
|
|
# Test of mysqltest itself
|
|
|
|
#
|
|
|
|
# ============================================================================
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# $mysql_errno contains the return code of the last command
|
|
|
|
# send to the server.
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# get $mysql_errno before the first statement
|
|
|
|
# $mysql_errno should be -1
|
|
|
|
eval select $mysql_errno as "before_use_test" ;
|
|
|
|
|
|
|
|
|
2004-10-22 05:56:27 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Positive case(statement)
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
select otto from (select 1 as otto) as t1;
|
|
|
|
# expectation = response
|
|
|
|
--error 0
|
|
|
|
select otto from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
# expectation <> response
|
|
|
|
-- // --error 1054
|
|
|
|
-- // select otto from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Negative case(statement):
|
|
|
|
# The dervied table t1 does not contain a column named 'friedrich' .
|
|
|
|
# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and
|
|
|
|
# --> 1054: Unknown column 'friedrich' in 'field list'
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# expectation <> response
|
|
|
|
#--error 0
|
|
|
|
#select friedrich from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
# expectation = response
|
|
|
|
--error 1054
|
|
|
|
select friedrich from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
# The following unmasked unsuccessful statement must give
|
|
|
|
# 1. mysqltest gives a 'failed'
|
|
|
|
# 2. does not produce a r/<test case>.reject file !!!
|
|
|
|
# PLEASE uncomment it and check it's effect
|
|
|
|
#select friedrich from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Tests for the new feature - SQLSTATE error code matching
|
|
|
|
# Positive case(statement)
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# expectation = response
|
|
|
|
!S00000 select otto from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
--error S00000
|
|
|
|
select otto from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
# expectation <> response
|
|
|
|
#!S42S22 select otto from (select 1 as otto) as t1;
|
|
|
|
#--error S42S22
|
|
|
|
#select otto from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Negative case(statement)
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# expectation = response
|
|
|
|
!S42S22 select friedrich from (select 1 as otto) as t1;
|
|
|
|
--error S42S22
|
|
|
|
select friedrich from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
# expectation !=response
|
|
|
|
#!S00000 select friedrich from (select 1 as otto) as t1;
|
|
|
|
#--error S00000
|
|
|
|
#select friedrich from (select 1 as otto) as t1;
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# 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.
|
2004-11-02 19:13:27 +01:00
|
|
|
# Example: --error 1064 To prevent the abort after the error.
|
2004-10-29 14:51:56 +02:00
|
|
|
# garbage ;
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# check mysql_errno = 0 after successful statement
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
select otto from (select 1 as otto) as t1;
|
|
|
|
eval select $mysql_errno as "after_successful_stmt_errno" ;
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# check mysql_errno = 1064 after statement with wrong syntax
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
eval select $mysql_errno as "after_wrong_syntax_errno" ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# check if let $my_var= 'abc' ; affects $mysql_errno
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
let $my_var= 'abc' ;
|
|
|
|
eval select $mysql_errno as "after_let_var_equal_value" ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# check if set @my_var= 'abc' ; affects $mysql_errno
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
set @my_var= 'abc' ;
|
|
|
|
eval select $mysql_errno as "after_set_var_equal_value" ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# check if the setting of --disable-warnings itself affects $mysql_errno
|
|
|
|
# (May be --<whatever> modifies $mysql_errno.)
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
--disable_warnings
|
|
|
|
eval select $mysql_errno as "after_disable_warnings_command" ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# check if --disable-warnings + command with warning affects the errno
|
|
|
|
# stored within $mysql_errno
|
|
|
|
# (May be disabled warnings affect $mysql_errno.)
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
drop table if exists t1 ;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
drop table if exists t1 ;
|
|
|
|
eval select $mysql_errno as "after_disable_warnings" ;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# check if masked errors affect $mysql_errno
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
--error 1146
|
|
|
|
select 3 from t1 ;
|
|
|
|
eval select $mysql_errno as "after_minus_masked" ;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1146
|
2004-10-29 14:51:56 +02:00
|
|
|
select 3 from t1 ;
|
|
|
|
eval select $mysql_errno as "after_!_masked" ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# Will manipulations of $mysql_errno be possible and visible ?
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
let $mysql_errno= -1;
|
|
|
|
eval select $mysql_errno as "after_let_errno_equal_value" ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# How affect actions on prepared statements $mysql_errno ?
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# failing prepare
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1146
|
2004-10-29 14:51:56 +02:00
|
|
|
prepare stmt from "select 3 from t1" ;
|
|
|
|
eval select $mysql_errno as "after_failing_prepare" ;
|
|
|
|
create table t1 ( f1 char(10));
|
|
|
|
|
|
|
|
# successful prepare
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
prepare stmt from "select 3 from t1" ;
|
|
|
|
eval select $mysql_errno as "after_successful_prepare" ;
|
|
|
|
|
|
|
|
# successful execute
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
execute stmt;
|
|
|
|
eval select $mysql_errno as "after_successful_execute" ;
|
|
|
|
|
|
|
|
# failing execute (table dropped)
|
|
|
|
drop table t1;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1146
|
2004-10-29 14:51:56 +02:00
|
|
|
execute stmt;
|
|
|
|
eval select $mysql_errno as "after_failing_execute" ;
|
|
|
|
|
|
|
|
# failing execute (unknown statement)
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1243
|
2004-10-29 14:51:56 +02:00
|
|
|
execute __stmt_;
|
|
|
|
eval select $mysql_errno as "after_failing_execute" ;
|
|
|
|
|
|
|
|
# successful deallocate
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
deallocate prepare stmt;
|
|
|
|
eval select $mysql_errno as "after_successful_deallocate" ;
|
|
|
|
|
|
|
|
# failing deallocate ( statement handle does not exist )
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1243
|
2004-10-29 14:51:56 +02:00
|
|
|
deallocate prepare __stmt_;
|
|
|
|
eval select $mysql_errno as "after_failing_deallocate" ;
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# test cases for "--disable_abort_on_error"
|
|
|
|
#
|
|
|
|
# "--disable_abort_on_error" switches the abort of mysqltest
|
|
|
|
# after "unmasked" failing statements off.
|
|
|
|
#
|
|
|
|
# The default is "--enable_abort_on_error".
|
|
|
|
#
|
|
|
|
# "Maskings" are
|
2004-11-02 19:13:27 +01:00
|
|
|
# --error <error number> and --error <error number>
|
2004-10-29 14:51:56 +02:00
|
|
|
# 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
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# Switch the abort on error off and check the effect on $mysql_errno
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
--disable_abort_on_error
|
|
|
|
eval select $mysql_errno as "after_--disable_abort_on_error" ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# "unmasked" failing statement should not cause an abort
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
select 3 from t1 ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# masked failing statements
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# expected error = response
|
|
|
|
--error 1146
|
|
|
|
select 3 from t1 ;
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1146
|
2004-10-29 14:51:56 +02:00
|
|
|
select 3 from t1 ;
|
|
|
|
eval select $mysql_errno as "after_!errno_masked_error" ;
|
|
|
|
# expected error <> response
|
|
|
|
# --error 1000
|
|
|
|
# select 3 from t1 ;
|
2004-11-02 19:13:27 +01:00
|
|
|
# --error 1000
|
2004-10-29 14:51:56 +02:00
|
|
|
# select 3 from t1 ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# Switch the abort on error on and check the effect on $mysql_errno
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
--error 1064
|
2004-10-29 14:51:56 +02:00
|
|
|
garbage ;
|
|
|
|
--enable_abort_on_error
|
|
|
|
eval select $mysql_errno as "after_--enable_abort_on_error" ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# masked failing statements
|
2004-10-29 14:51:56 +02:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# expected error = response
|
|
|
|
--error 1146
|
|
|
|
select 3 from t1 ;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2004-11-02 19:13:27 +01:00
|
|
|
# check that the old default behaviour is not changed
|
2004-10-29 14:51:56 +02:00
|
|
|
# Please remove the '#' to get the abort on error
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
#--error 1064
|
|
|
|
#select 3 from t1 ;
|
|
|
|
#
|
|
|
|
#select 3 from t1 ;
|
2005-05-06 14:48:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bug #10251: Identifiers containing quotes not handled correctly
|
|
|
|
#
|
|
|
|
select 1 as `a'b`, 2 as `a"b`;
|
|
|
|
|
|
|
|
# Test escaping of quotes
|
|
|
|
select 'aaa\\','aa''a',"aa""a";
|
2005-06-09 20:01:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check of include/show_msg.inc
|
|
|
|
#
|
|
|
|
|
|
|
|
# The message contains in most cases a string with the default character set
|
|
|
|
SET @message = 'Here comes a message';
|
|
|
|
--source include/show_msg.inc
|
|
|
|
|
|
|
|
# The message could also contain a string with character set utf8
|
|
|
|
SET @message = USER();
|
|
|
|
--source include/show_msg.inc
|
|
|
|
|
|
|
|
# The message contains more then 80 characters on multiple lines
|
|
|
|
SET @message = 'Here comes a very very long message that is longer then 80 characters
|
|
|
|
on multiple lines';
|
|
|
|
--source include/show_msg80.inc
|
|
|
|
|