2011-08-22 13:58:49 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# $mysql_errno contains the return code of the last command
|
|
|
|
|
# sent to the server.
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# get $mysql_errno before the first statement
|
|
|
|
|
# $mysql_errno should be -1
|
|
|
|
|
# get $mysql_errname as well
|
|
|
|
|
|
|
|
|
|
echo $mysql_errno before test;
|
|
|
|
|
echo $mysql_errname before test;
|
|
|
|
|
|
2007-05-31 09:34:24 +02:00
|
|
|
|
-- source include/have_log_bin.inc
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# This test should work in embedded server after mysqltest is fixed
|
2006-04-11 12:01:21 +02:00
|
|
|
|
-- source include/not_embedded.inc
|
2004-10-22 05:56:27 +02:00
|
|
|
|
|
2006-12-22 00:38:34 +01:00
|
|
|
|
# This test uses chmod, can't be run with root permissions
|
|
|
|
|
-- source include/not_as_root.inc
|
|
|
|
|
|
2009-03-03 21:34:18 +01:00
|
|
|
|
# Save the initial number of concurrent sessions
|
|
|
|
|
--source include/count_sessions.inc
|
|
|
|
|
|
Fix multiple test suite failures in Buildbot due to races in the test cases or missing server features not properly checked
mysql-test/r/func_misc.result:
Move test that requires query cache from main.func_misc to main.query_cache.
mysql-test/r/mysqltest.result:
Fix test failure due to race.
This test case creates > 300 connections in a tight loop, and depending on thread
scheduling and load, even though each connection is immediately disconnected
before connecting the next one, the server max connections may still be exceeded
due to server not being able to free old connections as fast as new ones are made.
mysql-test/r/query_cache.result:
Move test that requires query cache from main.func_misc to main.query_cache.
Move test that requires query cache from main.variables to main.query_cache.
mysql-test/r/query_cache_notembedded.result:
Move test that requires query cache from main.sp_notembedded to main.query_cache_notembedded.
mysql-test/r/sp_notembedded.result:
Move test that requires query cache from main.sp_notembedded to main.query_cache_notembedded.
mysql-test/r/udf.result:
Move test in main.udf that requires query cache to separate file.
mysql-test/r/udf_query_cache.result:
Move test in main.udf that requires query cache to separate file.
mysql-test/r/variables.result:
Move test that requires query cache from main.variables to main.query_cache.
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Fix race where result file may show state "cleaning up" in the small window
between setting COMMAND to 'Sleep' and clearing STATE.
mysql-test/suite/rpl/r/rpl_temporary.result:
Fix race with suppression of warning message by fixing the test to not generate the
warning message in the first place.
Problem was a race between creating an anonymous account and resetting the slave.
If the slave reset happens before replicating the account, the subsequest deletion
of the account will fail to replicate correctly due to missing row.
mysql-test/suite/rpl/t/rpl_temporary.test:
Fix race with suppression of warning message by fixing the test to not generate the
warning message in the first place.
Problem was a race between creating an anonymous account and resetting the slave.
If the slave reset happens before replicating the account, the subsequest deletion
of the account will fail to replicate correctly due to missing row.
mysql-test/t/func_misc.test:
Move test that requires query cache from main.func_misc to main.query_cache.
Move test that requires query cache from main.variables to main.query_cache.
mysql-test/t/mysqltest.test:
Fix test failure due to race.
This test case creates > 300 connections in a tight loop, and depending on thread
scheduling and load, even though each connection is immediately disconnected
before connecting the next one, the server max connections may still be exceeded
due to server not being able to free old connections as fast as new ones are made.
mysql-test/t/query_cache.test:
Move test that requires query cache to main.query_cache.
mysql-test/t/query_cache_notembedded.test:
Move test that requires query cache from main.sp_notembedded to main.query_cache_notembedded.
mysql-test/t/sp_notembedded.test:
Move test that requires query cache from main.sp_notembedded to main.query_cache_notembedded.
mysql-test/t/udf.test:
Move test in main.udf that requires query cache to separate file.
mysql-test/t/udf_query_cache-master.opt:
Move test in main.udf that requires query cache to separate file.
mysql-test/t/udf_query_cache.test:
Move test in main.udf that requires query cache to separate file.
mysql-test/t/variables.test:
Move test that requires query cache from main.variables to main.query_cache.
tests/mysql_client_test.c:
In tests that require query cache, skip the test if query cache not available.
Do this dynamically rather than using HAVE_QUERY_CACHE, as there is no guarantee
that the server we run against was compiled with same preprocessor #define as
the mysql_client_test program (and since it is trivial to check dynamically).
2010-01-11 14:15:28 +01:00
|
|
|
|
# Some tests below connect/disconnect rapidly in a loop. This causes a race
|
|
|
|
|
# where mysqld may not have time to register the previous disconnects before
|
|
|
|
|
# new connects, and eventually we run out of connections. So we need to
|
|
|
|
|
# increase the maximum.
|
|
|
|
|
let $saved_max_connections = `SELECT @@global.max_connections`;
|
|
|
|
|
SET GLOBAL max_connections = 1000;
|
|
|
|
|
|
|
|
|
|
|
2004-10-22 05:56:27 +02:00
|
|
|
|
# ============================================================================
|
|
|
|
|
#
|
|
|
|
|
# Test of mysqltest itself
|
|
|
|
|
#
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# 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
|
|
|
|
|
#
|
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;
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Negative case(statement):
|
2009-03-03 21:34:18 +01:00
|
|
|
|
# The derived table t1 does not contain a column named 'friedrich' .
|
2004-10-22 05:56:27 +02:00
|
|
|
|
# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and
|
|
|
|
|
# --> 1054: Unknown column 'friedrich' in 'field list'
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# expectation <> response
|
|
|
|
|
#--error 0
|
2005-07-15 17:51:43 +02:00
|
|
|
|
#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
|
2004-10-22 05:56:27 +02:00
|
|
|
|
|
|
|
|
|
# expectation = response
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_BAD_FIELD_ERROR
|
|
|
|
|
|
2004-10-22 05:56:27 +02:00
|
|
|
|
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 !!!
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# PLEASE uncomment it and check its effect
|
2004-10-22 05:56:27 +02:00
|
|
|
|
#select friedrich from (select 1 as otto) as t1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Tests for the new feature - SQLSTATE error code matching
|
|
|
|
|
# Positive case(statement)
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
2005-08-31 18:10:26 +02:00
|
|
|
|
# This syntax not allowed anymore, use --error S00000, see below
|
2004-10-22 05:56:27 +02:00
|
|
|
|
# expectation = response
|
2005-08-31 18:10:26 +02:00
|
|
|
|
#!S00000 select otto from (select 1 as otto) as t1;
|
2004-10-22 05:56:27 +02:00
|
|
|
|
|
|
|
|
|
--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;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2008-07-21 11:20:03 +02:00
|
|
|
|
# expecting a SQL-state for a command that can't give one should fail
|
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
2008-07-15 13:42:21 +02:00
|
|
|
|
--error 1
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--exec echo "disable_warnings ; error S00000; remove_file $MYSQLTEST_VARDIR/tmp/test_nonexistent.tmp;" | $MYSQL_TEST 2>&1
|
2004-10-22 05:56:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Negative case(statement)
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
2005-08-31 18:10:26 +02:00
|
|
|
|
# This syntax not allowed anymore, use --error S42S22, see below
|
2004-10-22 05:56:27 +02:00
|
|
|
|
# expectation = response
|
2005-08-31 18:10:26 +02:00
|
|
|
|
#!S42S22 select friedrich from (select 1 as otto) as t1;
|
2004-10-22 05:56:27 +02:00
|
|
|
|
--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;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1
|
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
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# of the last command sent to the server.
|
2004-10-29 14:51:56 +02:00
|
|
|
|
#
|
2009-03-03 21:34:18 +01:00
|
|
|
|
# The following test cases often initialize $mysql_errno to 1064 by
|
2004-10-29 14:51:56 +02:00
|
|
|
|
# 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;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
let $my_var= 'abc' ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
set @my_var= 'abc' ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
--disable_warnings
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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 ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
drop table if exists t1 ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
select 3 from t1 ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
eval select $mysql_errno as "after_minus_masked" ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
select 3 from t1 ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
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
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
prepare stmt from "select 3 from t1" ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
eval select $mysql_errno as "after_failing_prepare" ;
|
|
|
|
|
create table t1 ( f1 char(10));
|
|
|
|
|
|
|
|
|
|
# successful prepare
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
prepare stmt from "select 3 from t1" ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
eval select $mysql_errno as "after_successful_prepare" ;
|
|
|
|
|
|
|
|
|
|
# successful execute
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
execute stmt;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
eval select $mysql_errno as "after_successful_execute" ;
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# failing execute (table has been dropped)
|
2004-10-29 14:51:56 +02:00
|
|
|
|
drop table t1;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
execute stmt;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
eval select $mysql_errno as "after_failing_execute" ;
|
|
|
|
|
|
|
|
|
|
# failing execute (unknown statement)
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_UNKNOWN_STMT_HANDLER
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
execute __stmt_;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
eval select $mysql_errno as "after_failing_execute" ;
|
|
|
|
|
|
|
|
|
|
# successful deallocate
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
deallocate prepare stmt;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
eval select $mysql_errno as "after_successful_deallocate" ;
|
|
|
|
|
|
|
|
|
|
# failing deallocate ( statement handle does not exist )
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_UNKNOWN_STMT_HANDLER
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
deallocate prepare __stmt_;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
eval select $mysql_errno as "after_failing_deallocate" ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test cases for "--disable_abort_on_error"
|
|
|
|
|
#
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# "--disable_abort_on_error" switches off the abort of mysqltest
|
|
|
|
|
# after "unmasked" failing statements.
|
2004-10-29 14:51:56 +02:00
|
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
#
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# There are some additional test cases for $mysql_errno
|
2004-10-29 14:51:56 +02:00
|
|
|
|
# because "--disable_abort_on_error" enables a new situation.
|
|
|
|
|
# Example: "unmasked" statement fails + analysis of $mysql_errno
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# Switch off the abort on error and check the effect on $mysql_errno
|
2004-10-29 14:51:56 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
--disable_abort_on_error
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
select 3 from t1 ;
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
select 3 from t1 ;
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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 ;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $MYSQL_TEST 2>&1
|
2004-10-29 14:51:56 +02:00
|
|
|
|
|
2010-03-22 11:28:57 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Check some non-query statements that would fail
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
--exec illegal_command
|
|
|
|
|
--cat_file does_not_exist
|
|
|
|
|
--perl
|
2010-10-19 13:56:30 +02:00
|
|
|
|
exit(2);
|
2010-03-22 11:28:57 +01:00
|
|
|
|
EOF
|
|
|
|
|
|
2011-09-14 15:19:24 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Check backtick and query_get_value, result should be empty
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
let $empty= `garbage`;
|
|
|
|
|
echo $empty is empty;
|
|
|
|
|
let $empty= query_get_value(nonsense, blabla, 1);
|
|
|
|
|
echo $empty is empty;
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
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
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
garbage ;
|
|
|
|
|
--enable_abort_on_error
|
2011-08-22 13:58:49 +02:00
|
|
|
|
echo $mysql_errname;
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
|
2004-10-29 14:51:56 +02:00
|
|
|
|
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-07-28 02:22:47 +02:00
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--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
|
|
|
|
|
|
2011-09-14 15:15:36 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test --enable and --disable with ONCE
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--disable_abort_on_error ONCE
|
|
|
|
|
garbage;
|
|
|
|
|
--disable_abort_on_error ONCE
|
|
|
|
|
--remove_file DoesNotExist
|
|
|
|
|
|
|
|
|
|
--disable_result_log
|
|
|
|
|
select 2;
|
|
|
|
|
--enable_result_log ONCE
|
|
|
|
|
select 3;
|
|
|
|
|
select 5;
|
|
|
|
|
--enable_result_log
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test cumulative ONCE
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--disable_abort_on_error ONCE
|
|
|
|
|
--disable_query_log ONCE
|
|
|
|
|
select 3 from t1;
|
|
|
|
|
select 7;
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--disable_info OCNE" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--enable_connect_log ONCE
|
|
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
|
connection default;
|
|
|
|
|
disconnect con1;
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test ONCE can be combined with --error or modifiers like lowercase
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--disable_result_log ONCE
|
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
select 5 from t1;
|
|
|
|
|
|
|
|
|
|
--disable_query_log ONCE
|
|
|
|
|
--lowercase_result
|
|
|
|
|
select "CASE" as "LOWER";
|
|
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
|
--disable_query_log ONCE
|
|
|
|
|
select "xyz" as name union select "abc" as name order by name desc;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2011-09-14 15:19:24 +02:00
|
|
|
|
# Test --error with backtick operator or query_get_value
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--error 0,ER_NO_SUCH_TABLE
|
|
|
|
|
let $empty= `SELECT foo from bar`;
|
|
|
|
|
echo $empty is empty;
|
|
|
|
|
|
|
|
|
|
--error 0,ER_BAD_FIELD_ERROR
|
|
|
|
|
let $empty= query_get_value(SELECT bar as foo, baz, 1);
|
|
|
|
|
echo $empty is empty;
|
|
|
|
|
|
|
|
|
|
--error 0,ER_NO_SUCH_TABLE
|
|
|
|
|
if (!`SELECT foo from bar`) {
|
|
|
|
|
echo "Yes it's empty";
|
|
|
|
|
}
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test comments
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# This is a comment
|
|
|
|
|
# This is a ; comment
|
|
|
|
|
# This is a -- comment
|
2007-06-01 18:05:34 +02:00
|
|
|
|
# -- This is also a comment
|
|
|
|
|
# -- # This is also a comment
|
|
|
|
|
# -- This is also a ; comment
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test comments with embedded command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--echo hello
|
|
|
|
|
-- echo hello
|
|
|
|
|
-- echo ;;;;;;;;
|
|
|
|
|
|
|
|
|
|
--echo # MySQL: -- The
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test detect end of line "junk"
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# Most likely caused by a missing delimiter
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# 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"
|
2006-10-05 12:25:24 +02:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
sleep 4
|
|
|
|
|
# A comment
|
|
|
|
|
show status;
|
|
|
|
|
EOF
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Missing delimiter until eof
|
|
|
|
|
# The comment will be "sucked into" the sleep command since
|
2006-10-05 12:25:24 +02:00
|
|
|
|
# delimiter is missing
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
sleep 7
|
|
|
|
|
# Another comment
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2006-10-05 12:25:24 +02:00
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Missing delimiter until "disable_query_log"
|
|
|
|
|
#
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
disconnect default
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# comment
|
|
|
|
|
# comment 3
|
|
|
|
|
disable_query_log;
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2006-10-05 12:25:24 +02:00
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Missing delimiter until "disable_query_log"
|
|
|
|
|
#
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
disconnect default
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# comment
|
|
|
|
|
|
|
|
|
|
# comment 3
|
|
|
|
|
disable_query_log;
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2006-10-05 12:25:24 +02:00
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Missing delimiter until eof
|
|
|
|
|
#
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
disconnect default
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# comment
|
|
|
|
|
# comment2
|
|
|
|
|
|
|
|
|
|
# comment 3
|
|
|
|
|
--disable_query_log
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2006-10-05 12:25:24 +02:00
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Missing delimiter until eof
|
|
|
|
|
#
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
disconnect default # comment
|
|
|
|
|
# comment part2
|
|
|
|
|
|
|
|
|
|
# comment 3
|
|
|
|
|
--disable_query_log
|
|
|
|
|
EOF
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
#
|
|
|
|
|
# Extra delimiter
|
|
|
|
|
#
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--sleep 4;" | $MYSQL_TEST 2>&1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
2010-09-15 14:56:22 +02:00
|
|
|
|
#
|
|
|
|
|
# Extra text after ``
|
|
|
|
|
#
|
2010-09-21 11:16:20 +02:00
|
|
|
|
# Cannot use exec echo here as ` may or may not need to be escaped
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
let $x= `select 1` BOO ;
|
|
|
|
|
EOF
|
2010-09-15 14:56:22 +02:00
|
|
|
|
--error 1
|
2010-09-21 11:16:20 +02:00
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
--let $x= `select 1`;
|
|
|
|
|
EOF
|
2010-09-15 14:56:22 +02:00
|
|
|
|
--error 1
|
2010-09-21 11:16:20 +02:00
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2010-09-15 14:56:22 +02:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
# Missing ; in next line should be detected and cause failure
|
|
|
|
|
let $x= `select 1`
|
|
|
|
|
let $x= 2;
|
|
|
|
|
echo $x;
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# Allow trailing # comment
|
|
|
|
|
--sleep 1 # Wait for insert delayed to be executed.
|
2009-03-03 21:34:18 +01:00
|
|
|
|
--sleep 1 # Wait for insert delayed to be executed.
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test error
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# Missing argument
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "error;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
# First char must be uppercase 'S' or 'E' or [0-9]
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error s99999" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error e99999" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error 9eeeee" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error 1sssss" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
# First char 'S' but too long
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error S999999" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
# First char 'S' but lowercase char found
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error S99a99" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
# First char 'S' but too short
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error S9999" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
# First char 'E' but not found in error array
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error E9999" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
# First char [0-9] but contains chars
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error 999e9" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error 9b" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
# Multiple errorcodes separated by ','
|
|
|
|
|
--error 1,1,1,1
|
|
|
|
|
#--error 9,ER_PARSE_ERROR
|
|
|
|
|
#--error ER_PARSE_ERROR
|
|
|
|
|
#--error 9,ER_PARSE_ERROR,9,ER_PARSE_ERROR
|
|
|
|
|
#--error 9, ER_PARSE_ERROR, 9, ER_PARSE_ERROR
|
|
|
|
|
#--error 9,S00000,9,ER_PARSE_ERROR
|
|
|
|
|
#--error 9,S00000,9,ER_PARSE_ERROR,ER_PARSE_ERROR,ER_PARSE_ERROR,9,10,11,12
|
|
|
|
|
--error 9,S00000,9
|
|
|
|
|
--error 9,S00000,9,9,10,11,12
|
|
|
|
|
--error 9 ,10
|
|
|
|
|
--error 9 , 10
|
|
|
|
|
--error 9 , 10
|
|
|
|
|
--error 9 , 10
|
|
|
|
|
|
|
|
|
|
# Too many errorcodes specified
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test echo command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
echo MySQL;
|
|
|
|
|
echo "MySQL";
|
|
|
|
|
echo MySQL: The world''s most popular open source database;
|
|
|
|
|
echo "MySQL: The world's most popular open source database";
|
|
|
|
|
|
|
|
|
|
echo MySQL: The world''s
|
|
|
|
|
most popular open
|
|
|
|
|
source database;
|
|
|
|
|
|
|
|
|
|
echo # MySQL: The world''s
|
|
|
|
|
# most popular open
|
|
|
|
|
# source database;
|
|
|
|
|
|
|
|
|
|
echo - MySQL: The world''s
|
|
|
|
|
- most popular open
|
|
|
|
|
- source database;
|
|
|
|
|
|
|
|
|
|
echo - MySQL: The world''s
|
2006-10-03 15:33:44 +02:00
|
|
|
|
-- most popular
|
|
|
|
|
-- open source database;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
echo # MySQL: The
|
|
|
|
|
--world''s
|
|
|
|
|
# most popular
|
|
|
|
|
-- open
|
|
|
|
|
- source database;
|
|
|
|
|
|
|
|
|
|
echo "MySQL: The world's most popular; open source database";
|
|
|
|
|
echo "MySQL: The world's most popular ; open source database";
|
|
|
|
|
echo "MySQL: The world's most popular ;open source database";
|
|
|
|
|
echo echo message echo message;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo ;
|
|
|
|
|
|
|
|
|
|
# Illegal use of echo
|
|
|
|
|
|
2007-02-19 18:23:59 +01:00
|
|
|
|
#--error 1
|
|
|
|
|
#--exec echo "echo \$;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test exec command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# Illegal use of exec
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--exec " | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2010-01-20 12:51:18 +01:00
|
|
|
|
# Multi-line exec
|
|
|
|
|
exec $MYSQL
|
|
|
|
|
test -e "select 1";
|
|
|
|
|
exec $MYSQL test -e "select
|
|
|
|
|
2";
|
|
|
|
|
let $query = select 3
|
|
|
|
|
as X;
|
|
|
|
|
exec $MYSQL test -e "$query";
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test let command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
let $message=MySQL;
|
|
|
|
|
echo $message;
|
|
|
|
|
|
|
|
|
|
let $message="MySQL";
|
|
|
|
|
echo $message;
|
|
|
|
|
|
|
|
|
|
let $message= MySQL: The
|
|
|
|
|
world''s most
|
|
|
|
|
popular open
|
|
|
|
|
source database;
|
|
|
|
|
echo $message;
|
|
|
|
|
|
|
|
|
|
let $message= # MySQL: The
|
|
|
|
|
# world''s most
|
|
|
|
|
# popular open
|
|
|
|
|
# source database;
|
|
|
|
|
echo $message;
|
|
|
|
|
|
|
|
|
|
let $message= -- MySQL: The
|
|
|
|
|
-- world''s most
|
2006-10-03 15:33:44 +02:00
|
|
|
|
-- popular
|
|
|
|
|
-- open source database;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
echo $message;
|
|
|
|
|
|
|
|
|
|
let $message= # MySQL: The
|
|
|
|
|
- world''s most
|
|
|
|
|
-- popular open
|
|
|
|
|
# source database;
|
|
|
|
|
echo $message;
|
|
|
|
|
|
|
|
|
|
echo '$message';
|
|
|
|
|
echo "$message";
|
|
|
|
|
|
|
|
|
|
let $1=hej;
|
|
|
|
|
echo $1;
|
|
|
|
|
|
|
|
|
|
let $1 =hej ;
|
|
|
|
|
echo $1;
|
|
|
|
|
|
|
|
|
|
let $1 = hej;
|
|
|
|
|
echo $1;
|
|
|
|
|
|
2005-09-01 10:53:33 +02:00
|
|
|
|
let $1=1;
|
|
|
|
|
let $2=$1;
|
|
|
|
|
echo $2;
|
|
|
|
|
let $5=$6;
|
|
|
|
|
echo $5;
|
|
|
|
|
echo $6;
|
|
|
|
|
|
|
|
|
|
let $where=a long variable content;
|
|
|
|
|
echo $where;
|
|
|
|
|
|
|
|
|
|
let $where2= $where;
|
|
|
|
|
echo $where2;
|
|
|
|
|
|
|
|
|
|
let $where3=a long $where variable content;
|
|
|
|
|
echo $where3;
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
let $where3=a long \\\$where variable content;
|
|
|
|
|
echo $where3;
|
|
|
|
|
|
2005-09-01 10:53:33 +02:00
|
|
|
|
let $novar1= $novar2;
|
|
|
|
|
echo $novar1;
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
let $cat=na;
|
|
|
|
|
let $cat=ba$cat$cat;
|
|
|
|
|
echo banana = $cat;
|
|
|
|
|
|
|
|
|
|
# ba\$cat\$cat should have been sufficient.
|
|
|
|
|
# ba\\\$cat\\\$cat -> ba\$cat\$cat -> ba$cat$cat -> banana
|
|
|
|
|
# Magnus' upcoming patch will fix the missing second interpretation.
|
|
|
|
|
let $cat=ba\\\$cat\\\$cat;
|
|
|
|
|
echo Not a banana: $cat;
|
2005-09-01 10:53:33 +02:00
|
|
|
|
|
2010-08-10 12:13:58 +02:00
|
|
|
|
# Bug #55413 would cause this to fail
|
|
|
|
|
let $escape= with\`some\"escaped\'quotes;
|
|
|
|
|
echo $escape;
|
|
|
|
|
|
|
|
|
|
--let $escape= with\`some\"escaped\'quotes
|
|
|
|
|
echo $escape;
|
|
|
|
|
|
|
|
|
|
# This only works with "--let" syntax
|
|
|
|
|
--let $tick= single'tick`backtick
|
|
|
|
|
echo $tick;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# Test illegal uses of let
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "let \$=hi;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "let \$1 hi;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "let \$m hi;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "let \$hi;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "let \$ hi;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let =hi;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let hi;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2009-03-06 15:56:17 +01:00
|
|
|
|
# More advanced test for Bug#17280
|
2006-10-03 15:33:44 +02:00
|
|
|
|
let $success= 1;
|
|
|
|
|
--echo # Execute: --echo # <whatever> success: \$success
|
|
|
|
|
--echo # <whatever> success: $success
|
|
|
|
|
--echo # Execute: echo # <whatever> success: \$success ;
|
|
|
|
|
echo # <whatever> success: $success ;
|
|
|
|
|
|
|
|
|
|
--echo # The next two variants work fine and expand the content of \$success
|
|
|
|
|
--echo # Execute: --echo \$success
|
|
|
|
|
--echo $success
|
|
|
|
|
--echo # Execute: echo \$success ;
|
|
|
|
|
echo $success ;
|
|
|
|
|
|
2007-01-19 15:43:21 +01:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test to assign let from variable
|
|
|
|
|
# let $<var_name>=$<var_name>;
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--echo # Check if let \$B = \$A is an assignment per value.
|
|
|
|
|
|
|
|
|
|
# Basic preparations:
|
|
|
|
|
--echo let \$A = initial value of A;
|
|
|
|
|
let $A = initial value of A;
|
|
|
|
|
# --echo # Content of \$A is: $A
|
|
|
|
|
--echo let \$B = initial value of B;
|
|
|
|
|
let $B = initial value of B;
|
|
|
|
|
# --echo # Content of \$B is: $B
|
|
|
|
|
|
|
|
|
|
# Assign $B to $A:
|
|
|
|
|
--echo let \$B = \$A
|
|
|
|
|
let $A = $B;
|
|
|
|
|
--echo # Content of \$A is: $A
|
|
|
|
|
|
|
|
|
|
# Changes of $B must NOT affect $A and Changes of $A must NOT affect $B !
|
|
|
|
|
--echo let \$A = changed value of A;
|
|
|
|
|
let $A = changed value of A;
|
|
|
|
|
--echo # Content of \$B is: $B
|
|
|
|
|
|
|
|
|
|
--echo let \$B = changed value of B;
|
|
|
|
|
let $B = changed value of B;
|
|
|
|
|
--echo # Content of \$A is: $A
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
2007-04-04 15:09:12 +02:00
|
|
|
|
# Test let from query with $variable
|
|
|
|
|
# let $<var_name>=`<query with $variable>`;
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
let $var1=content of variable 1;
|
|
|
|
|
let $var2= `select "$var1"`;
|
|
|
|
|
let $var3= `select concat("$var1", " ", "$var2")`;
|
|
|
|
|
echo var2: $var2;
|
|
|
|
|
echo var3: $var3;
|
|
|
|
|
if (`select length("$var3") > 0`)
|
|
|
|
|
{
|
|
|
|
|
echo length of var3 is longer than 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test to assign let from query
|
|
|
|
|
# let $<var_name>=`<query>`;
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
echo var1;
|
|
|
|
|
let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`;
|
|
|
|
|
echo $var1;
|
|
|
|
|
|
|
|
|
|
echo var2;
|
|
|
|
|
let $var2= `select 2 as "Column num 2"`;
|
|
|
|
|
echo $var2;
|
|
|
|
|
|
|
|
|
|
echo var2 again;
|
|
|
|
|
let $var2= `select 2 as "Column num 2"`;
|
|
|
|
|
echo $var2;
|
|
|
|
|
|
|
|
|
|
echo var3 two columns with same name;
|
|
|
|
|
let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`;
|
|
|
|
|
echo $var3;
|
|
|
|
|
|
2007-08-06 11:20:36 +02:00
|
|
|
|
echo var4 from query that returns NULL;
|
|
|
|
|
let $var4= `select NULL`;
|
|
|
|
|
|
|
|
|
|
echo var5 from query that returns no row;
|
|
|
|
|
let $var5= `SHOW VARIABLES LIKE "nonexisting_variable"`;
|
|
|
|
|
|
|
|
|
|
echo failing query in let;
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/let.sql
|
|
|
|
|
let $var2= `failing query`;
|
|
|
|
|
echo $var2;
|
|
|
|
|
EOF
|
|
|
|
|
|
2010-11-15 14:23:02 +01:00
|
|
|
|
create table t1 (a varchar(100));
|
|
|
|
|
insert into t1 values ('`select 42`');
|
|
|
|
|
let $a= `select * from t1`;
|
|
|
|
|
# This should output `select 42`, not evaluate it again to 42
|
|
|
|
|
echo $a;
|
2011-01-11 10:54:42 +01:00
|
|
|
|
insert into t1 values ('$dollar');
|
|
|
|
|
# These should also output the string without evaluating it.
|
|
|
|
|
let $a= query_get_value(select * from t1 order by a, a, 1);
|
|
|
|
|
echo $a;
|
|
|
|
|
let $a= query_get_value(select * from t1 order by a, a, 2);
|
|
|
|
|
echo $a;
|
2010-11-15 14:23:02 +01:00
|
|
|
|
drop table t1;
|
|
|
|
|
|
2007-08-06 11:20:36 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1
|
|
|
|
|
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/let.sql;
|
|
|
|
|
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test source command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# Test illegal uses of source
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "source ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# Fix win paths
|
|
|
|
|
--replace_result \\ /
|
|
|
|
|
# Source a nonexisting file
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
# Too many source
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql
|
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $MYSQL_TEST 2>&1
|
2007-08-03 13:12:53 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/recursive.sql;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# Source a file with error
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql
|
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/error.sql;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
2005-08-16 17:10:52 +02:00
|
|
|
|
# Test execution of source in a while loop
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
|
|
|
|
|
echo here is the sourced script;
|
|
|
|
|
EOF
|
2005-08-16 17:10:52 +02:00
|
|
|
|
--disable_query_log
|
|
|
|
|
let $outer= 2; # Number of outer loops
|
|
|
|
|
while ($outer)
|
|
|
|
|
{
|
|
|
|
|
eval SELECT '$outer = outer loop variable after while' AS "";
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
|
2005-08-16 17:10:52 +02:00
|
|
|
|
|
|
|
|
|
eval SELECT '$outer = outer loop variable before dec' AS "";
|
|
|
|
|
dec $outer;
|
|
|
|
|
eval SELECT '$outer = outer loop variable after dec' AS "";
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-02 11:17:33 +02:00
|
|
|
|
# Test source in an if in a while which is false on 1st iteration
|
2010-03-02 12:39:32 +01:00
|
|
|
|
# Also test --error and --disable_abort_on_error in same context
|
2005-08-16 17:10:52 +02:00
|
|
|
|
let $outer= 2; # Number of outer loops
|
2009-09-02 11:17:33 +02:00
|
|
|
|
let $ifval= 0; # false 1st time
|
2005-08-16 17:10:52 +02:00
|
|
|
|
while ($outer)
|
|
|
|
|
{
|
2009-09-02 11:17:33 +02:00
|
|
|
|
echo outer=$outer ifval=$ifval;
|
2005-08-16 17:10:52 +02:00
|
|
|
|
|
2009-09-02 11:17:33 +02:00
|
|
|
|
if ($ifval) {
|
|
|
|
|
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
|
2009-10-08 11:30:03 +02:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
SELECT * from nowhere;
|
2011-09-14 15:15:36 +02:00
|
|
|
|
--disable_abort_on_error ONCE
|
2010-03-02 12:39:32 +01:00
|
|
|
|
# Statement giving a different error, to make sure we don't mask it
|
|
|
|
|
SELECT * FROM nowhere else;
|
2009-09-02 11:17:33 +02:00
|
|
|
|
}
|
2005-08-16 17:10:52 +02:00
|
|
|
|
dec $outer;
|
2009-09-02 11:17:33 +02:00
|
|
|
|
inc $ifval;
|
2005-08-16 17:10:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test execution of source in a while loop
|
|
|
|
|
--disable_abort_on_error
|
|
|
|
|
# Sourcing of a file within while loop, sourced file will
|
|
|
|
|
# source other file
|
|
|
|
|
let $num= 9;
|
|
|
|
|
while ($num)
|
|
|
|
|
{
|
|
|
|
|
SELECT 'In loop' AS "";
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
|
2005-08-16 17:10:52 +02:00
|
|
|
|
dec $num;
|
|
|
|
|
}
|
2005-09-06 22:03:12 +02:00
|
|
|
|
--enable_abort_on_error
|
2005-08-16 17:10:52 +02:00
|
|
|
|
--enable_query_log
|
2007-06-19 11:06:02 +02:00
|
|
|
|
|
|
|
|
|
# Test source $variable/<filename>
|
|
|
|
|
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
|
2005-08-16 17:10:52 +02:00
|
|
|
|
|
2007-08-13 15:46:11 +02:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
|
|
|
|
|
echo "hello";
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
let $x= sourced;
|
|
|
|
|
source $MYSQLTEST_VARDIR/tmp/$x.inc;
|
|
|
|
|
|
|
|
|
|
let $x= $MYSQLTEST_VARDIR;
|
|
|
|
|
source $x/tmp/sourced.inc;
|
|
|
|
|
|
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
|
|
|
|
|
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test sleep command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
sleep 0.5;
|
|
|
|
|
sleep 1;
|
|
|
|
|
real_sleep 1;
|
|
|
|
|
|
2010-02-09 18:13:57 +01:00
|
|
|
|
# Parameter from variable, legal and illegal
|
|
|
|
|
let $sleep_var= 0.1;
|
|
|
|
|
sleep $sleep_var;
|
|
|
|
|
let $sleep_var= 1;
|
|
|
|
|
--real_sleep $sleep_var
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQL_TMP_DIR/sleep.inc
|
|
|
|
|
let $sleep_var= xyz;
|
|
|
|
|
--sleep $sleep_var
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1
|
|
|
|
|
--remove_file $MYSQL_TMP_DIR/sleep.inc
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQL_TMP_DIR/sleep.inc
|
|
|
|
|
let $sleep_var= xyz;
|
|
|
|
|
real_sleep $sleep_var;
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1
|
|
|
|
|
--remove_file $MYSQL_TMP_DIR/sleep.inc
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# Missing parameter
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "sleep ;" | $MYSQL_TEST 2>&1
|
2006-03-01 00:54:11 +01:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "real_sleep ;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# Illegal parameter
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "sleep abc;" | $MYSQL_TEST 2>&1
|
2006-03-01 00:54:11 +01:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "real_sleep abc;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test inc
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2010-09-27 14:36:16 +02:00
|
|
|
|
let $i= 0;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
inc $i;
|
|
|
|
|
echo $i;
|
|
|
|
|
let $i=100;
|
|
|
|
|
inc $i;
|
|
|
|
|
echo $i;
|
2010-09-27 14:36:16 +02:00
|
|
|
|
let $i= -100;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
inc $i;
|
|
|
|
|
echo $i;
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "inc;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "inc i;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
2010-09-27 14:36:16 +02:00
|
|
|
|
--exec echo "inc \$i;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
|
2010-09-27 14:36:16 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$i=text; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$i=10cc; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
inc $i; inc $i; inc $i; --echo $i
|
|
|
|
|
echo $i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test dec
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
2010-09-27 14:36:16 +02:00
|
|
|
|
let $d= 0;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
dec $d;
|
|
|
|
|
echo $d;
|
|
|
|
|
let $d=100;
|
|
|
|
|
dec $d;
|
|
|
|
|
echo $d;
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "dec;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "dec i;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
2010-09-27 14:36:16 +02:00
|
|
|
|
--exec echo "dec \$i;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
|
2010-09-27 14:36:16 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$i=text; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$i=10cc; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test system
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2007-02-19 12:03:42 +01:00
|
|
|
|
#system ls > /dev/null;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
system echo "hej" > /dev/null;
|
2007-02-19 12:03:42 +01:00
|
|
|
|
#--system ls > /dev/null
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--system echo "hej" > /dev/null;
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "system;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2011-09-14 15:15:36 +02:00
|
|
|
|
--disable_abort_on_error ONCE
|
2006-10-03 15:33:44 +02:00
|
|
|
|
system NonExistsinfComamdn 2> /dev/null;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test delimiter
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
delimiter stop;
|
|
|
|
|
echo teststop
|
|
|
|
|
delimiter ;stop
|
|
|
|
|
echo test2;
|
|
|
|
|
--delimiter stop
|
|
|
|
|
echo test3stop
|
|
|
|
|
--delimiter ;
|
|
|
|
|
echo test4;
|
|
|
|
|
|
2010-01-20 14:18:27 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test that delimiter within if() works in in various combinations
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
|
{
|
|
|
|
|
delimiter ||;
|
|
|
|
|
echo false-inner||
|
|
|
|
|
if (0)
|
|
|
|
|
{
|
|
|
|
|
delimiter *||
|
|
|
|
|
echo false-innerer*
|
|
|
|
|
delimiter ||*
|
|
|
|
|
}
|
|
|
|
|
echo false-inner again||
|
|
|
|
|
}
|
|
|
|
|
echo outer;
|
|
|
|
|
if (1)
|
|
|
|
|
{
|
|
|
|
|
delimiter /;
|
|
|
|
|
echo true-inner/
|
|
|
|
|
if (0)
|
|
|
|
|
{
|
|
|
|
|
delimiter %/
|
|
|
|
|
echo true-innerer%
|
|
|
|
|
}
|
|
|
|
|
echo true-inner again/
|
|
|
|
|
}
|
|
|
|
|
echo true-outer/
|
|
|
|
|
delimiter ;/
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test if
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
let $counter=10;
|
|
|
|
|
if ($counter)
|
|
|
|
|
{
|
|
|
|
|
echo Counter is greater than 0, (counter=10);
|
|
|
|
|
}
|
|
|
|
|
if (!$counter)
|
|
|
|
|
{
|
|
|
|
|
echo Counter is not 0, (counter=10);
|
|
|
|
|
}
|
2010-11-17 16:05:52 +01:00
|
|
|
|
if (! $counter)
|
|
|
|
|
{
|
|
|
|
|
let $counter=5;
|
|
|
|
|
}
|
|
|
|
|
echo Counter should still be 10, is $counter;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
let $counter=0;
|
2007-08-08 18:03:44 +02:00
|
|
|
|
if($counter)
|
2006-10-03 15:33:44 +02:00
|
|
|
|
{
|
|
|
|
|
echo Counter is greater than 0, (counter=0);
|
|
|
|
|
}
|
|
|
|
|
if (!$counter)
|
|
|
|
|
{
|
|
|
|
|
echo Counter is not 0, (counter=0);
|
|
|
|
|
}
|
2010-11-17 16:05:52 +01:00
|
|
|
|
if (! $counter)
|
|
|
|
|
{
|
|
|
|
|
echo Not space var works;
|
|
|
|
|
}
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
2010-08-03 16:11:23 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test if with some non-numerics
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
let $counter=alpha;
|
|
|
|
|
if ($counter)
|
|
|
|
|
{
|
|
|
|
|
echo Counter is true, (counter=alpha);
|
|
|
|
|
}
|
|
|
|
|
let $counter= ;
|
|
|
|
|
if ($counter)
|
|
|
|
|
{
|
|
|
|
|
echo oops, space is true;
|
|
|
|
|
}
|
2010-08-04 10:52:45 +02:00
|
|
|
|
let $counter=-0;
|
|
|
|
|
if ($counter)
|
|
|
|
|
{
|
|
|
|
|
echo oops, -0 is true;
|
|
|
|
|
}
|
2010-11-10 09:42:14 +01:00
|
|
|
|
# This is no longer allowed, as a precaution against mistyped conditionals
|
|
|
|
|
# if (beta)
|
|
|
|
|
# {
|
|
|
|
|
# echo Beta is true;
|
|
|
|
|
# }
|
2010-08-04 10:52:45 +02:00
|
|
|
|
let $counter=gamma;
|
|
|
|
|
while ($counter)
|
|
|
|
|
{
|
|
|
|
|
echo while with string, only once;
|
|
|
|
|
let $counter=000;
|
|
|
|
|
}
|
2010-08-03 16:11:23 +02:00
|
|
|
|
|
2010-11-10 09:42:14 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test if with compare conditions
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
let $ifvar= 5;
|
|
|
|
|
let $ifvar2= 6;
|
|
|
|
|
|
|
|
|
|
if ($ifvar < 7)
|
|
|
|
|
{
|
|
|
|
|
echo 5<7;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar< 7)
|
|
|
|
|
{
|
|
|
|
|
echo 5<7 again;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar<7)
|
|
|
|
|
{
|
|
|
|
|
echo 5<7 still;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar < $ifvar2)
|
|
|
|
|
{
|
|
|
|
|
echo 5<6;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar <= 4)
|
|
|
|
|
{
|
|
|
|
|
echo 5<=4;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar >= 5)
|
|
|
|
|
{
|
|
|
|
|
echo 5>=5;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar>=5)
|
|
|
|
|
{
|
|
|
|
|
echo 5>=5 again;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar > 3)
|
|
|
|
|
{
|
|
|
|
|
echo 5>3;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar == 4)
|
|
|
|
|
{
|
|
|
|
|
echo 5==4;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar == 5)
|
|
|
|
|
{
|
|
|
|
|
echo 5==5;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar != 8)
|
|
|
|
|
{
|
|
|
|
|
echo 5!=8;
|
|
|
|
|
}
|
|
|
|
|
# Any number should compare unequal to any string
|
|
|
|
|
if ($ifvar != five)
|
|
|
|
|
{
|
|
|
|
|
echo 5!=five;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar == `SELECT 3+2`)
|
|
|
|
|
{
|
|
|
|
|
echo 5==3+2;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar == 5)
|
|
|
|
|
{
|
|
|
|
|
echo 5 == 5;
|
|
|
|
|
}
|
|
|
|
|
let $ifvar= hello;
|
|
|
|
|
if ($ifvar == hello there)
|
|
|
|
|
{
|
|
|
|
|
echo hello == hello there;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar == hello)
|
|
|
|
|
{
|
|
|
|
|
echo hello == hello;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar == hell)
|
|
|
|
|
{
|
|
|
|
|
echo hello == hell;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar == hello)
|
|
|
|
|
{
|
|
|
|
|
echo hello == hello;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar != goodbye)
|
|
|
|
|
{
|
|
|
|
|
echo hello != goodbye;
|
|
|
|
|
}
|
2010-11-26 10:57:01 +01:00
|
|
|
|
let $ifvar= 'quoted';
|
|
|
|
|
if ($ifvar == ''quoted'')
|
|
|
|
|
{
|
|
|
|
|
echo 'quoted' == ''quoted'';
|
|
|
|
|
}
|
2010-11-10 09:42:14 +01:00
|
|
|
|
let $ifvar= two words;
|
|
|
|
|
if ($ifvar == two words)
|
|
|
|
|
{
|
|
|
|
|
echo two words;
|
|
|
|
|
}
|
2010-11-26 10:57:01 +01:00
|
|
|
|
if ($ifvar == 'two words')
|
|
|
|
|
{
|
|
|
|
|
echo 'two words';
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar == "two words")
|
|
|
|
|
{
|
|
|
|
|
echo "two words";
|
|
|
|
|
}
|
2010-11-10 09:42:14 +01:00
|
|
|
|
if ($ifvar == `SELECT 'two words'`)
|
|
|
|
|
{
|
|
|
|
|
echo two words are two words;
|
|
|
|
|
}
|
|
|
|
|
if (42)
|
|
|
|
|
{
|
|
|
|
|
echo right answer;
|
|
|
|
|
}
|
|
|
|
|
if (0)
|
|
|
|
|
{
|
|
|
|
|
echo wrong answer;
|
|
|
|
|
}
|
|
|
|
|
# Non-empty string treated as 'true'
|
|
|
|
|
if (`SELECT 'something'`)
|
|
|
|
|
{
|
|
|
|
|
echo anything goes;
|
|
|
|
|
}
|
|
|
|
|
# Make sure 0 and string compare right
|
|
|
|
|
let $ifvar= 0;
|
|
|
|
|
if ($ifvar == string)
|
|
|
|
|
{
|
|
|
|
|
echo 0 == string;
|
|
|
|
|
}
|
|
|
|
|
if ($ifvar != string)
|
|
|
|
|
{
|
|
|
|
|
echo 0 != string;
|
|
|
|
|
}
|
|
|
|
|
--write_file $MYSQL_TMP_DIR/mysqltest.sql
|
|
|
|
|
let $var= 5;
|
|
|
|
|
if ($var >= four)
|
|
|
|
|
{
|
|
|
|
|
echo 5>=four;
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
|
|
|
|
|
remove_file $MYSQL_TMP_DIR/mysqltest.sql;
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQL_TMP_DIR/mysqltest.sql
|
|
|
|
|
let $var= 5;
|
|
|
|
|
if ($var ~= 6)
|
|
|
|
|
{
|
|
|
|
|
echo 5~=6;
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
|
|
|
|
|
remove_file $MYSQL_TMP_DIR/mysqltest.sql;
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQL_TMP_DIR/mysqltest.sql
|
|
|
|
|
let $var= text;
|
|
|
|
|
if (var == text)
|
|
|
|
|
{
|
|
|
|
|
echo Oops I forgot the $;
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
|
|
|
|
|
remove_file $MYSQL_TMP_DIR/mysqltest.sql;
|
|
|
|
|
|
2010-12-09 12:15:25 +01:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "if (\$var ==) {" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "if (\$var > ) {" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2010-11-10 09:42:14 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test while with compare conditions
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
let $counter= 2;
|
|
|
|
|
|
|
|
|
|
while ($counter < 5)
|
|
|
|
|
{
|
|
|
|
|
echo counter is $counter;
|
|
|
|
|
inc $counter;
|
|
|
|
|
}
|
|
|
|
|
let $ifvar=;
|
|
|
|
|
while ($ifvar != stop)
|
|
|
|
|
{
|
|
|
|
|
if ($counter >= 7)
|
|
|
|
|
{
|
|
|
|
|
let $ifvar= stop;
|
|
|
|
|
}
|
|
|
|
|
echo counter is $counter;
|
|
|
|
|
inc $counter;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test while, { and }
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
let $i=1;
|
|
|
|
|
while ($i)
|
|
|
|
|
{
|
|
|
|
|
echo $i;
|
|
|
|
|
dec $i;
|
|
|
|
|
}
|
|
|
|
|
# One liner
|
|
|
|
|
#let $i=1;while ($i){echo $i;dec $i;}
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
let $i=0;
|
|
|
|
|
while (!$i)
|
|
|
|
|
{
|
|
|
|
|
echo Testing while with not;
|
|
|
|
|
inc $i;
|
|
|
|
|
}
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
|
|
|
|
# Exceed max nesting level
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
|
|
|
|
|
let $1 = 10;
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
while ($1)
|
|
|
|
|
{
|
|
|
|
|
echo $1;
|
|
|
|
|
dec $1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
# Fix win path
|
|
|
|
|
--replace_result \\ / $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--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
|
2005-09-05 22:40:13 +02:00
|
|
|
|
|
2007-02-19 12:03:42 +01:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
while (0)
|
|
|
|
|
echo hej;
|
|
|
|
|
EOF
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2005-09-05 22:40:13 +02:00
|
|
|
|
|
2007-02-19 12:03:42 +01:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
while (0)
|
|
|
|
|
{echo hej;
|
|
|
|
|
EOF
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2005-09-05 22:40:13 +02:00
|
|
|
|
|
2007-02-19 12:03:42 +01:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
while (0){
|
|
|
|
|
echo hej;
|
|
|
|
|
EOF
|
2005-07-15 17:51:43 +02:00
|
|
|
|
--error 1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
|
|
|
|
|
2005-08-31 17:16:05 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# 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 b
|
|
|
|
|
select "a" as col1, "c" as col2;
|
|
|
|
|
|
|
|
|
|
--replace_result a b c d
|
|
|
|
|
select "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
|
2008-08-04 21:54:44 +02:00
|
|
|
|
--exec echo "replace_result a b; echo OK; exit;" | $MYSQL_TEST 2>&1
|
2005-08-31 17:16:05 +02:00
|
|
|
|
--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 b
|
|
|
|
|
select "a" as col1, "c" as col2;
|
|
|
|
|
|
|
|
|
|
--replace_column 1 b 2 d
|
|
|
|
|
select "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
|
|
|
|
|
|
2010-01-20 12:52:35 +01:00
|
|
|
|
let $long_rep= 1234567890123456789012345678901234567890;
|
|
|
|
|
let $long_rep= $long_rep,$long_rep;
|
|
|
|
|
let $long_rep= $long_rep,$long_rep;
|
|
|
|
|
let $long_rep= $long_rep,$long_rep;
|
|
|
|
|
let $long_rep= $long_rep,$long_rep;
|
|
|
|
|
let $long_rep= $long_rep,$long_rep;
|
|
|
|
|
|
|
|
|
|
# This tests from strings > 1024 (here 1311)
|
|
|
|
|
|
|
|
|
|
--replace_result $long_rep LONG_STRING
|
|
|
|
|
eval select "$long_rep" as x;
|
2005-08-31 17:16:05 +02:00
|
|
|
|
|
2011-11-08 15:55:25 +01:00
|
|
|
|
# Test replace within ``
|
|
|
|
|
|
|
|
|
|
--replace_result cat dog
|
|
|
|
|
--let $animal= `select "cat" as pet`
|
|
|
|
|
--echo $animal
|
|
|
|
|
|
2005-08-31 17:16:05 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test sync_with_master
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
--error 1
|
2007-05-31 15:58:22 +02:00
|
|
|
|
--exec echo "sync_with_master 10!;" | $MYSQL_TEST 2>&1
|
2005-08-31 17:16:05 +02:00
|
|
|
|
--error 1
|
2007-05-31 15:58:22 +02:00
|
|
|
|
--exec echo "sync_with_master a;" | $MYSQL_TEST 2>&1
|
2005-08-31 17:16:05 +02:00
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# 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,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
|
|
|
|
|
|
2007-07-13 06:45:54 +02:00
|
|
|
|
# Repeat connect/disconnect
|
2007-02-19 12:03:42 +01:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
let $i=200;
|
|
|
|
|
while ($i)
|
|
|
|
|
{
|
|
|
|
|
connect (test_con1,localhost,root,,);
|
|
|
|
|
disconnect test_con1;
|
|
|
|
|
dec $i;
|
|
|
|
|
}
|
2010-09-22 10:57:10 +02:00
|
|
|
|
echo 200 connects succeeded;
|
2007-02-19 12:03:42 +01:00
|
|
|
|
EOF
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
# Select disconnected connection
|
2007-02-19 12:03:42 +01:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
connect (test_con1,localhost,root,,);
|
|
|
|
|
disconnect test_con1;
|
|
|
|
|
connection test_con1;
|
|
|
|
|
EOF
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
# Connection name already used
|
2007-02-19 12:03:42 +01:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
|
|
|
|
|
connect (test_con1,localhost,root,,);
|
|
|
|
|
connect (test_con1,localhost,root,,);
|
|
|
|
|
EOF
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# connect when "disable_abort_on_error" caused "connection not found"
|
|
|
|
|
--disable_abort_on_error
|
|
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
|
connection default;
|
|
|
|
|
connection con1;
|
2006-12-14 23:51:37 +01:00
|
|
|
|
disconnect con1;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--enable_abort_on_error
|
2005-09-05 16:50:32 +02:00
|
|
|
|
|
2006-12-14 23:51:37 +01:00
|
|
|
|
# Test connect without a database
|
|
|
|
|
connect (con2,localhost,root,,*NO-ONE*);
|
|
|
|
|
--error ER_NO_DB_ERROR
|
|
|
|
|
show tables;
|
|
|
|
|
disconnect con2;
|
|
|
|
|
connection default;
|
|
|
|
|
|
2010-09-22 10:57:10 +02:00
|
|
|
|
# Test enable_connect_log
|
|
|
|
|
--enable_connect_log
|
|
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
|
connection default;
|
|
|
|
|
connection con1;
|
|
|
|
|
--disable_query_log
|
|
|
|
|
# These should not be logged
|
|
|
|
|
connect (con2,localhost,root,,*NO-ONE*);
|
|
|
|
|
connection con2;
|
|
|
|
|
disconnect con2;
|
|
|
|
|
connection con1;
|
|
|
|
|
--enable_query_log
|
|
|
|
|
disconnect con1;
|
|
|
|
|
connection default;
|
|
|
|
|
--disable_connect_log
|
|
|
|
|
|
2005-09-05 16:50:32 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test mysqltest arguments
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# -x <file_name>, use the file specified after -x as the test file
|
2005-09-20 14:11:58 +02:00
|
|
|
|
--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
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# Fix Win paths
|
|
|
|
|
--replace_result \\ /
|
2005-09-20 14:11:58 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST -x non_existing_file.inc 2>&1
|
2005-09-05 16:50:32 +02:00
|
|
|
|
|
|
|
|
|
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-03-03 21:34:18 +01:00
|
|
|
|
# TODO Test queries, especially their errormessages... so it's easy to debug
|
2005-07-15 17:51:43 +02:00
|
|
|
|
# new scripts and diagnose errors
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
2005-09-01 09:34:40 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-03-06 15:56:17 +01:00
|
|
|
|
# Test Bug#12386
|
2005-09-01 09:34:40 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
let $num= 2;
|
|
|
|
|
while ($num)
|
|
|
|
|
{
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2005-09-01 09:34:40 +02:00
|
|
|
|
failing_statement;
|
|
|
|
|
|
|
|
|
|
dec $num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SELECT 1 as a;
|
2005-07-15 17:51:43 +02:00
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
#
|
2009-03-06 15:56:17 +01:00
|
|
|
|
# Bug#10251 Identifiers containing quotes not handled correctly
|
2006-10-03 15:33:44 +02:00
|
|
|
|
#
|
|
|
|
|
select 1 as `a'b`, 2 as `a"b`;
|
|
|
|
|
|
|
|
|
|
# Test escaping of quotes
|
|
|
|
|
select '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 set
|
|
|
|
|
let $message= Here comes a message;
|
|
|
|
|
--source include/show_msg.inc
|
|
|
|
|
|
|
|
|
|
# The message could also contain a string with character set utf8
|
|
|
|
|
let $message= `SELECT USER()`;
|
|
|
|
|
--source include/show_msg.inc
|
|
|
|
|
|
|
|
|
|
# The message contains more then 80 characters on multiple lines
|
|
|
|
|
# and is kept between double quotes.
|
2009-03-03 21:34:18 +01:00
|
|
|
|
let $message=
|
2006-10-03 15:33:44 +02:00
|
|
|
|
"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_log
|
|
|
|
|
select "this will not be executed";
|
|
|
|
|
--enable_parsing
|
|
|
|
|
select "this will be executed";
|
|
|
|
|
--enable_query_log
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Test zero length result file. Should not pass
|
|
|
|
|
#
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--exec echo '' > $MYSQLTEST_VARDIR/tmp/zero_length_file.result
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
|
|
|
|
|
--error 1
|
2007-08-03 13:12:53 +02:00
|
|
|
|
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--disable_warnings
|
2007-10-05 19:28:09 +02:00
|
|
|
|
--error 0,1
|
2009-03-02 11:03:13 +01:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject;
|
2007-10-05 19:28:09 +02:00
|
|
|
|
--error 0,1
|
2009-03-06 15:56:17 +01:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.log;
|
|
|
|
|
--error 0,1
|
2007-10-05 19:28:09 +02:00
|
|
|
|
remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject;
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--enable_warnings
|
2007-08-03 13:12:53 +02:00
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
#
|
|
|
|
|
# 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
|
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/query.sql;
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
#
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
#
|
2009-03-06 15:56:17 +01:00
|
|
|
|
# Bug#11731 mysqltest in multi-statement queries ignores errors in
|
|
|
|
|
# non-1st queries
|
2006-10-03 15:33:44 +02:00
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
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>&1
|
|
|
|
|
drop table t1;
|
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--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
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error 1
|
|
|
|
|
--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
|
2006-10-03 15:33:44 +02:00
|
|
|
|
drop 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
|
2008-08-04 21:54:44 +02:00
|
|
|
|
--exec echo "exit;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
# These two should work since the error is expected
|
|
|
|
|
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
|
|
|
|
|
drop 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
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
|
2006-10-03 15:33:44 +02:00
|
|
|
|
drop table t1;
|
2007-08-03 13:12:53 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
|
2007-08-13 15:46:11 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
|
2007-08-03 13:12:53 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
#
|
2009-03-06 15:56:17 +01:00
|
|
|
|
# Bug#19890 mysqltest "query" command is broken
|
2006-10-03 15:33:44 +02:00
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# It should be possible to use the command "query" to force mysqltest to
|
|
|
|
|
# send the command to the server although it's a builtin mysqltest command.
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
query sleep;
|
|
|
|
|
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_PARSE_ERROR
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--query sleep
|
|
|
|
|
|
|
|
|
|
# Just an empty query command
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_EMPTY_QUERY
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
query ;
|
|
|
|
|
|
|
|
|
|
# test for replace_regex
|
|
|
|
|
--replace_regex /at/b/
|
|
|
|
|
select "at" as col1, "c" as col2;
|
|
|
|
|
|
|
|
|
|
--replace_regex /at/b/i
|
|
|
|
|
select "at" as col1, "AT" as col2, "c" as col3;
|
|
|
|
|
|
|
|
|
|
--replace_regex /a/b/ /ct/d/
|
2009-03-03 21:34:18 +01:00
|
|
|
|
select "a" as col1, "ct" as col2;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
|
|
|
|
|
select "strawberry","blueberry","potato";
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--replace_regex a" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--replace_regex a;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "replace_regex a;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "replace_regex a ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "replace_regex a b; echo OK;" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--replace_regex /a b c" | $MYSQL_TEST 2>&1
|
|
|
|
|
--error 1
|
2009-03-03 21:34:18 +01:00
|
|
|
|
--exec echo "replace_regex /a /b c ;" | $MYSQL_TEST 2>&1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
# REQUIREMENT
|
|
|
|
|
# replace_regex should replace substitutions from left to right in output
|
|
|
|
|
|
|
|
|
|
create table t1 (a int, b int);
|
|
|
|
|
insert into t1 values (1,3);
|
|
|
|
|
insert into t1 values (2,4);
|
|
|
|
|
--replace_regex /A/C/ /B/D/i /3/2/ /2/1/
|
|
|
|
|
select * from t1;
|
|
|
|
|
drop table t1;
|
|
|
|
|
|
2011-11-08 15:55:25 +01:00
|
|
|
|
# Test usage with ``
|
|
|
|
|
|
|
|
|
|
--replace_regex /x/y/
|
|
|
|
|
--let $result= `select "x" as col`
|
|
|
|
|
--echo $result
|
|
|
|
|
|
|
|
|
|
# Test usage with a variable as pattern list
|
|
|
|
|
|
|
|
|
|
--disable_query_log
|
|
|
|
|
--let $patt= /a /b / /less/more/
|
|
|
|
|
--replace_regex $patt
|
|
|
|
|
select "a is a and less is more" as txt;
|
|
|
|
|
--let $patt=
|
|
|
|
|
--replace_regex $patt
|
|
|
|
|
select "a is a and less is more" as txt;
|
|
|
|
|
--enable_query_log
|
|
|
|
|
|
2011-10-19 09:23:52 +02:00
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
# BUG #11754855 : Passing variable to --error
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
create table t2 ( a char(10));
|
|
|
|
|
let $errno1=0;
|
|
|
|
|
let $errno2=ER_PARSE_ERROR;
|
|
|
|
|
let $errno3=ER_NO_SUCH_TABLE;
|
|
|
|
|
--error $errno2
|
|
|
|
|
garbage;
|
|
|
|
|
|
|
|
|
|
--error $errno2,$errno3
|
|
|
|
|
garbage;
|
|
|
|
|
|
|
|
|
|
--error $errno2,ER_NO_SUCH_TABLE
|
|
|
|
|
garbage;
|
|
|
|
|
|
|
|
|
|
--error ER_NO_SUCH_TABLE,$errno2
|
|
|
|
|
insert into t1 values ("Abcd");
|
|
|
|
|
|
|
|
|
|
--error $errno1,ER_PARSE_ERROR
|
|
|
|
|
garbage;
|
|
|
|
|
|
2012-07-16 04:14:53 +02:00
|
|
|
|
let $errno_multi = $errno1,ER_NO_SUCH_TABLE,$errno2,1062;
|
|
|
|
|
|
|
|
|
|
--error $errno_multi
|
|
|
|
|
SELECT * FROM non_existing_table;
|
|
|
|
|
|
2011-10-19 09:23:52 +02:00
|
|
|
|
drop table t2;
|
|
|
|
|
|
|
|
|
|
|
2010-01-06 09:47:25 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Tests of send
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
create table t1 ( f1 char(10));
|
|
|
|
|
insert into t1 values ("Abcd");
|
|
|
|
|
|
|
|
|
|
# 1. Basic test
|
|
|
|
|
|
|
|
|
|
send select * from t1;
|
|
|
|
|
reap;
|
|
|
|
|
|
|
|
|
|
# 2. Test with error
|
|
|
|
|
|
|
|
|
|
--send select * from t2;
|
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
--reap
|
|
|
|
|
|
|
|
|
|
# 3. test send of next stmt
|
|
|
|
|
|
|
|
|
|
--send
|
|
|
|
|
select * from t1;
|
|
|
|
|
--reap
|
|
|
|
|
|
|
|
|
|
# 4. Non-query stmt betwen send and reap allowed
|
|
|
|
|
|
|
|
|
|
--send select * from t1;
|
|
|
|
|
--sleep 0.05
|
|
|
|
|
--echo Result coming up
|
|
|
|
|
--reap
|
|
|
|
|
|
|
|
|
|
# 5. Test of send_eval
|
|
|
|
|
|
|
|
|
|
--let $my_stmt= select * from t1;
|
|
|
|
|
--send_eval $my_stmt
|
|
|
|
|
--reap
|
|
|
|
|
|
|
|
|
|
# 6. Test that mysqltest does not allow query stmt between send and reap
|
|
|
|
|
# Untestable directly as it causes mysqltest to fail
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.in
|
|
|
|
|
--send select * from t1;
|
|
|
|
|
select 1;
|
|
|
|
|
--reap
|
|
|
|
|
EOF
|
|
|
|
|
--error 1
|
2010-03-03 11:17:00 +01:00
|
|
|
|
# Must filter unpredictable extra warning from output
|
|
|
|
|
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.in > $MYSQL_TMP_DIR/mysqltest.out 2>&1
|
|
|
|
|
--perl
|
|
|
|
|
my $dir= $ENV{'MYSQL_TMP_DIR'};
|
|
|
|
|
open (FILE, "$dir/mysqltest.out");
|
|
|
|
|
while (<FILE>) {
|
|
|
|
|
print unless /Note: net_clear/; # This shows up on rare occations
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
remove_file $MYSQL_TMP_DIR/mysqltest.out;
|
2010-01-06 09:47:25 +01:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.in;
|
|
|
|
|
|
|
|
|
|
drop table t1;
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for remove_file
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--disable_warnings
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "remove_file ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
remove_file non_existing_file;
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--enable_warnings
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
2010-02-04 13:15:42 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for remove_files_wildcard
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "remove_files_wildcard ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
remove_files_wildcard non_existing_dir;
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
remove_files_wildcard non_existing_dir non_existing_file;
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for write_file
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "write_file ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "write_file filename ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2007-02-19 12:03:42 +01:00
|
|
|
|
# Comment out this test as it confuses cmd.exe with unmatched "
|
|
|
|
|
#--error 1
|
|
|
|
|
#--exec echo "write_file filename \";" | $MYSQL_TEST 2>&1
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
|
|
|
|
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
Content for test_file1
|
|
|
|
|
EOF
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
2007-08-08 16:44:01 +02:00
|
|
|
|
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
|
|
|
|
|
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER;
|
|
|
|
|
Content for test_file1 contains EOF
|
|
|
|
|
END_DELIMITER
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
2007-08-07 11:40:03 +02:00
|
|
|
|
|
2010-09-15 14:48:15 +02:00
|
|
|
|
# write to already existing file
|
2007-08-07 11:40:03 +02:00
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
|
2007-02-19 16:39:50 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for append_file
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
Content for test_file1
|
|
|
|
|
EOF
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
|
|
|
|
|
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
Appended text
|
|
|
|
|
EOF
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
Appended text on nonexisting file
|
|
|
|
|
EOF
|
|
|
|
|
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
|
2009-09-02 11:17:33 +02:00
|
|
|
|
# Test append_file within while
|
|
|
|
|
let $outer= 2; # Number of outer loops
|
|
|
|
|
while ($outer)
|
|
|
|
|
{
|
|
|
|
|
append_file $MYSQLTEST_VARDIR/tmp/app_while.tmp;
|
|
|
|
|
These lines should be repeated,
|
|
|
|
|
if things work as expected
|
|
|
|
|
EOF
|
|
|
|
|
dec $outer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cat_file $MYSQLTEST_VARDIR/tmp/app_while.tmp;
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/app_while.tmp;
|
|
|
|
|
|
2007-02-19 18:19:47 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for cat_file
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp
|
|
|
|
|
Some data
|
|
|
|
|
for cat_file command
|
|
|
|
|
of mysqltest
|
|
|
|
|
EOF
|
|
|
|
|
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
2007-02-19 18:19:47 +01:00
|
|
|
|
|
2010-12-01 11:11:16 +01:00
|
|
|
|
--replace_regex /my_errno=[0-9]*/(my_errno)/
|
2007-02-19 18:19:47 +01:00
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "cat_file non_existing_file;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2007-02-20 18:20:58 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for diff_files
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
|
|
|
|
|
Some data
|
|
|
|
|
for diff_file command
|
|
|
|
|
of mysqltest
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
|
|
|
|
|
Some data
|
|
|
|
|
for diff_file command
|
|
|
|
|
of mysqltest
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
|
|
|
|
|
Some other data
|
|
|
|
|
for diff_file command
|
|
|
|
|
of mysqltest
|
|
|
|
|
EOF
|
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/diff4.tmp
|
|
|
|
|
Some data
|
|
|
|
|
for diff_file command
|
|
|
|
|
of musqltest
|
|
|
|
|
EOF
|
|
|
|
|
|
2007-02-20 18:20:58 +01:00
|
|
|
|
# Compare equal files
|
|
|
|
|
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
|
|
|
|
|
--diff_files $MYSQLTEST_VARDIR/tmp/diff2.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
|
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
# Compare files that differ in size
|
|
|
|
|
--error 2
|
|
|
|
|
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp
|
|
|
|
|
--error 2
|
|
|
|
|
--diff_files $MYSQLTEST_VARDIR/tmp/diff3.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
|
|
|
|
|
|
|
|
|
|
# Compare files that differ only in content
|
2007-02-20 18:20:58 +01:00
|
|
|
|
--error 1
|
2007-08-03 13:12:53 +02:00
|
|
|
|
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff4.tmp
|
2007-02-20 18:20:58 +01:00
|
|
|
|
--error 1
|
2007-08-03 13:12:53 +02:00
|
|
|
|
--diff_files $MYSQLTEST_VARDIR/tmp/diff4.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
|
2007-02-20 18:20:58 +01:00
|
|
|
|
|
|
|
|
|
# Compare equal files, again...
|
|
|
|
|
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
|
|
|
|
|
|
2007-08-03 13:12:53 +02:00
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
|
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
|
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
|
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/diff4.tmp
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for file_exist
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "file_exists ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--disable_warnings
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--error 0,1
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--enable_warnings
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--error 1
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
Content for test_file1
|
|
|
|
|
EOF
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
--error 1
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for copy_file
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
|
|
|
|
|
file1
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
copy_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "copy_file ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2009-05-27 22:54:40 +02:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for move_file
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# - Check that if source file does not exist, nothing will be created.
|
|
|
|
|
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--disable_warnings
|
2009-05-27 22:54:40 +02:00
|
|
|
|
--error 1
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
|
|
|
|
--error 1
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
--error 1
|
|
|
|
|
move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
--error 1
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
|
|
|
|
--error 1
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
2010-09-15 14:48:15 +02:00
|
|
|
|
--enable_warnings
|
2009-05-27 22:54:40 +02:00
|
|
|
|
|
|
|
|
|
# - Check that if source file exists, everything works properly.
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
|
|
|
|
|
file1
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
--error 1
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
|
|
|
|
|
# - Check that if destination file exists, everything works properly.
|
|
|
|
|
# (file2.tmp exists from the previous check; file1.tmp needs to be created)
|
|
|
|
|
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
|
|
|
|
|
file1
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
--error 1
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
|
|
|
|
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp;
|
|
|
|
|
|
|
|
|
|
# - Check usage.
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "move_file ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "move_file from_file;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2006-11-30 10:54:50 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for chmod
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
|
|
|
|
|
file1
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
|
|
|
|
# The below write fails, but --error is not implemented
|
|
|
|
|
# for write_file
|
|
|
|
|
#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
|
|
|
|
|
#test should fail
|
|
|
|
|
#EOF
|
|
|
|
|
|
|
|
|
|
chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
2007-08-07 11:40:03 +02:00
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
2006-11-30 10:54:50 +01:00
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
|
|
|
|
|
test2
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "chmod ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "chmod 0 from_file;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "chmod 08 from_file;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "chmod from_file;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "chmod ABZD from_file;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "chmod 06789 from_file;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for perl
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
--perl
|
|
|
|
|
print "hello\n";
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
--perl EOF
|
|
|
|
|
print "hello\n";
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
--perl DELIMITER
|
|
|
|
|
print "hello\n";
|
|
|
|
|
DELIMITER
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "perl TOO_LONG_DELIMITER ;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
perl;
|
|
|
|
|
print "hello\n";
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
perl;
|
|
|
|
|
# Print "hello"
|
|
|
|
|
print "hello\n";
|
|
|
|
|
EOF
|
|
|
|
|
|
2009-11-11 12:46:19 +01:00
|
|
|
|
# Test perl within while, also with if being false first iteration
|
|
|
|
|
let $outer= 3;
|
|
|
|
|
let $ifval= 0;
|
|
|
|
|
while ($outer) {
|
|
|
|
|
if ($ifval) {
|
|
|
|
|
perl UNTIL;
|
|
|
|
|
my $val= 5;
|
|
|
|
|
print "val is $val\n";
|
|
|
|
|
UNTIL
|
|
|
|
|
}
|
|
|
|
|
inc $ifval;
|
|
|
|
|
dec $outer;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-19 13:34:09 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for die
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "die test of die;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for exit
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
2007-04-05 20:12:56 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
2007-05-18 12:50:23 +02:00
|
|
|
|
# test for sorted_result
|
2007-04-05 20:12:56 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
create table t1( a int, b char(255), c timestamp);
|
|
|
|
|
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 2", '2007-04-05');
|
|
|
|
|
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05');
|
|
|
|
|
select * from t1;
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
select * from t1;
|
|
|
|
|
# Should not be sorted
|
|
|
|
|
select * from t1;
|
2007-04-05 20:12:56 +02:00
|
|
|
|
disable_result_log;
|
2007-05-18 12:50:23 +02:00
|
|
|
|
sorted_result;
|
2007-05-16 17:19:36 +02:00
|
|
|
|
select * from t1;
|
2007-04-05 20:12:56 +02:00
|
|
|
|
enable_result_log;
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
select '';
|
2007-05-18 12:50:23 +02:00
|
|
|
|
sorted_result;
|
2007-05-16 17:19:36 +02:00
|
|
|
|
select "h";
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
select "he";
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
select "hep";
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
select "hepp";
|
2007-04-05 20:12:56 +02:00
|
|
|
|
|
2007-05-16 17:19:36 +02:00
|
|
|
|
drop table t1;
|
2007-04-05 20:12:56 +02:00
|
|
|
|
|
2007-05-16 17:19:36 +02:00
|
|
|
|
# 1. Assignment of result set sorting
|
2007-05-18 12:50:23 +02:00
|
|
|
|
sorted_result;
|
2007-05-16 17:19:36 +02:00
|
|
|
|
SELECT 2 as "my_col"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT 1;
|
2007-05-18 12:50:23 +02:00
|
|
|
|
#
|
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
SELECT 2 as "my_col" UNION SELECT 1;
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
SELECT 2 as "my_col"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT 1;
|
|
|
|
|
|
|
|
|
|
# 2. Ensure that the table header will be not sorted into the result
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
SELECT '2' as "3"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT '1';
|
|
|
|
|
|
2007-05-18 12:50:23 +02:00
|
|
|
|
# 3. Ensure that an empty result set does not cause problems
|
|
|
|
|
CREATE TABLE t1( a CHAR);
|
|
|
|
|
--sorted_result
|
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
DROP TABLE t1;
|
2007-05-16 17:19:36 +02:00
|
|
|
|
|
2007-05-18 12:50:23 +02:00
|
|
|
|
# 4. Ensure that NULL values within the result set do not cause problems
|
|
|
|
|
SELECT NULL as "my_col1",2 AS "my_col2"
|
2007-05-16 17:19:36 +02:00
|
|
|
|
UNION
|
2007-05-18 12:50:23 +02:00
|
|
|
|
SELECT NULL,1;
|
|
|
|
|
--sorted_result
|
|
|
|
|
SELECT NULL as "my_col1",2 AS "my_col2"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT NULL,1;
|
|
|
|
|
#
|
|
|
|
|
SELECT 2 as "my_col1",NULL AS "my_col2"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT 1,NULL;
|
|
|
|
|
--sorted_result
|
|
|
|
|
SELECT 2 as "my_col1",NULL AS "my_col2"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT 1,NULL;
|
|
|
|
|
|
|
|
|
|
# 5. "sorted_result" changes nothing when applied to a non query statement.
|
|
|
|
|
sorted_result;
|
|
|
|
|
SET @a = 17;
|
|
|
|
|
#
|
|
|
|
|
# 6. Show that "sorted_result;" before the "SET @a = 17;" above does not affect
|
|
|
|
|
# the now following query.
|
2007-05-16 17:19:36 +02:00
|
|
|
|
SELECT 2 as "my_col"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT 1;
|
|
|
|
|
|
2007-05-18 12:50:23 +02:00
|
|
|
|
# 7. Ensure that "sorted_result" in combination with $variables works
|
2007-05-16 17:19:36 +02:00
|
|
|
|
let $my_stmt=SELECT 2 as "my_col"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT 1;
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
2007-05-16 17:19:36 +02:00
|
|
|
|
eval $my_stmt;
|
|
|
|
|
|
2007-05-18 12:50:23 +02:00
|
|
|
|
# 8. Ensure that "sorted_result " does not change the semantics of
|
|
|
|
|
# "--error ...." or the protocol output after such an expected failure
|
|
|
|
|
--sorted_result
|
2009-02-19 21:37:40 +01:00
|
|
|
|
--error ER_NO_SUCH_TABLE
|
|
|
|
|
|
2007-05-16 17:19:36 +02:00
|
|
|
|
SELECT '2' as "my_col1",2 as "my_col2"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT '1',1 from t2;
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
2009-03-03 21:34:18 +01:00
|
|
|
|
# 9. Ensure that several result formatting options including "sorted_result"
|
2007-05-18 12:50:23 +02:00
|
|
|
|
# - have all an effect
|
|
|
|
|
# - "--sorted_result" does not need to be direct before the statement
|
|
|
|
|
# - Row sorting is applied after modification of the column content
|
|
|
|
|
--sorted_result
|
|
|
|
|
--replace_column 1 #
|
|
|
|
|
SELECT '1' as "my_col1",2 as "my_col2"
|
|
|
|
|
UNION
|
|
|
|
|
SELECT '2',1;
|
|
|
|
|
|
|
|
|
|
# 10. Ensure that at least 1024 rows within a result set do not cause problems
|
|
|
|
|
#
|
|
|
|
|
CREATE TABLE t1 (f1 INT);
|
|
|
|
|
INSERT INTO t1 SET f1 = 1024;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 1 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 2 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 4 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 8 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 16 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 32 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 64 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 128 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 256 FROM t1;
|
|
|
|
|
INSERT INTO t1 SELECT f1 - 512 FROM t1;
|
2011-09-14 15:15:36 +02:00
|
|
|
|
--disable_result_log ONCE
|
2007-05-18 12:50:23 +02:00
|
|
|
|
--sorted_result
|
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
DROP TABLE t1;
|
2010-01-06 09:42:21 +01:00
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for lowercase_result
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# 1. Basic test
|
|
|
|
|
--lowercase_result
|
|
|
|
|
SELECT "500g BL<42>B<EFBFBD>RSYLTET<45>Y" AS "WILL BE lower cased";
|
|
|
|
|
|
|
|
|
|
# 2. test that it does not apply to next statement
|
|
|
|
|
SELECT "UPPER" AS "WILL NOT BE lower cased";
|
|
|
|
|
|
|
|
|
|
# 3. test that it does not affect non-SQL or the following statement
|
|
|
|
|
--lowercase_result
|
|
|
|
|
--echo UP
|
|
|
|
|
SELECT 0 as "UP AGAIN";
|
|
|
|
|
|
|
|
|
|
# 4. test that it works with eval and variables
|
|
|
|
|
let $lower_stmt=SELECT "ABCdef" AS "uvwXYZ";
|
|
|
|
|
--lowercase_result
|
|
|
|
|
eval $lower_stmt;
|
|
|
|
|
|
|
|
|
|
# 5. test that it works in combination with sort
|
|
|
|
|
sorted_result;
|
|
|
|
|
lowercase_result;
|
|
|
|
|
SELECT "Xyz" AS Name UNION SELECT "Abc" as Name ORDER BY Name DESC;
|
|
|
|
|
|
|
|
|
|
# 6. Test combination with replace, and that lower casing is done first
|
|
|
|
|
--lowercase_result
|
|
|
|
|
--replace_result old new
|
|
|
|
|
SELECT 1 as "SOME OLD TEXT";
|
|
|
|
|
|
|
|
|
|
# 7. Test missing lower casing of "unknown" characters
|
|
|
|
|
--character_set utf8
|
|
|
|
|
--lowercase_result
|
|
|
|
|
SELECT 0 as "WILL NOT lower case <20><><EFBFBD>";
|
|
|
|
|
--character_set latin1
|
|
|
|
|
|
2006-12-14 23:51:37 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Some coverage tests
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--disable_query_log
|
|
|
|
|
--exec $MYSQL_TEST --help 2>&1 > /dev/null
|
|
|
|
|
--exec $MYSQL_TEST --version 2>&1 > /dev/null
|
2007-06-01 15:49:01 +02:00
|
|
|
|
--enable_query_log
|
2011-09-14 15:15:36 +02:00
|
|
|
|
--disable_abort_on_error ONCE
|
2006-12-14 23:51:37 +01:00
|
|
|
|
--error 1
|
|
|
|
|
--exec $MYSQL_TEST a b c 2>&1 > /dev/null
|
2006-10-03 15:33:44 +02:00
|
|
|
|
|
2007-06-01 12:01:42 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# test for query_get_value
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
CREATE TABLE t1(
|
|
|
|
|
a int, b varchar(255), c datetime
|
|
|
|
|
);
|
|
|
|
|
SHOW COLUMNS FROM t1;
|
|
|
|
|
|
|
|
|
|
#------------ Positive tests ------------
|
|
|
|
|
# 1. constant parameters
|
|
|
|
|
# value is simple string without spaces
|
|
|
|
|
let $value= query_get_value(SHOW COLUMNS FROM t1, Type, 1);
|
|
|
|
|
--echo statement=SHOW COLUMNS FROM t1 row_number=1, column_name="Type", Value=$value
|
|
|
|
|
let $value= query_get_value("SHOW COLUMNS FROM t1", Type, 1);
|
|
|
|
|
--echo statement="SHOW COLUMNS FROM t1" row_number=1, column_name="Type", Value=$value
|
|
|
|
|
#
|
|
|
|
|
# 2. $variables as parameters
|
|
|
|
|
# value IS NULL
|
|
|
|
|
let $my_show= SHOW COLUMNS FROM t1;
|
|
|
|
|
let $column_name= Default;
|
|
|
|
|
let $row_number= 1;
|
|
|
|
|
let $value= query_get_value($my_show, $column_name, $row_number);
|
|
|
|
|
--echo statement=$my_show row_number=$row_number, column_name=$column_name, Value=$value
|
|
|
|
|
#
|
|
|
|
|
# 3. result set of a SELECT (not recommended, because projection and
|
|
|
|
|
# selection could be done much better by pure SELECT functionality)
|
|
|
|
|
# value is string with space in the middle
|
|
|
|
|
let $value= query_get_value(SELECT 'A B' AS "MyColumn", MyColumn, 1);
|
|
|
|
|
--echo value= ->$value<-
|
|
|
|
|
#
|
|
|
|
|
# 4. column name with space
|
|
|
|
|
let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1);
|
|
|
|
|
--echo value= $value
|
|
|
|
|
#
|
2009-05-25 17:19:20 +02:00
|
|
|
|
# 4.1 Query containing , protected by quotes, quotes also on column
|
|
|
|
|
let $value= query_get_value('SELECT 1 as a, 2 as b', "b", 1);
|
|
|
|
|
--echo value= $value
|
|
|
|
|
#
|
2007-06-01 12:01:42 +02:00
|
|
|
|
#------------ Negative tests ------------
|
|
|
|
|
# 5. Incomplete statement including missing parameters
|
|
|
|
|
# 5.1 incomplete statement
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value(SHOW;" | $MYSQL_TEST 2>&1
|
|
|
|
|
# 5.2 missing query
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value;" | $MYSQL_TEST 2>&1
|
|
|
|
|
# 5.3 missing column name
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1);" | $MYSQL_TEST 2>&1
|
|
|
|
|
# 5.4 missing row number
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field);" | $MYSQL_TEST 2>&1
|
|
|
|
|
#
|
|
|
|
|
# 6. Somehow "wrong" value of parameters
|
|
|
|
|
# 6.1 row parameter
|
|
|
|
|
# 6.1.1 non sense number 0
|
|
|
|
|
let $value= initialized;
|
|
|
|
|
let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 0);
|
|
|
|
|
--echo value= $value
|
|
|
|
|
# 6.1.2 after the last row
|
|
|
|
|
let $value= initialized;
|
|
|
|
|
let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 10);
|
|
|
|
|
--echo value= $value
|
|
|
|
|
# 6.1.3 invalid row number
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field, notnumber);" | $MYSQL_TEST 2>&1
|
|
|
|
|
# 6.2 column name parameter, name of not existing column
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, column_not_exists, 1);" | $MYSQL_TEST 2>&1
|
|
|
|
|
# 6.3. statement which never gives a result set
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value(SET @A = 1, Field, 1);" | $MYSQL_TEST 2>&1
|
|
|
|
|
# 6.4. statement contains a ","
|
|
|
|
|
# Note: There is no need to improve this, because we need query_get_value
|
|
|
|
|
# for SHOW commands only.
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value(SELECT 1 AS "A", 1 AS "B", 1);" | $MYSQL_TEST 2>&1
|
|
|
|
|
#
|
|
|
|
|
# 7. empty result set
|
|
|
|
|
let $value= initialized;
|
|
|
|
|
let $value= query_get_value(SELECT a FROM t1, a, 1);
|
|
|
|
|
--echo value= $value
|
|
|
|
|
#
|
|
|
|
|
# 9. failing statement
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "let \$value= query_get_value(SHOW COLNS FROM t1, Field, 1);" | $MYSQL_TEST 2>&1
|
|
|
|
|
#
|
|
|
|
|
# 10. Artificial example how to process a complete SHOW result set:
|
|
|
|
|
let $show_statement= SHOW COLUMNS FROM t1;
|
|
|
|
|
let $rowno= 1;
|
|
|
|
|
let $run=1;
|
|
|
|
|
let $count= 0;
|
|
|
|
|
--echo
|
|
|
|
|
--echo Field Type Null Key Default Extra
|
|
|
|
|
while ($run)
|
|
|
|
|
{
|
|
|
|
|
let $Field= query_get_value($show_statement, Field, $rowno);
|
2010-11-17 11:16:13 +01:00
|
|
|
|
if ($Field == No such row)
|
2007-06-01 12:01:42 +02:00
|
|
|
|
{
|
|
|
|
|
let $run= 0;
|
|
|
|
|
}
|
2010-11-17 11:16:13 +01:00
|
|
|
|
if ($Field != No such row)
|
2007-06-01 12:01:42 +02:00
|
|
|
|
{
|
|
|
|
|
let $Type= query_get_value($show_statement, Type, $rowno);
|
|
|
|
|
let $Null= query_get_value($show_statement, Null, $rowno);
|
2010-11-17 11:16:13 +01:00
|
|
|
|
if ($Null == YES)
|
2007-06-01 12:01:42 +02:00
|
|
|
|
{
|
|
|
|
|
inc $count;
|
|
|
|
|
}
|
|
|
|
|
let $Key= query_get_value($show_statement, Key, $rowno);
|
|
|
|
|
let $Default= query_get_value($show_statement, Default, $rowno);
|
|
|
|
|
let $Extra= query_get_value($show_statement, Extra, $rowno);
|
|
|
|
|
--echo $Field $Type $Null ->$Key<- $Default $Extra
|
|
|
|
|
inc $rowno;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
--echo
|
|
|
|
|
--echo Number of columns with Default NULL: $count
|
|
|
|
|
--echo
|
|
|
|
|
eval $show_statement;
|
|
|
|
|
|
|
|
|
|
drop table t1;
|
|
|
|
|
|
2007-10-31 18:44:31 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test change_user command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--change_user root,,inexistent" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--change_user inexistent,,test" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--change_user root,inexistent,test" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
--change_user
|
|
|
|
|
--change_user root
|
|
|
|
|
--change_user root,,
|
|
|
|
|
--change_user root,,test
|
|
|
|
|
|
2007-11-01 15:42:19 +01:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test mkdir and rmdir command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
|
|
|
|
|
# Directory already exist
|
|
|
|
|
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
--error 1
|
|
|
|
|
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
|
|
|
|
|
# Remove dir with file inside
|
|
|
|
|
write_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
|
|
|
|
|
hello
|
|
|
|
|
EOF
|
2008-07-09 13:19:04 +02:00
|
|
|
|
|
2010-11-17 10:13:57 +01:00
|
|
|
|
# Verify that --replace_result also work on list_files
|
|
|
|
|
--replace_result file REPLACED_FILE
|
2008-07-09 13:19:04 +02:00
|
|
|
|
list_files $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
# list_files gets the directory list before creating the new file
|
|
|
|
|
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *;
|
|
|
|
|
list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *2*;
|
|
|
|
|
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
|
|
|
|
|
list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
|
|
|
|
|
diff_files $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
|
2007-11-01 15:42:19 +01:00
|
|
|
|
--error 1
|
|
|
|
|
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
|
2008-07-09 13:19:04 +02:00
|
|
|
|
cat_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
|
|
|
|
|
|
2010-02-04 13:15:42 +01:00
|
|
|
|
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file11.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
|
|
|
|
|
remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
|
|
|
|
|
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/dir-list.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
|
|
|
|
|
cat_file $MYSQLTEST_VARDIR/tmp/testdir/dir-list.txt;
|
|
|
|
|
remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
|
|
|
|
|
list_files $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
list_files $MYSQLTEST_VARDIR/tmp/testdir;
|
2007-11-01 15:42:19 +01:00
|
|
|
|
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
|
|
|
|
|
|
2008-04-29 18:08:52 +02:00
|
|
|
|
#
|
2009-03-06 15:56:17 +01:00
|
|
|
|
# Bug#36041 mysql-test-run doesn't seem to string match 100% effectively
|
|
|
|
|
# on Windows
|
2008-04-29 18:08:52 +02:00
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
--replace_result c:\\a.txt z
|
|
|
|
|
SELECT 'c:\\a.txt' AS col;
|
2007-10-31 18:44:31 +01:00
|
|
|
|
|
2008-08-04 21:54:44 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Test that -- is not allowed as comment, only as mysqltest builtin command
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# valid
|
|
|
|
|
select 1;
|
|
|
|
|
--query select 1
|
|
|
|
|
--query -- a comment for the server
|
|
|
|
|
|
|
|
|
|
# Not valid, "select" is not a mysqltest command
|
|
|
|
|
--error 1
|
|
|
|
|
--exec echo "--select 1;" | $MYSQL_TEST 2>&1
|
|
|
|
|
|
|
|
|
|
|
2008-10-23 16:23:13 +02:00
|
|
|
|
# ----------------------------------------------------------------------------
|
2009-03-06 15:56:17 +01:00
|
|
|
|
# BUG#35701 please allow test language variables in connection and sync_slave_with_master
|
2008-10-23 16:23:13 +02:00
|
|
|
|
# Test that "connection $variable" works and that $CURRENT_CONNECTION has the right value.
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
2009-03-06 15:56:17 +01:00
|
|
|
|
connect (con2,localhost,root,,);
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
2008-10-23 16:23:13 +02:00
|
|
|
|
|
|
|
|
|
connection default;
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
|
|
|
|
|
|
|
|
|
connection con1;
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
|
|
|
|
|
2009-03-06 15:56:17 +01:00
|
|
|
|
connection con2;
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
|
|
|
|
|
|
|
|
|
let $x= con1;
|
|
|
|
|
let $y= con2;
|
2008-10-23 16:23:13 +02:00
|
|
|
|
|
|
|
|
|
connection $x;
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
|
|
|
|
|
|
|
|
|
connection $y;
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
|
|
|
|
|
2009-01-15 09:05:51 +01:00
|
|
|
|
# Disconnect the not selected connection
|
|
|
|
|
disconnect $x;
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
|
|
|
|
|
|
|
|
|
# Disconnect the selected connection
|
|
|
|
|
disconnect $y;
|
|
|
|
|
--echo $CURRENT_CONNECTION
|
|
|
|
|
|
2008-10-23 16:23:13 +02:00
|
|
|
|
|
2006-10-03 15:33:44 +02:00
|
|
|
|
--echo End of tests
|
2007-06-01 12:01:42 +02:00
|
|
|
|
|
2009-03-06 15:56:17 +01:00
|
|
|
|
connection default;
|
2009-03-03 21:34:18 +01:00
|
|
|
|
# Wait till we reached the initial number of concurrent sessions
|
|
|
|
|
--source include/wait_until_count_sessions.inc
|
Fix multiple test suite failures in Buildbot due to races in the test cases or missing server features not properly checked
mysql-test/r/func_misc.result:
Move test that requires query cache from main.func_misc to main.query_cache.
mysql-test/r/mysqltest.result:
Fix test failure due to race.
This test case creates > 300 connections in a tight loop, and depending on thread
scheduling and load, even though each connection is immediately disconnected
before connecting the next one, the server max connections may still be exceeded
due to server not being able to free old connections as fast as new ones are made.
mysql-test/r/query_cache.result:
Move test that requires query cache from main.func_misc to main.query_cache.
Move test that requires query cache from main.variables to main.query_cache.
mysql-test/r/query_cache_notembedded.result:
Move test that requires query cache from main.sp_notembedded to main.query_cache_notembedded.
mysql-test/r/sp_notembedded.result:
Move test that requires query cache from main.sp_notembedded to main.query_cache_notembedded.
mysql-test/r/udf.result:
Move test in main.udf that requires query cache to separate file.
mysql-test/r/udf_query_cache.result:
Move test in main.udf that requires query cache to separate file.
mysql-test/r/variables.result:
Move test that requires query cache from main.variables to main.query_cache.
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Fix race where result file may show state "cleaning up" in the small window
between setting COMMAND to 'Sleep' and clearing STATE.
mysql-test/suite/rpl/r/rpl_temporary.result:
Fix race with suppression of warning message by fixing the test to not generate the
warning message in the first place.
Problem was a race between creating an anonymous account and resetting the slave.
If the slave reset happens before replicating the account, the subsequest deletion
of the account will fail to replicate correctly due to missing row.
mysql-test/suite/rpl/t/rpl_temporary.test:
Fix race with suppression of warning message by fixing the test to not generate the
warning message in the first place.
Problem was a race between creating an anonymous account and resetting the slave.
If the slave reset happens before replicating the account, the subsequest deletion
of the account will fail to replicate correctly due to missing row.
mysql-test/t/func_misc.test:
Move test that requires query cache from main.func_misc to main.query_cache.
Move test that requires query cache from main.variables to main.query_cache.
mysql-test/t/mysqltest.test:
Fix test failure due to race.
This test case creates > 300 connections in a tight loop, and depending on thread
scheduling and load, even though each connection is immediately disconnected
before connecting the next one, the server max connections may still be exceeded
due to server not being able to free old connections as fast as new ones are made.
mysql-test/t/query_cache.test:
Move test that requires query cache to main.query_cache.
mysql-test/t/query_cache_notembedded.test:
Move test that requires query cache from main.sp_notembedded to main.query_cache_notembedded.
mysql-test/t/sp_notembedded.test:
Move test that requires query cache from main.sp_notembedded to main.query_cache_notembedded.
mysql-test/t/udf.test:
Move test in main.udf that requires query cache to separate file.
mysql-test/t/udf_query_cache-master.opt:
Move test in main.udf that requires query cache to separate file.
mysql-test/t/udf_query_cache.test:
Move test in main.udf that requires query cache to separate file.
mysql-test/t/variables.test:
Move test that requires query cache from main.variables to main.query_cache.
tests/mysql_client_test.c:
In tests that require query cache, skip the test if query cache not available.
Do this dynamically rather than using HAVE_QUERY_CACHE, as there is no guarantee
that the server we run against was compiled with same preprocessor #define as
the mysql_client_test program (and since it is trivial to check dynamically).
2010-01-11 14:15:28 +01:00
|
|
|
|
|
|
|
|
|
--disable_query_log
|
|
|
|
|
--eval SET GLOBAL max_connections = $saved_max_connections
|
|
|
|
|
--enable_query_log
|