diff options
author | Michael Widenius <monty@askmonty.org> | 2010-08-02 12:01:24 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2010-08-02 12:01:24 +0300 |
commit | e0a6b02c5d0a311e7167295494786077009743d1 (patch) | |
tree | 72c934fe42261ad5de3139961e092f57e9d147df /mysql-test/include | |
parent | d2f8b7d04503478ab6b6998194a2070891f0c2bb (diff) | |
parent | 6ad06b15222300e4eed4fe3972d1ad249c4c42a2 (diff) | |
download | mariadb-git-e0a6b02c5d0a311e7167295494786077009743d1.tar.gz |
Merge with MySQL 5.1.49
Fixed Bug#52005 'JOIN_TAB->dependent' may be incorrectly propageted for multilevel outer joins' in a better way (patch from Sergey Petrunya)
Diffstat (limited to 'mysql-test/include')
22 files changed, 708 insertions, 57 deletions
diff --git a/mysql-test/include/check_concurrent_insert.inc b/mysql-test/include/check_concurrent_insert.inc new file mode 100644 index 00000000000..f4bec3c9cdb --- /dev/null +++ b/mysql-test/include/check_concurrent_insert.inc @@ -0,0 +1,96 @@ +# +# SUMMARY +# Check if statement reading table '$table' allows concurrent +# inserts in it. +# +# PARAMETERS +# $table Table in which concurrent inserts should be allowed. +# $con_aux1 Name of the first auxiliary connection to be used by this +# script. +# $con_aux2 Name of the second auxiliary connection to be used by this +# script. +# $statement Statement to be checked. +# $restore_table Table which might be modified by statement to be checked +# and thus needs backing up before its execution and +# restoring after it (can be empty). +# +# EXAMPLE +# lock_sync.test +# +--disable_result_log +--disable_query_log + +# Reset DEBUG_SYNC facility for safety. +set debug_sync= "RESET"; + +if (`SELECT '$restore_table' <> ''`) +{ +--eval create temporary table t_backup select * from $restore_table; +} + +connection $con_aux1; +set debug_sync='after_lock_tables_takes_lock SIGNAL parked WAIT_FOR go'; +--send_eval $statement; + +connection $con_aux2; +set debug_sync='now WAIT_FOR parked'; +--send_eval insert into $table (i) values (0); + +--enable_result_log +--enable_query_log +connection default; +# Wait until concurrent insert is successfully executed while +# statement being checked has its tables locked. +# We use wait_condition.inc instead of simply reaping +# concurrent insert here in order to avoid deadlocks if test +# fails and to time out gracefully instead. +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where info = "insert into $table (i) values (0)"; +--source include/wait_condition.inc + +--disable_result_log +--disable_query_log + +if ($success) +{ +# Apparently concurrent insert was successfully executed. +# To be safe against wait_condition.inc succeeding due to +# races let us first reap concurrent insert to ensure that +# it has really been successfully executed. +connection $con_aux2; +--reap +connection default; +set debug_sync= 'now SIGNAL go'; +connection $con_aux1; +--reap +connection default; +--echo Success: '$statement' allows concurrent inserts into '$table'. +} +if (!$success) +{ +# Waiting has timed out. Apparently concurrent insert was blocked. +# So to be able to continue we need to end our statement first. +set debug_sync= 'now SIGNAL go'; +connection $con_aux1; +--reap +connection $con_aux2; +--reap +connection default; +--echo Error: '$statement' doesn't allow concurrent inserts into '$table'! +} + +--eval delete from $table where i = 0; + +if (`SELECT '$restore_table' <> ''`) +{ +--eval truncate table $restore_table; +--eval insert into $restore_table select * from t_backup; +drop temporary table t_backup; +} + +# Clean-up. Reset DEBUG_SYNC facility after use. +set debug_sync= "RESET"; + +--enable_result_log +--enable_query_log diff --git a/mysql-test/include/check_no_concurrent_insert.inc b/mysql-test/include/check_no_concurrent_insert.inc new file mode 100644 index 00000000000..f60401bcad1 --- /dev/null +++ b/mysql-test/include/check_no_concurrent_insert.inc @@ -0,0 +1,81 @@ +# +# SUMMARY +# Check that statement reading table '$table' doesn't allow concurrent +# inserts in it. +# +# PARAMETERS +# $table Table in which concurrent inserts should be disallowed. +# $con_aux1 Name of the first auxiliary connection to be used by this +# script. +# $con_aux2 Name of the second auxiliary connection to be used by this +# script. +# $statement Statement to be checked. +# $restore_table Table which might be modified by statement to be checked +# and thus needs backing up before its execution and +# restoring after it (can be empty). +# +# EXAMPLE +# lock_sync.test +# +--disable_result_log +--disable_query_log + +# Reset DEBUG_SYNC facility for safety. +set debug_sync= "RESET"; + +if (`SELECT '$restore_table' <> ''`) +{ +--eval create temporary table t_backup select * from $restore_table; +} + +connection $con_aux1; +set debug_sync='after_lock_tables_takes_lock SIGNAL parked WAIT_FOR go'; +--send_eval $statement; + +connection $con_aux2; +set debug_sync='now WAIT_FOR parked'; +--send_eval insert into $table (i) values (0); + +--enable_result_log +--enable_query_log +connection default; +# Wait until concurrent insert is successfully blocked because +# of our statement. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "insert into $table (i) values (0)"; +--source include/wait_condition.inc + +--disable_result_log +--disable_query_log + +set debug_sync= 'now SIGNAL go'; +connection $con_aux1; +--reap +connection $con_aux2; +--reap +connection default; + +if ($success) +{ +--echo Success: '$statement' doesn't allow concurrent inserts into '$table'. +} +if (!$success) +{ +--echo Error: '$statement' allows concurrent inserts into '$table'! +} + +--eval delete from $table where i = 0; + +if (`SELECT '$restore_table' <> ''`) +{ +--eval truncate table $restore_table; +--eval insert into $restore_table select * from t_backup; +drop temporary table t_backup; +} + +# Clean-up. Reset DEBUG_SYNC facility after use. +set debug_sync= "RESET"; + +--enable_result_log +--enable_query_log diff --git a/mysql-test/include/check_no_row_lock.inc b/mysql-test/include/check_no_row_lock.inc new file mode 100644 index 00000000000..c08e7f35b10 --- /dev/null +++ b/mysql-test/include/check_no_row_lock.inc @@ -0,0 +1,71 @@ +# +# SUMMARY +# Check if statement affecting or reading table '$table' doesn't +# take any kind of locks on its rows. +# +# PARAMETERS +# $table Table for which presence of row locks should be checked. +# $con_aux Name of auxiliary connection to be used by this script. +# $statement Statement to be checked. +# +# EXAMPLE +# innodb_mysql_lock2.test +# +--disable_result_log +--disable_query_log + +connection default; +begin; +--eval select * from $table for update; + +connection $con_aux; +begin; +--send_eval $statement; + +--enable_result_log +--enable_query_log + +connection default; +# Wait until statement is successfully executed while +# all rows in table are X-locked. This means that it +# does not acquire any row locks. +# We use wait_condition.inc instead of simply reaping +# statement here in order to avoid deadlocks if test +# fails and to time out gracefully instead. +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where info = "$statement"; +--source include/wait_condition.inc + +--disable_result_log +--disable_query_log + +if ($success) +{ +# Apparently statement was successfully executed and thus it +# has not required any row locks. +# To be safe against wait_condition.inc succeeding due to +# races let us first reap the statement being checked to +# ensure that it has been successfully executed. +connection $con_aux; +--reap +rollback; +connection default; +rollback; +--echo Success: '$statement' doesn't take row locks on '$table'. +} +if (!$success) +{ +# Waiting has timed out. Apparently statement was blocked on +# some row lock. So to be able to continue we need to unlock +# rows first. +rollback; +connection $con_aux; +--reap +rollback; +connection default; +--echo Error: '$statement' takes some row locks on '$table'! +} + +--enable_result_log +--enable_query_log diff --git a/mysql-test/include/check_shared_row_lock.inc b/mysql-test/include/check_shared_row_lock.inc new file mode 100644 index 00000000000..efc7e13b3aa --- /dev/null +++ b/mysql-test/include/check_shared_row_lock.inc @@ -0,0 +1,61 @@ +# +# SUMMARY +# Check if statement reading table '$table' takes shared locks +# on some of its rows. +# +# PARAMETERS +# $table Table for which presence of row locks should be checked. +# $con_aux Name of auxiliary connection to be used by this script. +# $statement Statement to be checked. +# $wait_statement Sub-statement which is supposed to acquire locks (should +# be the same as $statement for ordinary statements). +# +# EXAMPLE +# innodb_mysql_lock2.test +# +--disable_result_log +--disable_query_log + +connection default; +begin; +--eval select * from $table for update; + +connection $con_aux; +begin; +--send_eval $statement; + +--enable_result_log +--enable_query_log + +connection default; +# Wait until statement is successfully blocked because +# all rows in table are X-locked. This means that at +# least it acquires S-locks on some of rows. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state in ("Sending data","statistics", "preparing") and + info = "$wait_statement"; +--source include/wait_condition.inc + +--disable_result_log +--disable_query_log + +rollback; + +connection $con_aux; +--reap +rollback; + +connection default; +--enable_result_log +--enable_query_log + +if ($success) +{ +--echo Success: '$statement' takes shared row locks on '$table'. +} + +if (!$success) +{ +--echo Error: '$statement' hasn't taken shared row locks on '$table'! +} diff --git a/mysql-test/include/check_slave_is_running.inc b/mysql-test/include/check_slave_is_running.inc new file mode 100644 index 00000000000..5fbbe0d684c --- /dev/null +++ b/mysql-test/include/check_slave_is_running.inc @@ -0,0 +1,18 @@ +# ==== Purpose ==== +# +# Assert that the slave threads are running and don't have any errors. +# +# ==== Usage ==== +# +# --source include/check_slave_running.inc + +--echo Checking that both slave threads are running. + +--let $slave_sql_running = query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1) +--let $slave_io_running = query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1) + +if (`SELECT '$slave_sql_running' != 'Yes' OR '$slave_io_running' != 'Yes'`) { + --echo Slave not running: Slave_SQL_Running = $slave_sql_running Slave_IO_Running = $slave_io_running + --source include/show_rpl_debug_info.inc + --die Expected slave to be running, but it was not running. +} diff --git a/mysql-test/include/check_slave_no_error.inc b/mysql-test/include/check_slave_no_error.inc new file mode 100644 index 00000000000..371db5ed6a0 --- /dev/null +++ b/mysql-test/include/check_slave_no_error.inc @@ -0,0 +1,17 @@ +# ==== Purpose ==== +# +# Assert that Slave_SQL_Error and Slave_IO_Error are empty. +# +# ==== Usage ==== +# +# --let $slave_param= Exec_Master_Log_Pos +# --let $slave_param_value= 4711 +# --source include/check_slave_running.inc + +--let $slave_param= Last_SQL_Errno +--let $slave_param_value= 0 +--source include/check_slave_param.inc + +--let $slave_param= Last_IO_Errno +--let $slave_param_value= 0 +--source include/check_slave_param.inc diff --git a/mysql-test/include/check_slave_param.inc b/mysql-test/include/check_slave_param.inc new file mode 100644 index 00000000000..d82c26851ea --- /dev/null +++ b/mysql-test/include/check_slave_param.inc @@ -0,0 +1,16 @@ +# ==== Purpose ==== +# +# Assert that a given column in SHOW SLAVE STATUS has a given value. +# +# ==== Usage ==== +# +# --let $slave_param= Exec_Master_Log_Pos +# --let $slave_param_value= 4711 +# --source include/check_slave_param.inc + +--let $_param_value= query_get_value(SHOW SLAVE STATUS, $slave_param, 1) +if (`SELECT '$_param_value' != '$slave_param_value'`) { + --echo Wrong value for $slave_param. Expected '$slave_param_value', got '$_param_value' + --source include/show_rpl_debug_info.inc + --die Wrong value for slave parameter +} diff --git a/mysql-test/include/get_relay_log_pos.inc b/mysql-test/include/get_relay_log_pos.inc new file mode 100644 index 00000000000..7ce36fd3c50 --- /dev/null +++ b/mysql-test/include/get_relay_log_pos.inc @@ -0,0 +1,70 @@ +# For a given event which is at position $master_log_pos in the the master's +# binary log, returns its position in the slave's relay log file +# $relay_log_file. +# The position is stored in the variable $relay_log_pos. + +# Usage: +# let $relay_log_file= 'relay-log-bin.000001'; +# let $master_log_pos= 106; +# source include/get_relay_log_pos.inc; +# # at this point, get_relay_log_pos.inc sets $relay_log_pos. echo position +# # in $relay_log_file: $relay_log_pos. + +if (`SELECT '$relay_log_file' = ''`) +{ + --die 'variable $relay_log_file is null' +} + +if (`SELECT '$master_log_pos' = ''`) +{ + --die 'variable $master_log_pos is null' +} + +let $MYSQLD_DATADIR= `select @@datadir`; +let $_suffix= `SELECT UUID()`; +let $_tmp_file= $MYSQLTEST_VARDIR/tmp/mysqlbinlog.$_suffix; +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$relay_log_file > $_tmp_file + +# All queries in this file should not be logged. +--disable_query_log + +--disable_warnings +DROP TEMPORARY TABLE IF EXISTS mysqlbinlog_events; +DROP TEMPORARY TABLE IF EXISTS events_at; +DROP TEMPORARY TABLE IF EXISTS events_pos; +CREATE TEMPORARY TABLE mysqlbinlog_events(c1 INT AUTO_INCREMENT KEY, c2 varchar(256)); + +# Event position is in the comments output by mysqlbinlog, we load this +# comments into the table +# '# at 106' +# '# .... end_log_pos 46' +eval LOAD DATA LOCAL INFILE '$_tmp_file' INTO TABLE mysqlbinlog_events + LINES STARTING BY '#' (c2) SET c1 = NULL; +--enable_warnings + +# Event pos in relay log file is inserted into table events_at +CREATE TEMPORARY TABLE events_at(c1 INT AUTO_INCREMENT KEY, c2 varchar(256)) + SELECT c2 FROM mysqlbinlog_events WHERE c2 LIKE ' at%' ORDER BY c1; + +# Event pos in master log file is inserted into table events_pos +CREATE TEMPORARY TABLE events_pos(c1 INT AUTO_INCREMENT KEY, c2 varchar(256)) + SELECT c2 FROM mysqlbinlog_events WHERE c2 LIKE '% end_log_pos %' ORDER BY c1; + +# events_at events_pos +# c1------c2-------------------------- c1------c2------------------------ +# 1 ev1's begin pos in relay log 1 ev1's end pos in master log +# 2 ev2's begin pos in relay log 2 ev2's end pos in master log +# 3 ev3's begin pos in relay log 3 ev3's end pos in master log +# events always keep the same sequence. +# Because event[N]'s end pos is equal to event[N+1]'s begin pos we want to +# find event's end pos in relay log, we can find the right relay_log_pos +# using the relationship that 'events_pos.c1 = events_at.c1 + 1' +# +# There is a fault that we can't get the relay log position of the last event, +# as it is not output by mysqlbinlog +let $relay_log_pos= `SELECT SUBSTRING(a.c2, 5) + FROM events_at a, events_pos b + WHERE a.c1=b.c1+1 and b.c2 LIKE '% $master_log_pos%'`; +DROP TEMPORARY TABLE mysqlbinlog_events, events_at, events_pos; +--remove_file $_tmp_file +--enable_query_log diff --git a/mysql-test/include/mysqlhotcopy.inc b/mysql-test/include/mysqlhotcopy.inc new file mode 100644 index 00000000000..b3fd5e47179 --- /dev/null +++ b/mysql-test/include/mysqlhotcopy.inc @@ -0,0 +1,121 @@ +# Test of mysqlhotcopy (perl script) +# Author: Horst Hunger +# Created: 2010-05-10 + +--source include/not_windows.inc +--source include/not_embedded.inc + +if ($MYSQLHOTCOPY) +{ + die due to missing mysqlhotcopy tool; +} + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +--disable_warnings +DROP DATABASE IF EXISTS hotcopy_test; +--enable_warnings +CREATE DATABASE hotcopy_test; +USE hotcopy_test; +eval CREATE TABLE t1 (c1 int, c2 varchar(20)) ENGINE=$engine; +eval CREATE TABLE t2 (c1 int, c2 varchar(20)) ENGINE=$engine; +eval CREATE TABLE t3 (c1 int, c2 varchar(20)) ENGINE=$engine; + +INSERT INTO t1 VALUES (1,'aaaaaaaaaaaaaaaaaaaa'),(2, 'bbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t2 VALUES (1,'aaaaaaaaaaaaaaaaaaaa'),(2, 'bbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t3 VALUES (1,'aaaaaaaaaaaaaaaaaaaa'),(2, 'bbbbbbbbbbbbbbbbbbbbbbb'); + +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_test + +# backup into another database in the same directory +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save + +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_save + +USE hotcopy_save; +SELECT * FROM t1; +SELECT * FROM t2; +SELECT * FROM t3; + +# restore data into the original database with mysqlhotcopy +if(`SELECT engine= 'MyISAM' FROM information_schema.tables WHERE table_name='t1'`) +{ +USE hotcopy_test; +DELETE FROM t1; +SELECT * FROM t1; + +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--exec $MYSQLHOTCOPY --quiet --addtodest -S $MASTER_MYSOCK -u root hotcopy_save hotcopy_test + +USE hotcopy_save; +SELECT * FROM t1; +SELECT * FROM t2; +SELECT * FROM t3; +} + +USE hotcopy_test; +DROP TABLE t2; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_test + +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--exec $MYSQLHOTCOPY --quiet --addtodest -S $MASTER_MYSOCK -u root hotcopy_save hotcopy_test + +FLUSH TABLES; +SELECT * FROM t1; +SELECT * FROM t2; +SELECT * FROM t3; + +# backup of db into a directory +USE hotcopy_test; +--replace_result $MASTER_MYSOCK MASTER_MYSOCK $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test $MYSQLTEST_VARDIR/tmp +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--list_files $MYSQLTEST_VARDIR/tmp/hotcopy_test +#--exec rm -rf $MYSQLTEST_VARDIR/tmp/hotcopy_test +--remove_files_wildcard $MYSQLTEST_VARDIR/tmp/hotcopy_test * +--rmdir $MYSQLTEST_VARDIR/tmp/hotcopy_test + +# backup without full index files +# reproduction of bug#53556, "--list_files" shows MYI files, which is wrong. +DROP DATABASE hotcopy_save; +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--exec $MYSQLHOTCOPY --quiet --noindices -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_save + +# test of option "allowold" +DROP DATABASE hotcopy_save; +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_save +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--error 9,2304 +--exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--exec $MYSQLHOTCOPY --quiet --allowold -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_save + +# test of option "keepold" +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--exec $MYSQLHOTCOPY --quiet --keepold -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_save_old +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_save + +# test of option "suffix" +--replace_result $MASTER_MYSOCK MASTER_MYSOCK +--exec $MYSQLHOTCOPY --quiet --suffix=_cpy -S $MASTER_MYSOCK -u root hotcopy_test +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--list_files $MYSQLD_DATADIR/hotcopy_test_cpy +DROP DATABASE hotcopy_test_cpy; + +DROP DATABASE hotcopy_test; +DROP DATABASE hotcopy_save; +DROP DATABASE hotcopy_save_old; + diff --git a/mysql-test/include/rpl_stmt_seq.inc b/mysql-test/include/rpl_stmt_seq.inc index 6c944dc4729..08f6e44aba0 100644 --- a/mysql-test/include/rpl_stmt_seq.inc +++ b/mysql-test/include/rpl_stmt_seq.inc @@ -80,9 +80,8 @@ eval INSERT INTO t1 SET f1= $MAX + 1; SELECT MAX(f1) FROM t1; if ($show_binlog) { ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; + --let $binlog_file= master-bin.$_log_num_s + --source include/show_binlog_events.inc } sync_slave_with_master; @@ -93,9 +92,8 @@ connection slave; SELECT MAX(f1) FROM t1; if ($show_binlog) { ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; + --let $binlog_file= slave-bin.$_log_num_s + --source include/show_binlog_events.inc } ############################################################### @@ -111,9 +109,8 @@ let $my_stmt= ERROR: YOU FORGOT TO FILL IN THE STATEMENT; SELECT MAX(f1) FROM t1; if ($show_binlog) { ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; + --let $binlog_file= master-bin.$_log_num_s + --source include/show_binlog_events.inc } sync_slave_with_master; @@ -124,9 +121,8 @@ connection slave; SELECT MAX(f1) FROM t1; if ($show_binlog) { ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; + --let $binlog_file= slave-bin.$_log_num_s + --source include/show_binlog_events.inc } ############################################################### @@ -150,9 +146,8 @@ eval SELECT CONCAT(CONCAT('TEST-INFO: MASTER: The INSERT is ', --enable_query_log if ($show_binlog) { ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; + --let $binlog_file= master-bin.$_log_num_s + --source include/show_binlog_events.inc } sync_slave_with_master; @@ -171,9 +166,8 @@ eval SELECT CONCAT(CONCAT('TEST-INFO: SLAVE: The INSERT is ', --enable_query_log if ($show_binlog) { ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; + --let $binlog_file= slave-bin.$_log_num_s + --source include/show_binlog_events.inc } ############################################################### diff --git a/mysql-test/include/show_binlog_events.inc b/mysql-test/include/show_binlog_events.inc index 68f913a16a3..8649f31ad9f 100644 --- a/mysql-test/include/show_binlog_events.inc +++ b/mysql-test/include/show_binlog_events.inc @@ -1,10 +1,45 @@ -# $binlog_start can be set by caller or take a default value +############################################################################## +# Show binary log events +# +# Useage: +# let $binlog_file= master-bin.000002; +# let $binlog_start= 106; +# let $binlog_limit= 1, 3; +# source include/show_binlog_events.inc; +# +# It shows the first binary log file if $binlog_file is not given. +# +# It shows events from the end position of the description event if +# $binlog_start is not given. +# +# It shows all of the events if $binlog_limit is not given. +# $binlog_format has the same semantic with 'LIMIT' option. +# +############################################################################## if (!$binlog_start) { - let $binlog_start=106; + # If $binlog_start is not set, we will set it as the second event's position. + # The first event(Description Event) is always ignored. For description + # event's length might be changed because of adding new events, 'SHOW BINLOG + # EVENTS LIMIT 1' is used to get the right value. + --let $binlog_start= query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1) } + +--let $_statement=show binlog events +if (`SELECT '$binlog_file' <> ''`) +{ + --let $_statement= $_statement in '$binlog_file' +} + +--let $_statement= $_statement from $binlog_start + +if (`SELECT '$binlog_limit' <> ''`) +{ + --let $_statement= $_statement limit $binlog_limit +} + --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/ ---eval show binlog events from $binlog_start +--eval $_statement diff --git a/mysql-test/include/show_rpl_debug_info.inc b/mysql-test/include/show_rpl_debug_info.inc index 252d63f1bf4..148d11f3b02 100644 --- a/mysql-test/include/show_rpl_debug_info.inc +++ b/mysql-test/include/show_rpl_debug_info.inc @@ -36,6 +36,7 @@ let $_con= $CURRENT_CONNECTION; --echo --echo [on $_con] --echo +SELECT NOW(); --echo **** SHOW SLAVE STATUS on $_con **** query_vertical SHOW SLAVE STATUS; --echo @@ -70,6 +71,7 @@ if (`SELECT '$_master_con' != ''`) --echo [on $_master_con] connection $_master_con; --echo + SELECT NOW(); --echo **** SHOW MASTER STATUS on $_master_con **** query_vertical SHOW MASTER STATUS; --echo diff --git a/mysql-test/include/show_slave_status.inc b/mysql-test/include/show_slave_status.inc index b315b9e45ca..d66c068e19b 100644 --- a/mysql-test/include/show_slave_status.inc +++ b/mysql-test/include/show_slave_status.inc @@ -1,6 +1,25 @@ # Include file to show the slave status, masking out some information # that varies depending on where the test is executed. ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 16 # 23 # 33 # 35 # 36 # -query_vertical SHOW SLAVE STATUS; +--let $_items=$status_items +if (`SELECT "XX$status_items" = "XX"`) +{ + --die 'Variable status_items is NULL' +} + +--disable_query_log +--vertical_results + +while (`SELECT "XX$_items" <> "XX"`) +{ + --let $_name= `SELECT SUBSTRING_INDEX('$_items', ',', 1)` + --let $_items= `SELECT LTRIM(SUBSTRING('$_items', LENGTH('$_name') + 2))` + + --let $_value= query_get_value(SHOW SLAVE STATUS, $_name, 1) + + --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR + --eval SELECT "$_value" AS $_name +} + +--horizontal_results +--enable_query_log diff --git a/mysql-test/include/show_slave_status2.inc b/mysql-test/include/show_slave_status2.inc deleted file mode 100644 index 9c4e14c62c2..00000000000 --- a/mysql-test/include/show_slave_status2.inc +++ /dev/null @@ -1,8 +0,0 @@ -# Include file to show the slave status, masking out some information -# that varies depending on where the test is executed. - -# masked out log positions - ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 # -query_vertical SHOW SLAVE STATUS; diff --git a/mysql-test/include/test_fieldsize.inc b/mysql-test/include/test_fieldsize.inc index 606bc63779d..57dba4d1cc0 100644 --- a/mysql-test/include/test_fieldsize.inc +++ b/mysql-test/include/test_fieldsize.inc @@ -22,10 +22,9 @@ eval $test_insert; connection slave; START SLAVE; ---source include/wait_for_slave_sql_to_stop.inc ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 # ---query_vertical SHOW SLAVE STATUS +--let $slave_sql_errno= 1535 +--let $show_slave_sql_error= 1 +--source include/wait_for_slave_sql_error.inc # The following should be 0 SELECT COUNT(*) FROM t1; diff --git a/mysql-test/include/wait_for_binlog_event.inc b/mysql-test/include/wait_for_binlog_event.inc index 2a57c191413..7a55c8c2182 100644 --- a/mysql-test/include/wait_for_binlog_event.inc +++ b/mysql-test/include/wait_for_binlog_event.inc @@ -18,7 +18,7 @@ while (`SELECT INSTR("$_last_event","$wait_binlog_event") = 0`) dec $_loop_count; if (!$_loop_count) { - SHOW BINLOG EVENTS; + --source include/show_rpl_debug_info.inc --die ERROR: failed while waiting for $wait_binlog_event in binlog } real_sleep 0.1; diff --git a/mysql-test/include/wait_for_slave_io_error.inc b/mysql-test/include/wait_for_slave_io_error.inc index 094406e02b2..34cbf20a73b 100644 --- a/mysql-test/include/wait_for_slave_io_error.inc +++ b/mysql-test/include/wait_for_slave_io_error.inc @@ -1,23 +1,59 @@ # ==== Purpose ==== # # Waits until the IO thread of the current connection has got an -# error, or until a timeout is reached. +# error, or until a timeout is reached. Also waits until the IO +# thread has completely stopped. # # ==== Usage ==== # +# # Wait several errors. +# let $slave_io_errno= 1, 2, 3; # source include/wait_for_slave_io_error.inc; # -# Parameters to this macro are $slave_timeout and -# $slave_keep_connection. See wait_for_slave_param.inc for -# descriptions. +# # Print error message +# let $slave_io_errno= 1; +# let $show_slave_io_error= 1; +# source include/wait_for_slave_io_error.inc; +# +# Parameters: +# +# $slave_io_errno +# The expected IO error numbers. This is required. +# (After BUG#41956 has been fixed, this will be required to be a +# symbolic name instead of a numbers.) +# +# $show_slave_io_error +# If set, will print the error to the query log. +# +# $slave_timeout +# See wait_for_slave_param.inc for description. +# +# $master_connection +# See wait_for_slave_param.inc for description. -let $old_slave_param_comparison= $slave_param_comparison; +if (`SELECT '$slave_io_errno' = ''`) { + --die !!!ERROR IN TEST: you must set \$slave_io_errno before sourcing wait_for_slave_io_error.inc +} +let $old_slave_param_comparison= $slave_param_comparison; let $slave_param= Last_IO_Errno; let $slave_param_comparison= !=; let $slave_param_value= 0; let $slave_error_message= Failed while waiting for slave to produce an error in its sql thread; source include/wait_for_slave_param.inc; let $slave_error_message= ; - let $slave_param_comparison= $old_slave_param_comparison; + +let $_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1); +if (`SELECT $_error NOT IN ($slave_io_errno)`) { + --echo **** Slave stopped with wrong error code: $_error (expected $slave_io_errno) **** + source include/show_rpl_debug_info.inc; + --echo **** Slave stopped with wrong error code: $_error (expected $slave_io_errno) **** + --die Slave stopped with wrong error code +} + +if ($show_slave_io_error) +{ + let $error= query_get_value("SHOW SLAVE STATUS", Last_IO_Error, 1); + echo Last_IO_Error = $error; +} diff --git a/mysql-test/include/wait_for_slave_param.inc b/mysql-test/include/wait_for_slave_param.inc index 82e57922913..ef864f9245e 100644 --- a/mysql-test/include/wait_for_slave_param.inc +++ b/mysql-test/include/wait_for_slave_param.inc @@ -78,5 +78,5 @@ if (!$_slave_timeout_counter) --echo Current connection is '$CURRENT_CONNECTION' echo Note: the following output may have changed since the failure was detected; source include/show_rpl_debug_info.inc; - exit; + die; } diff --git a/mysql-test/include/wait_for_slave_sql_error.inc b/mysql-test/include/wait_for_slave_sql_error.inc index ad1d7a9e639..aab04036eea 100644 --- a/mysql-test/include/wait_for_slave_sql_error.inc +++ b/mysql-test/include/wait_for_slave_sql_error.inc @@ -14,6 +14,9 @@ # The expected SQL error number. This is required. # (After BUG#41956 has been fixed, this will be required to be a # symbolic name instead of a number.) +# +# $show_slave_sql_error +# If set, will print the error to the query log. # # $slave_timeout # See wait_for_slave_param.inc for description. @@ -22,8 +25,7 @@ # See wait_for_slave_param.inc for description. if (`SELECT '$slave_sql_errno' = ''`) { - --echo !!!ERROR IN TEST: you must set \$slave_sql_errno before sourcing wait_fro_slave_sql_error.inc - exit; + --die !!!ERROR IN TEST: you must set \$slave_sql_errno before sourcing wait_for_slave_sql_error.inc } let $slave_param= Slave_SQL_Running; @@ -33,7 +35,14 @@ source include/wait_for_slave_param.inc; let $_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1); if (`SELECT '$_error' != '$slave_sql_errno'`) { - --echo Slave stopped with wrong error code: $_error (expected $slave_sql_errno) + --echo **** Slave stopped with wrong error code: $_error (expected $slave_sql_errno) **** source include/show_rpl_debug_info.inc; - exit; + --echo **** Slave stopped with wrong error code: $_error (expected $slave_sql_errno) **** + --die Slave stopped with wrong error code +} + +if ($show_slave_sql_error) +{ + let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); + echo Last_SQL_Error = $error; } diff --git a/mysql-test/include/wait_for_slave_sql_error_and_skip.inc b/mysql-test/include/wait_for_slave_sql_error_and_skip.inc index 247de3a41a1..11c02c0b490 100644 --- a/mysql-test/include/wait_for_slave_sql_error_and_skip.inc +++ b/mysql-test/include/wait_for_slave_sql_error_and_skip.inc @@ -22,17 +22,30 @@ # # $master_connection # See wait_for_slave_param.inc for description. +# +# $slave_skip_counter +# If set, skip this number of events. If not set, skip one event. +# +# $not_switch_connection If set, don't switch to slave and don't switch back +# master. +# echo --source include/wait_for_slave_sql_error_and_skip.inc; -connection slave; -source include/wait_for_slave_sql_error.inc; -if ($show_sql_error) +if (!$not_switch_connection) { - let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); - echo Last_SQL_Error = $error; + connection slave; } +source include/wait_for_slave_sql_error.inc; # skip the erroneous statement -set global sql_slave_skip_counter=1; +if ($slave_skip_counter) { + eval SET GLOBAL SQL_SLAVE_SKIP_COUNTER= $slave_skip_counter; +} +if (!$slave_skip_counter) { + SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; +} source include/start_slave.inc; -connection master; +if (!$not_switch_connection) +{ + connection master; +} diff --git a/mysql-test/include/wait_for_status_var.inc b/mysql-test/include/wait_for_status_var.inc index 6ba632ce46b..b8b4fa20b86 100644 --- a/mysql-test/include/wait_for_status_var.inc +++ b/mysql-test/include/wait_for_status_var.inc @@ -35,7 +35,7 @@ if (`SELECT STRCMP('$status_type', '') * STRCMP(UPPER('$status_type'), 'SESSION') * STRCMP(UPPER('$status_type'), 'GLOBAL')`) { --echo **** ERROR: Unknown type of variable status_type: allowed values are: SESSION or GLOBAL **** - exit; + die; } let $_status_timeout_counter= $status_timeout; @@ -61,7 +61,7 @@ while (`SELECT NOT('$_show_status_value' $_status_var_comparsion '$status_var_va --echo **** Showing STATUS, PROCESSLIST **** eval SHOW $status_type STATUS LIKE '$status_var'; SHOW PROCESSLIST; - exit; + die; } dec $_status_timeout_counter; sleep 0.1; diff --git a/mysql-test/include/wait_until_count_sessions.inc b/mysql-test/include/wait_until_count_sessions.inc index de4f0eeb652..26b0d8f2633 100644 --- a/mysql-test/include/wait_until_count_sessions.inc +++ b/mysql-test/include/wait_until_count_sessions.inc @@ -122,5 +122,6 @@ if (!$success) --echo # Timeout in wait_until_count_sessions.inc --echo # Number of sessions expected: <= $count_sessions found: $current_sessions SHOW PROCESSLIST; + --die Timeout in wait_until_count_sessions.inc } |