Commit cc628c61 authored by Patrick Crews's avatar Patrick Crews

Bug#38831: 11 test cases fail on Windows due to missing commands

Replaced Unix calls with mysql-test-run's built-in functions / SQL manipulation where possible.
Replaced error codes with error names as well.
Disabled two tests on Windows due to more complex Unix command usage
See Bug#41307, Bug#41308
parent 49243dd2
......@@ -2,6 +2,13 @@
# By JBM 2006-02-16 So that the code is not repeated #
# in test cases and can be reused. #
######################################################
# Bug#41307: Tests using include/ndb_backup.inc won't work on Windows due to
# 'grep' call
# This test is disabled on Windows via the next line until the above bug is
# resolved
--source include/not_windows.inc
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT
# there is no neat way to find the backupid, this is a hack to find it...
......
......@@ -353,7 +353,14 @@ flush logs;
INSERT INTO t1 VALUES ('0123456789');
flush logs;
DROP TABLE t1;
# Query thread_id=REMOVED exec_time=REMOVED error_code=REMOVED
We expect this value to be 1
The bug being tested was that 'Query' lines were not preceded by '#'
If the line is in the table, it had to have been preceded by a '#'
SELECT COUNT(*) AS `BUG#28293_expect_1` FROM patch WHERE a LIKE '%Query%';
BUG#28293_expect_1
1
DROP TABLE patch;
flush logs;
create table t1(a int);
insert into t1 values(connection_id());
......
......@@ -210,7 +210,6 @@ source database
"MySQL: The world's most popular ;open source database"
echo message echo message
mysqltest: At line 1: command "false" failed
mysqltest: At line 1: Missing argument in exec
MySQL
"MySQL"
......@@ -378,7 +377,6 @@ mysqltest: At line 1: The argument to dec must be a variable (start with $)
mysqltest: At line 1: End of line junk detected: "1000"
mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: system command 'false' failed
system command 'NonExistsinfComamdn 2> /dev/null' failed
test
test2
......
......@@ -13,9 +13,7 @@ GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
---> connection: wl2818_definer_con
CREATE TABLE t1(num_value INT);
CREATE TABLE t2(user_str TEXT);
CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1
FOR EACH ROW
INSERT INTO t2 VALUES(CURRENT_USER());
CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER());
---> patching t1.TRG...
......
# We are using .opt file since we need small binlog size
-- source include/have_log_bin.inc
# Currently disabling this test on Windows due to use of grep and sed
--source include/not_windows.inc
# we need this for getting fixed timestamps inside of this test
set timestamp=1000000000;
......@@ -174,7 +176,8 @@ delimiter ;//
flush logs;
call p1();
drop procedure p1;
--error 1305
--error ER_SP_DOES_NOT_EXIST
call p1();
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000007
......@@ -226,7 +229,26 @@ flush logs;
INSERT INTO t1 VALUES ('0123456789');
flush logs;
DROP TABLE t1;
--exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000011 | grep 'Query' | sed 's/[0-9]\{1,\}/REMOVED/g'
# We create a table, patch, and load the output into it
# By using LINES STARTING BY '#' + SELECT WHERE a LIKE 'Query'
# We can easily see if a 'Query' line is missing the '#' character
# as described in the original bug
--disable_query_log
CREATE TABLE patch (a blob);
--exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000011 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat
eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat'
INTO TABLE patch FIELDS TERMINATED by '' LINES STARTING BY '#';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat
--enable_query_log
--echo We expect this value to be 1
--echo The bug being tested was that 'Query' lines were not preceded by '#'
--echo If the line is in the table, it had to have been preceded by a '#'
--echo
SELECT COUNT(*) AS `BUG#28293_expect_1` FROM patch WHERE a LIKE '%Query%';
DROP TABLE patch;
#
# Bug #29928: incorrect connection_id() restoring from mysqlbinlog out
......
......@@ -62,7 +62,8 @@ select otto from (select 1 as otto) as t1;
--exec echo "select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1
# expectation = response
--error 1054
--error ER_BAD_FIELD_ERROR
select friedrich from (select 1 as otto) as t1;
# The following unmasked unsuccessful statement must give
......@@ -131,14 +132,16 @@ eval select $mysql_errno as "after_successful_stmt_errno" ;
#----------------------------------------------------------------------------
# check mysql_errno = 1064 after statement with wrong syntax
# ----------------------------------------------------------------------------
--error 1064
--error ER_PARSE_ERROR
garbage ;
eval select $mysql_errno as "after_wrong_syntax_errno" ;
# ----------------------------------------------------------------------------
# check if let $my_var= 'abc' ; affects $mysql_errno
# ----------------------------------------------------------------------------
--error 1064
--error ER_PARSE_ERROR
garbage ;
let $my_var= 'abc' ;
eval select $mysql_errno as "after_let_var_equal_value" ;
......@@ -146,7 +149,8 @@ eval select $mysql_errno as "after_let_var_equal_value" ;
# ----------------------------------------------------------------------------
# check if set @my_var= 'abc' ; affects $mysql_errno
# ----------------------------------------------------------------------------
--error 1064
--error ER_PARSE_ERROR
garbage ;
set @my_var= 'abc' ;
eval select $mysql_errno as "after_set_var_equal_value" ;
......@@ -155,7 +159,8 @@ eval select $mysql_errno as "after_set_var_equal_value" ;
# check if the setting of --disable-warnings itself affects $mysql_errno
# (May be --<whatever> modifies $mysql_errno.)
# ----------------------------------------------------------------------------
--error 1064
--error ER_PARSE_ERROR
garbage ;
--disable_warnings
eval select $mysql_errno as "after_disable_warnings_command" ;
......@@ -166,7 +171,8 @@ eval select $mysql_errno as "after_disable_warnings_command" ;
# (May be disabled warnings affect $mysql_errno.)
# ----------------------------------------------------------------------------
drop table if exists t1 ;
--error 1064
--error ER_PARSE_ERROR
garbage ;
drop table if exists t1 ;
eval select $mysql_errno as "after_disable_warnings" ;
......@@ -175,21 +181,26 @@ eval select $mysql_errno as "after_disable_warnings" ;
# ----------------------------------------------------------------------------
# check if masked errors affect $mysql_errno
# ----------------------------------------------------------------------------
--error 1064
--error ER_PARSE_ERROR
garbage ;
--error 1146
--error ER_NO_SUCH_TABLE
select 3 from t1 ;
eval select $mysql_errno as "after_minus_masked" ;
--error 1064
--error ER_PARSE_ERROR
garbage ;
--error 1146
--error ER_NO_SUCH_TABLE
select 3 from t1 ;
eval select $mysql_errno as "after_!_masked" ;
# ----------------------------------------------------------------------------
# Will manipulations of $mysql_errno be possible and visible ?
# ----------------------------------------------------------------------------
--error 1064
--error ER_PARSE_ERROR
garbage ;
let $mysql_errno= -1;
eval select $mysql_errno as "after_let_errno_equal_value" ;
......@@ -198,50 +209,61 @@ eval select $mysql_errno as "after_let_errno_equal_value" ;
# How affect actions on prepared statements $mysql_errno ?
# ----------------------------------------------------------------------------
# failing prepare
--error 1064
--error ER_PARSE_ERROR
garbage ;
--error 1146
--error ER_NO_SUCH_TABLE
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_failing_prepare" ;
create table t1 ( f1 char(10));
# successful prepare
--error 1064
--error ER_PARSE_ERROR
garbage ;
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_successful_prepare" ;
# successful execute
--error 1064
--error ER_PARSE_ERROR
garbage ;
execute stmt;
eval select $mysql_errno as "after_successful_execute" ;
# failing execute (table has been dropped)
drop table t1;
--error 1064
--error ER_PARSE_ERROR
garbage ;
--error 1146
--error ER_NO_SUCH_TABLE
execute stmt;
eval select $mysql_errno as "after_failing_execute" ;
# failing execute (unknown statement)
--error 1064
--error ER_PARSE_ERROR
garbage ;
--error 1243
--error ER_UNKNOWN_STMT_HANDLER
execute __stmt_;
eval select $mysql_errno as "after_failing_execute" ;
# successful deallocate
--error 1064
--error ER_PARSE_ERROR
garbage ;
deallocate prepare stmt;
eval select $mysql_errno as "after_successful_deallocate" ;
# failing deallocate ( statement handle does not exist )
--error 1064
--error ER_PARSE_ERROR
garbage ;
--error 1243
--error ER_UNKNOWN_STMT_HANDLER
deallocate prepare __stmt_;
eval select $mysql_errno as "after_failing_deallocate" ;
......@@ -266,7 +288,8 @@ eval select $mysql_errno as "after_failing_deallocate" ;
# ----------------------------------------------------------------------------
# Switch off the abort on error and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
--error 1064
--error ER_PARSE_ERROR
garbage ;
--disable_abort_on_error
eval select $mysql_errno as "after_--disable_abort_on_error" ;
......@@ -280,9 +303,11 @@ select 3 from t1 ;
# masked failing statements
# ----------------------------------------------------------------------------
# expected error = response
--error 1146
--error ER_NO_SUCH_TABLE
select 3 from t1 ;
--error 1146
--error ER_NO_SUCH_TABLE
select 3 from t1 ;
eval select $mysql_errno as "after_!errno_masked_error" ;
# expected error <> response
......@@ -296,7 +321,8 @@ eval select $mysql_errno as "after_!errno_masked_error" ;
# ----------------------------------------------------------------------------
# Switch the abort on error on and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
--error 1064
--error ER_PARSE_ERROR
garbage ;
--enable_abort_on_error
eval select $mysql_errno as "after_--enable_abort_on_error" ;
......@@ -305,7 +331,8 @@ eval select $mysql_errno as "after_--enable_abort_on_error" ;
# masked failing statements
# ----------------------------------------------------------------------------
# expected error = response
--error 1146
--error ER_NO_SUCH_TABLE
select 3 from t1 ;
# ----------------------------------------------------------------------------
......@@ -568,9 +595,6 @@ echo ;
# ----------------------------------------------------------------------------
# Illegal use of exec
--error 1
--exec echo "--exec false" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--exec " | $MYSQL_TEST 2>&1
......@@ -951,8 +975,6 @@ system echo "hej" > /dev/null;
--exec echo "system;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "system false;" | $MYSQL_TEST 2>&1
--disable_abort_on_error
system NonExistsinfComamdn 2> /dev/null;
......@@ -1370,7 +1392,8 @@ connection default;
let $num= 2;
while ($num)
{
--error 1064
--error ER_PARSE_ERROR
failing_statement;
dec $num;
......@@ -1429,7 +1452,7 @@ select "this will be executed";
#
# Test zero length result file. Should not pass
#
--exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result
--exec echo '' > $MYSQLTEST_VARDIR/tmp/zero_length_file.result
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
--error 1
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1
......@@ -1482,7 +1505,8 @@ drop table t1;
--error 1
--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
# The .out file should be non existent
--exec test ! -s $MYSQLTEST_VARDIR/tmp/bug11731.out
--error 1
--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
drop table t1;
......@@ -1503,7 +1527,7 @@ 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
--exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.out
--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
drop table t1;
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
......@@ -1515,14 +1539,17 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
# 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.
--error 1064
--error ER_PARSE_ERROR
query sleep;
--error 1064
--error ER_PARSE_ERROR
--query sleep
# Just an empty query command
--error 1065
--error ER_EMPTY_QUERY
query ;
# test for replace_regex
......@@ -1915,7 +1942,8 @@ eval $my_stmt;
# 8. Ensure that "sorted_result " does not change the semantics of
# "--error ...." or the protocol output after such an expected failure
--sorted_result
--error 1146
--error ER_NO_SUCH_TABLE
SELECT '2' as "my_col1",2 as "my_col2"
UNION
SELECT '1',1 from t2;
......
-- source include/have_ndb.inc
-- source include/not_embedded.inc
# Bug#41308: Test main.ndb_autodiscover.test doesn't work on Windows due
# to 'grep' calls
# Test is currently disabled on Windows via the next line until this bug
# can be resolved.
--source include/not_windows.inc
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
--enable_warnings
......
......@@ -293,7 +293,8 @@ STOP SLAVE;
connection master;
FLUSH LOGS;
exec cp $MYSQL_TEST_DIR/std_data/bug16266.000001 $MYSQLTEST_VARDIR/log/master-bin.000001;
--remove_file $MYSQLTEST_VARDIR/log/master-bin.000001
--copy_file $MYSQL_TEST_DIR/std_data/bug16266.000001 $MYSQLTEST_VARDIR/log/master-bin.000001
# Make the slave to replay the new binlog.
......
......@@ -50,9 +50,7 @@ GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
CREATE TABLE t1(num_value INT);
CREATE TABLE t2(user_str TEXT);
CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1
FOR EACH ROW
INSERT INTO t2 VALUES(CURRENT_USER());
CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER());
#
# Remove definers from TRG file.
......@@ -61,8 +59,24 @@ CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1
--echo
--echo ---> patching t1.TRG...
--exec grep -v 'definers=' $MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG > $MYSQLTEST_VARDIR/tmp/t1.TRG
--exec mv $MYSQLTEST_VARDIR/tmp/t1.TRG $MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG
# Here we remove definers. This is somewhat complex than the original test
# Previously, the test only used grep -v 'definers=' t1.TRG, but grep is not
# portable and we have to load the file into a table, exclude the definers line,
# then load the data to an outfile to accomplish the same effect
--disable_query_log
--connection default
CREATE TABLE patch (a blob);
eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG' INTO TABLE patch;
# remove original t1.TRG file so SELECT INTO OUTFILE won't fail
--remove_file $MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG
eval SELECT SUBSTRING_INDEX(a,'definers=',1) INTO OUTFILE
'$MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG'
FROM patch;
DROP TABLE patch;
--connection wl2818_definer_con
--enable_query_log
#
# Create a new trigger.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment