Commit d57a0e52 authored by unknown's avatar unknown

BUG#11316 mysqltest, problems when assigning value with '#' to $variable

 - Fixed problem, only detect comment if the # is on start of line AND starting line of the current command.
 - Wrote tests for most of the mysqltest commands, added stricter checking of correct syntax.


client/mysqltest.c:
  Updated mysql test to do stricter checking of syntax. For example when the number 
  of arguments to a command is known, everything else is "junk" => die. 
  Better checking of argument types.
  Added better debug printouts.
  Added improved printouts when wrong syntax is detected.
  Fix two bugs where mysqltest could not detect end of comamnd properly, as described in bug#11316
  Fix segfault when performing too many source commands.
  Fix segfault when doing too many while loop levels.
  Add printout of line number in die
  Remove lineno and \n in all strings passed to die function.
  Decrese BLOCK_STACK_DEPTH from 32 to 16, does any test use more than 1 level?
mysql-test/mysql-test-run.pl:
  export MYSQL_TEST environment variable, used from msyqltest.test
mysql-test/mysql-test-run.sh:
  export MYSQL_TEST environment variable, used from msyqltest.test
mysql-test/r/mysqltest.result:
  Updated test results
mysql-test/r/rpl_flush_log_loop.result:
  Updated test result.
  Approved by lars
mysql-test/t/innodb-deadlock.test:
  Correct wrong syntax
  Superfluos ;
mysql-test/t/innodb-lock.test:
  Correct wrong syntax
  Superfluos ;
mysql-test/t/mysqltest.test:
  Add several new tests  for mysqltest.
  Foxus on detecting wrong syntax in test files.
  Use exec with expected error to execute test scripts that will kill mysqltest
  Change some negative test that were previously commented out to use the above method.
mysql-test/t/ndb_autodiscover2.test:
  Correct wrong syntax
  Superfluos ;
mysql-test/t/rpl_change_master.test:
  Correct wrong syntax
  Superfluos ;
mysql-test/t/rpl_deadlock.test:
  Correct wrong syntax
  Superfluos ;
mysql-test/t/rpl_drop_temp.test:
  Correct wrong syntax
  Superfluos ;
mysql-test/t/rpl_flush_log_loop.test:
  Fix after detecting wrong syntax, missing ;
  Discussed with lars.
mysql-test/t/rpl_insert_id.test:
  Missing ;
mysql-test/t/rpl_rotate_logs.test:
  Correct wrong syntax
  Superfluos ;
mysql-test/t/rpl_until.test:
  Missing delimiter
mysql-test/include/mysqltest_while.inc:
  New file to test too many while levels
