Commit bfb18f9a authored by unknown's avatar unknown

WL#3949, second part. Added soft switching of the binlog format (w/o restart a server)


mysql-test/lib/mtr_cases.pl:
  updated the code for combination
mysql-test/mysql-test-run.pl:
  added soft switching of binlog format
mysql-test/lib/mtr_misc.pl:
  added new sub mtr_diff_opts
mysql-test/suite/rpl/r/rpl_invoked_features.result:
  updated result
mysql-test/suite/rpl/t/rpl_invoked_features.test:
  updated test
mysql-test/suite/rpl/t/rpl_misc_functions.test:
  updated test
mysql-test/suite/rpl/t/rpl_session_var.test:
  updated test
parent 8f798dff
......@@ -367,6 +367,7 @@ sub collect_one_suite($$)
# ----------------------------------------------------------------------
if ($combinations && $begin_index <= $#{@$cases})
{
my $prepared = {};
my $end_index = $#{@$cases};
my $is_copy;
# Keep original master/slave options
......@@ -397,7 +398,7 @@ sub collect_one_suite($$)
@$new_arr = @{$orig_opts[$idx]{$param}};
$copied_test->{$param} = $new_arr;
}
elsif ($param =~ /(comment|combinations)/)
elsif ($param =~ /combinations/)
{
$copied_test->{$param} = '';
}
......@@ -415,18 +416,29 @@ sub collect_one_suite($$)
if ($comb_opt =~ /^--binlog-format=.+$/)
{
my @opt_pairs = split(/=/, $comb_opt);
if ($test->{'binlog_format'} =~ /^$opt_pairs[1]$/ || $test->{'binlog_format'} eq '')
if (defined $::used_binlog_format)
{
$test->{'skip'} = 0;
$test->{'comment'} = '';
if ($test->{'binlog_format'} ne $::used_binlog_format)
{
$test->{'skip'} = 1;
$test->{'comment'} = "Requiring binlog format ".join(' or ', @{$test->{'sup_binlog_formats'}});
}
}
else
{
foreach my $binlog_format (@{$test->{'sup_binlog_formats'}})
{
$test->{'binlog_format'}= $binlog_format if ($binlog_format eq $opt_pairs[1]);
}
if (defined $prepared->{$test->{'name'}.'|'.$test->{'binlog_format'}} and $test->{'skip'} ne 1 )
{
$test->{'skip'} = 1;
$test->{'comment'} = "Requiring binlog format '$test->{'binlog_format'}'";;
$test->{'comment'} = "Test for binlog format '$test->{'binlog_format'}' already executed";
}
}
}
}
$prepared->{$test->{'name'}.'|'.$test->{'binlog_format'}}= 1;
$test->{'combination'} = $comb_set;
}
$is_copy = 1;
......@@ -524,6 +536,7 @@ sub collect_one_test_case($$$$$$$$$) {
$tinfo->{'slave_opt'}= [];
$tinfo->{'slave_mi'}= [];
# Add suite opts
foreach my $opt ( @$suite_opts )
{
......@@ -737,13 +750,42 @@ sub collect_one_test_case($$$$$$$$$) {
return;
}
if ( defined $tinfo->{'binlog_format'} and
! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) )
# Replication test needs an adjustment of binlog format
if ($tinfo->{'name'} =~ /^rpl/)
{
# Set default binlog format priority
if ($tinfo->{'name'} =~ /^rpl/ and !defined $tinfo->{'sup_binlog_formats'})
{
if ($::mysql_version_id >= 50100)
{
$tinfo->{'sup_binlog_formats'} = ["mixed", "row", "statement"];
}
else
{
$tinfo->{'sup_binlog_formats'} = ["statement", "row"];
}
}
# Check that a test supports binlog format defined via --binlog-format
if (defined $::used_binlog_format)
{
# Try to find a supported binlog formats
foreach my $binlog_format (@{$tinfo->{'sup_binlog_formats'}})
{
$tinfo->{'binlog_format'}= $binlog_format unless ($binlog_format ne $::used_binlog_format);
}
# Skip a test because
if (!defined $tinfo->{'binlog_format'})
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Requiring binlog format '$tinfo->{'binlog_format'}'";
$tinfo->{'comment'}= "Requiring binlog format ".join(' or ', @{$tinfo->{'sup_binlog_formats'}});
return;
}
}
else
{
$tinfo->{'binlog_format'}= $tinfo->{'sup_binlog_formats'}->[0];
}
}
if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries )
{
......@@ -824,10 +866,13 @@ sub collect_one_test_case($$$$$$$$$) {
our @tags=
(
["include/have_innodb.inc", "innodb_test", 1],
["include/have_binlog_format_row.inc", "binlog_format", "row"],
["include/have_binlog_format_row.inc", "sup_binlog_formats", ["row"]],
["include/have_log_bin.inc", "need_binlog", 1],
["include/have_binlog_format_statement.inc", "binlog_format", "statement"],
["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"],
["include/have_binlog_format_statement.inc", "sup_binlog_formats", ["statement"]],
["include/have_binlog_format_mixed.inc", "sup_binlog_formats", ["mixed"]],
["include/have_binlog_format_mixed_or_row.inc", "sup_binlog_formats", ["mixed","row"]],
["include/have_binlog_format_mixed_or_statement.inc", "sup_binlog_formats", ["mixed","statement"]],
["include/have_binlog_format_row_or_statement.inc", "sup_binlog_formats", ["row","statement"]],
["include/big_test.inc", "big_test", 1],
["include/have_debug.inc", "need_debug", 1],
["include/have_ndb.inc", "ndb_test", 1],
......
......@@ -280,4 +280,33 @@ sub mtr_cmp_opts ($$) {
return 0; # They are the same
}
#
# Compare two arrays and put all unequal elements into a new one
#
sub mtr_diff_opts ($$) {
my $l1= shift;
my $l2= shift;
my $f;
my $l= [];
foreach my $e1 (@$l1)
{
$f= undef;
foreach my $e2 (@$l2)
{
$f= 1 unless ($e1 ne $e2);
}
push(@$l, $e1) unless (defined $f);
}
foreach my $e2 (@$l2)
{
$f= undef;
foreach my $e1 (@$l1)
{
$f= 1 unless ($e1 ne $e2);
}
push(@$l, $e2) unless (defined $f);
}
return $l;
}
1;
......@@ -792,12 +792,8 @@ sub command_line_setup () {
# --------------------------------------------------------------------------
# Find out type of logging that are being used
# --------------------------------------------------------------------------
# NOTE if the default binlog format is changed, this has to be changed
$used_binlog_format= "statement";
if (!$opt_extern && $mysql_version_id >= 50100 )
{
$used_binlog_format= "mixed"; # Default value for binlog format
foreach my $arg ( @opt_extra_mysqld_opt )
{
if ( $arg =~ /binlog[-_]format=(\S+)/ )
......@@ -805,8 +801,15 @@ sub command_line_setup () {
$used_binlog_format= $1;
}
}
if (defined $used_binlog_format)
{
mtr_report("Using binlog format '$used_binlog_format'");
}
else
{
mtr_report("Using dynamic switching of binlog format");
}
}
# --------------------------------------------------------------------------
......@@ -3304,6 +3307,7 @@ sub run_testcase_check_skip_test($)
sub do_before_run_mysqltest($)
{
my $tinfo= shift;
my $args;
# Remove old files produced by mysqltest
my $base_file= mtr_match_extension($tinfo->{'result_file'},
......@@ -3324,6 +3328,26 @@ sub do_before_run_mysqltest($)
# if script decided to run mysqltest cluster _is_ installed ok
$ENV{'NDB_STATUS_OK'} = "YES";
}
if (defined $tinfo->{"binlog_format"} and $mysql_version_id > 50100 )
{
foreach my $server ((@$master,@$slave))
{
if ($server->{'pid'})
{
mtr_init_args(\$args);
mtr_add_arg($args, "--no-defaults");
mtr_add_arg($args, "--user=root");
mtr_add_arg($args, "--port=$server->{'port'}");
mtr_add_arg($args, "--socket=$server->{'path_sock'}");
mtr_run($exe_mysql, $args, "$glob_mysql_test_dir/include/set_binlog_format_".$tinfo->{"binlog_format"}.".inc", "", "", "", {});
}
}
}
}
}
......@@ -4217,12 +4241,21 @@ sub run_testcase_need_master_restart($)
# as the current test requires
elsif (! mtr_same_opts($master->[0]->{'start_opts'},
$tinfo->{'master_opt'}) )
{
# Chech that diff is binlog format only
my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
if (scalar(@$diff_opts) eq 2)
{
$do_restart= 1 unless ($diff_opts->[0] =~/^--binlog-format=/ and $diff_opts->[1] =~/^--binlog-format=/);
}
else
{
$do_restart= 1;
mtr_verbose("Restart master: running with different options '" .
join(" ", @{$tinfo->{'master_opt'}}) . "' != '" .
join(" ", @{$master->[0]->{'start_opts'}}) . "'" );
}
}
elsif( ! $master->[0]->{'pid'} )
{
if ( $opt_extern )
......
set autocommit=1;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; insert into bug16206 values(2)
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb
f n Query 1 n use `test`; insert into bug16206 values(0)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; BEGIN
f n Query 1 n use `test`; insert into bug16206 values(2)
f n Query 1 n use `test`; COMMIT
f n Query 1 n use `test`; insert into bug16206 values(3)
drop table bug16206;
set autocommit=0;
End of 5.0 tests
......@@ -116,23 +116,23 @@ t12
t13
t2
t3
SELECT table_name FROM information_schema.views WHERE table_schema='test';
SELECT table_name FROM information_schema.views WHERE table_schema='test' ORDER BY table_name;
table_name
v1
v11
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test';
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test' ORDER BY trigger_name;
trigger_name event_manipulation event_object_table
t1_tr1 INSERT t1
t1_tr2 UPDATE t1
t11_tr1 INSERT t11
t11_tr2 UPDATE t11
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test';
t1_tr1 INSERT t1
t1_tr2 UPDATE t1
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test' ORDER BY routine_name;
routine_type routine_name
FUNCTION f1
FUNCTION f2
PROCEDURE p1
PROCEDURE p11
SELECT event_name, status FROM information_schema.events WHERE event_schema='test';
SELECT event_name, status FROM information_schema.events WHERE event_schema='test' ORDER BY event_name;
event_name status
e1 DISABLED
e11 DISABLED
......@@ -276,23 +276,23 @@ t12
t13
t2
t3
SELECT table_name FROM information_schema.views WHERE table_schema='test';
SELECT table_name FROM information_schema.views WHERE table_schema='test' ORDER BY table_name;
table_name
v1
v11
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test';
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test' ORDER BY trigger_name;
trigger_name event_manipulation event_object_table
t1_tr1 INSERT t1
t1_tr2 UPDATE t1
t11_tr1 INSERT t11
t11_tr2 UPDATE t11
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test';
t1_tr1 INSERT t1
t1_tr2 UPDATE t1
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test' ORDER BY routine_name;
routine_type routine_name
FUNCTION f1
FUNCTION f2
PROCEDURE p1
PROCEDURE p11
SELECT event_name, status FROM information_schema.events WHERE event_schema='test';
SELECT event_name, status FROM information_schema.events WHERE event_schema='test' ORDER BY event_name;
event_name status
e1 SLAVESIDE_DISABLED
e11 SLAVESIDE_DISABLED
......
......@@ -202,10 +202,10 @@ SET GLOBAL EVENT_SCHEDULER = off;
# Check original objects
--echo
SHOW TABLES LIKE 't%';
SELECT table_name FROM information_schema.views WHERE table_schema='test';
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test';
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test';
SELECT event_name, status FROM information_schema.events WHERE event_schema='test';
SELECT table_name FROM information_schema.views WHERE table_schema='test' ORDER BY table_name;
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test' ORDER BY trigger_name;
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test' ORDER BY routine_name;
SELECT event_name, status FROM information_schema.events WHERE event_schema='test' ORDER BY event_name;
# Check original data
--echo
......@@ -229,10 +229,10 @@ SELECT a,b FROM v11 ORDER BY a;
# Check replicated objects
--echo
SHOW TABLES LIKE 't%';
SELECT table_name FROM information_schema.views WHERE table_schema='test';
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test';
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test';
SELECT event_name, status FROM information_schema.events WHERE event_schema='test';
SELECT table_name FROM information_schema.views WHERE table_schema='test' ORDER BY table_name;
SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test' ORDER BY trigger_name;
SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test' ORDER BY routine_name;
SELECT event_name, status FROM information_schema.events WHERE event_schema='test' ORDER BY event_name;
# Check replicated data
--echo
......
......@@ -109,6 +109,7 @@ DROP TABLE t1, t1_slave;
DROP PROCEDURE test_replication_sp1;
DROP PROCEDURE test_replication_sp2;
DROP FUNCTION test_replication_sf;
--remove_file $MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile
--sync_slave_with_master
......@@ -51,8 +51,9 @@ CREATE TABLE t1 (
`data` varchar(100),
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
--disable_warnings
INSERT INTO t1(data) VALUES(SESSION_USER());
--enable_warnings
save_master_pos;
connection slave;
sync_with_master;
......
-- source include/not_embedded.inc
-- source include/have_bdb.inc
#
# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode
#
set autocommit=1;
let $VERSION=`select version()`;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
set autocommit=0;
--echo End of 5.0 tests
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