parent 3d2814d6
This diff is collapsed.
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;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
......@@ -2129,6 +2129,11 @@ sub run_mysqltest ($) {
mysqld_arguments($args,'master',0,$tinfo->{'master_opt'},[]);
}
# ----------------------------------------------------------------------
# export MYSQL_TEST variable containing <path>/mysqltest <args>
# ----------------------------------------------------------------------
$ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args);
return mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,"");
}
......
......@@ -714,6 +714,7 @@ if [ x$USE_TIMER = x1 ] ; then
fi
MYSQL_TEST_BIN=$MYSQL_TEST
MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS"
export MYSQL_TEST
GDB_CLIENT_INIT=$MYSQL_TMP_DIR/gdbinit.client
GDB_MASTER_INIT=$MYSQL_TMP_DIR/gdbinit.master
GDB_SLAVE_INIT=$MYSQL_TMP_DIR/gdbinit.slave
......
......@@ -7,6 +7,7 @@ otto
select otto from (select 1 as otto) as t1;
otto
1
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed: 1054: Unknown column 'friedrich' in 'field list'
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select otto from (select 1 as otto) as t1;
......@@ -15,10 +16,12 @@ otto
select otto from (select 1 as otto) as t1;
otto
1
mysqltest: At line 1: query 'select otto from (select 1 as otto) as t1' succeeded - should have failed with sqlstate 42S22...
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed with wrong sqlstate 42S22 instead of 00000...
select otto from (select 1 as otto) as t1;
otto
1
......@@ -135,6 +138,8 @@ ERROR 42S02: Table 'test.t1' doesn't exist
select 1146 as "after_!errno_masked_error" ;
after_!errno_masked_error
1146
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1000...
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1000...
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 1064 as "after_--enable_abort_on_error" ;
......@@ -142,3 +147,119 @@ after_--enable_abort_on_error
1064
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146 instead of 1064...
mysqltest: At line 1: query 'select 3 from t1' failed: 1146: Table 'test.t1' doesn't exist
hello
hello
;;;;;;;;
# MySQL: -- The
mysqltest: At line 1: End of line junk detected: "6"
mysqltest: At line 1: End of line junk detected: "6"
mysqltest: At line 1: Missing delimiter
mysqltest: At line 1: Extra delimiter ";" found
MySQL
"MySQL"
MySQL: The world''s most popular open source database
"MySQL: The world's most popular open source database"
MySQL: The world''s
most popular open
source database
# MySQL: The world''s
# most popular open
# source database
- MySQL: The world''s
- most popular open
- source database
- MySQL: The world''s
-- most popular open
-- source database
# MySQL: The
--world''s
# most popular
-- open
- source database
"MySQL: The world's most popular; open source database"
"MySQL: The world's most popular ; open source database"
"MySQL: The world's most popular ;open source database"
echo message echo message
mysqltest: At line 1: Empty variable
sh: -c: line 0: syntax error near unexpected token `;'
sh: -c: line 0: `;'
mysqltest: At line 1: command ";" failed
mysqltest: At line 1: Missing argument in exec
MySQL
"MySQL"
MySQL: The
world''s most
popular open
source database
# MySQL: The
# world''s most
# popular open
# source database
-- MySQL: The
-- world''s most
-- popular open
-- source database
# MySQL: The
- world''s most
-- popular open
# source database
'$message'
"$message"
hej
hej
hej
mysqltest: At line 1: Missing arguments to let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Variable name in hi=hi does not start with '$'
mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing arguments to let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Variable name in =hi does not start with '$'
mysqltest: At line 1: Missing assignment operator in let
mysqltest: At line 1: Missing file name in source
mysqltest: At line 1: Could not open file ./non_existingFile
mysqltest: In included file "./var/tmp/recursive.sql": At line 1: Source directives are nesting too deep
mysqltest: In included file "./var/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
mysqltest: At line 1: Missing argument to sleep
mysqltest: At line 1: Invalid argument to sleep "abc"
1
2
101
hej
1
mysqltest: At line 1: Missing arguments to inc
mysqltest: At line 1: First argument to inc must be a variable (start with $)
mysqltest: At line 1: End of line junk detected: "1000"
4
4
-1
-2
99
hej
-1
mysqltest: At line 1: Missing arguments to dec
mysqltest: At line 1: First 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!
sh: NonExistsinfComamdn: command not found
mysqltest: At line 1: system command 'NonExistsinfComamdn' failed
test
test2
test3
test4
1
mysqltest: In included file "./include/mysqltest_while.inc": At line 32: Nesting too deeply
mysqltest: At line 1: missing '(' in while
mysqltest: At line 1: missing ')' in while
mysqltest: At line 1: Missing '{' after while. Found "dec $i"
mysqltest: At line 1: Stray '}' - end of block before beginning
mysqltest: At line 1: Stray '}' - end of block before beginning
mysqltest: At line 1: query '' failed: 1065: Query was empty
mysqltest: At line 1: Missing '{' after while. Found "echo hej"
mysqltest: At line 3: Missing end of block
mysqltest: At line 1: Missing newline between while and '{'
......@@ -4,10 +4,10 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
stop slave;
change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=MASTER_PORT;
start slave;
stop slave;
change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=SLAVE_PORT;
start slave;
......
......@@ -25,7 +25,7 @@ set autocommit=0;
# The following query should hang because con1 is locking the page
--send
update t1 set x=2 where id = 0;
--sleep 2;
--sleep 2
connection con1;
update t1 set x=1 where id = 0;
......@@ -63,7 +63,7 @@ set autocommit=0;
# The following query should hang because con1 is locking the page
--send
update t1 set x=2 where id = 0;
--sleep 2;
--sleep 2
connection con1;
update t1 set x=1 where id = 0;
......@@ -97,7 +97,7 @@ update t2 set a=2 where b = 0;
select * from t2;
--send
update t1 set x=2 where id = 0;
--sleep 2;
--sleep 2
connection con1;
update t1 set x=1 where id = 0;
......
......@@ -39,7 +39,7 @@ set autocommit=0;
# The following statement should hang because con1 is locking the page
--send
lock table t1 write;
--sleep 2;
--sleep 2
connection con1;
update t1 set x=1 where id = 0;
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
# The previous step has simply removed the frm file
# from disk, but left the table in NDB
#
--sleep 3;
--sleep 3
select * from t9 order by a;
# handler_discover should be 1
......
......@@ -8,7 +8,7 @@ insert into t1 values(1+get_lock("a",15)*0);
insert into t1 values(2);
save_master_pos;
connection slave;
--real_sleep 3; # can't sync_with_master as we should be blocked
--real_sleep 3 # can't sync_with_master as we should be blocked
stop slave;
select * from t1;
--replace_result $MASTER_MYPORT MASTER_MYPORT
......
......@@ -58,7 +58,7 @@ while ($1)
enable_query_log;
select * from t1 for update;
start slave;
--sleep 3; # hope that slave is blocked now
--sleep 3 # hope that slave is blocked now
insert into t2 values(22); # provoke deadlock, slave should be victim
commit;
sync_with_master;
......@@ -76,7 +76,7 @@ change master to master_log_pos=401; # the BEGIN log event
begin;
select * from t2 for update; # hold lock
start slave;
--sleep 10; # slave should have blocked, and be retrying
--sleep 10 # slave should have blocked, and be retrying
commit;
sync_with_master;
select * from t1; # check that slave succeeded finally
......@@ -97,7 +97,7 @@ change master to master_log_pos=401;
begin;
select * from t2 for update;
start slave;
--sleep 10;
--sleep 10
commit;
sync_with_master;
select * from t1;
......
......@@ -9,5 +9,5 @@ sync_slave_with_master;
connection master;
disconnect master;
connection slave;
--real_sleep 3; # time for DROP to be written
--real_sleep 3 # time for DROP to be written
show status like 'Slave_open_temp_tables';
# Testing if "flush logs" command bouncing resulting in logs created in a loop
# in case of bi-directional replication
source include/master-slave.inc
source include/master-slave.inc;
connection slave;
stop slave;
--replace_result $MASTER_MYPORT MASTER_PORT
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$MASTER_MYPORT;
start slave;
connection master;
stop slave;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$SLAVE_MYPORT;
......
......@@ -4,7 +4,7 @@
# We also check how the foreign_key_check variable is replicated
source include/master-slave.inc;
source include/have_innodb.inc
source include/have_innodb.inc;
connection master;
create table t1(a int auto_increment, key(a));
create table t2(b int auto_increment, c int, key(b));
......
......@@ -102,7 +102,7 @@ show master logs;
purge binary logs to 'master-bin.000002';
show binary logs;
# sleeping 10 seconds or more would make the slave believe connection is down
--real_sleep 1;
--real_sleep 1
purge master logs before now();
show binary logs;
insert into t2 values (65);
......
......@@ -60,7 +60,7 @@ stop slave;
# this should stop immideately
start slave until master_log_file='master-bin.000001', master_log_pos=561;
# 2 is not enough when running with valgrind
real_sleep 4
--real_sleep 4
# here the sql slave thread should be stopped
--replace_result $MASTER_MYPORT MASTER_MYPORT bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
--replace_column 1 # 9 # 23 # 33 #
......
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