From ff179e371f6ed583fcefe7e4b53917d2fe4f7c93 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Tue, 20 Jun 2006 10:40:36 +0200 Subject: [PATCH 1/5] Fix for BUG#20522 "RBR: CREATE TEMPORARY TABLE SELECT writes to binlog though unneeded". It's indeed unneeded, as slave is only interested in permanent tables, and permanent tables don't depend on temporary tables when in row-based binlogging mode. And other CREATE TEMPORARY TABLE (referring no table or with LIKE) already don't write the CREATE to binlog in row-based mode. --- mysql-test/r/rpl_row_create_table.result | 1 + mysql-test/t/rpl_row_create_table.test | 1 + sql/sql_class.h | 3 ++- sql/sql_insert.cc | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/rpl_row_create_table.result b/mysql-test/r/rpl_row_create_table.result index b3a8f5e1a0f..75807c8bfc9 100644 --- a/mysql-test/r/rpl_row_create_table.result +++ b/mysql-test/r/rpl_row_create_table.result @@ -178,6 +178,7 @@ CREATE TABLE t8 LIKE t4; CREATE TABLE t9 LIKE tt4; CREATE TEMPORARY TABLE tt5 LIKE t4; CREATE TEMPORARY TABLE tt6 LIKE tt4; +CREATE TEMPORARY TABLE tt7 SELECT 1; **** On Master **** SHOW CREATE TABLE t8; Table t8 diff --git a/mysql-test/t/rpl_row_create_table.test b/mysql-test/t/rpl_row_create_table.test index 0cb0fd766a3..4f01d7e5459 100644 --- a/mysql-test/t/rpl_row_create_table.test +++ b/mysql-test/t/rpl_row_create_table.test @@ -97,6 +97,7 @@ CREATE TABLE t8 LIKE t4; CREATE TABLE t9 LIKE tt4; CREATE TEMPORARY TABLE tt5 LIKE t4; CREATE TEMPORARY TABLE tt6 LIKE tt4; +CREATE TEMPORARY TABLE tt7 SELECT 1; --echo **** On Master **** --query_vertical SHOW CREATE TABLE t8 --query_vertical SHOW CREATE TABLE t9 diff --git a/sql/sql_class.h b/sql/sql_class.h index 723dad715bd..b5328d4c56b 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1610,7 +1610,8 @@ public: virtual bool can_rollback_data() { return 1; } // Needed for access from local class MY_HOOKS in prepare(), since thd is proteted. - THD *get_thd(void) { return thd; } + const THD *get_thd(void) { return thd; } + const HA_CREATE_INFO *get_create_info() { return create_info; }; }; #include diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f1f97400283..dc27adb853a 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2714,7 +2714,8 @@ public: MY_HOOKS(select_create *x) : ptr(x) { } virtual void do_prelock(TABLE **tables, uint count) { - if (ptr->get_thd()->current_stmt_binlog_row_based) + if (ptr->get_thd()->current_stmt_binlog_row_based && + !(ptr->get_create_info()->options & HA_LEX_CREATE_TMP_TABLE)) ptr->binlog_show_create_table(tables, count); } From fd520be81762e57e2c146227743c78e065a3df7e Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Thu, 6 Jul 2006 17:40:36 +0200 Subject: [PATCH 2/5] Behaviour change of mysql-test-run.pl: by default we never run disabled tests (even if they're explicitely listed on the command-line). We add an option --enable-disabled which will run tests even though they are disabled, and will print, for each such test, the comment explaining why it was disabled. The reason for the change is when you want to run "all tests which are about NDB" for example: mysql-test-run.pl t/*ndb*.test used to run some disabled NDB tests, causing failures, causing investigations. Code amended and approved by Kent. --- mysql-test/lib/mtr_cases.pl | 61 ++++++++++++++++++++++-------------- mysql-test/lib/mtr_report.pl | 18 +++++++++++ mysql-test/mysql-test-run.pl | 6 ++-- 3 files changed, 60 insertions(+), 25 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 448ca90d48d..6f326562649 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -37,6 +37,23 @@ sub collect_test_cases ($) { opendir(TESTDIR, $testdir) or mtr_error("Can't open dir \"$testdir\": $!"); + # ---------------------------------------------------------------------- + # Disable some tests listed in disabled.def + # ---------------------------------------------------------------------- + my %disabled; + if ( open(DISABLED, "$testdir/disabled.def" ) ) + { + while ( ) + { + chomp; + if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ ) + { + $disabled{$1}= $2; + } + } + close DISABLED; + } + if ( @::opt_cases ) { foreach my $tname ( @::opt_cases ) { # Run in specified order, no sort @@ -100,30 +117,13 @@ sub collect_test_cases ($) { } } - collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,{}, + collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled, $component_id); } closedir TESTDIR; } else { - # ---------------------------------------------------------------------- - # Disable some tests listed in disabled.def - # ---------------------------------------------------------------------- - my %disabled; - if ( ! $::opt_ignore_disabled_def and open(DISABLED, "$testdir/disabled.def" ) ) - { - while ( ) - { - chomp; - if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ ) - { - $disabled{$1}= $2; - } - } - close DISABLED; - } - foreach my $elem ( sort readdir(TESTDIR) ) { my $component_id= undef; my $tname= undef; @@ -414,20 +414,35 @@ sub collect_one_test_case($$$$$$$) { } # FIXME why this late? + my $marked_as_disabled= 0; if ( $disabled->{$tname} ) { - $tinfo->{'skip'}= 1; - $tinfo->{'disable'}= 1; # Sub type of 'skip' - $tinfo->{'comment'}= $disabled->{$tname} if $disabled->{$tname}; + $marked_as_disabled= 1; + $tinfo->{'comment'}= $disabled->{$tname}; } if ( -f $disabled_file ) { - $tinfo->{'skip'}= 1; - $tinfo->{'disable'}= 1; # Sub type of 'skip' + $marked_as_disabled= 1; $tinfo->{'comment'}= mtr_fromfile($disabled_file); } + # If test was marked as disabled, either opt_enable_disabled is off and then + # we skip this test, or it is on and then we run this test but warn + + if ( $marked_as_disabled ) + { + if ( $::opt_enable_disabled ) + { + $tinfo->{'dont_skip_though_disabled'}= 1; + } + else + { + $tinfo->{'skip'}= 1; + $tinfo->{'disable'}= 1; # Sub type of 'skip' + } + } + if ( $component_id eq 'im' ) { if ( $::glob_use_embedded_server ) diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index f2da89355f7..6a68e3a68d0 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -10,6 +10,7 @@ sub mtr_report_test_name($); sub mtr_report_test_passed($); sub mtr_report_test_failed($); sub mtr_report_test_skipped($); +sub mtr_report_test_not_skipped_though_disabled($); sub mtr_show_failed_diff ($); sub mtr_report_stats ($); @@ -100,6 +101,23 @@ sub mtr_report_test_skipped ($) { } } +sub mtr_report_tests_not_skipped_though_disabled ($) { + my $tests= shift; + + if ( $::opt_enable_disabled ) + { + my @disabled_tests= grep {$_->{'dont_skip_though_disabled'}} @$tests; + if ( @disabled_tests ) + { + print "\nTest(s) which will be run though they are marked as disabled:\n"; + foreach my $tinfo ( sort {$a->{'name'} cmp $b->{'name'}} @disabled_tests ) + { + printf " %-20s : %s\n", $tinfo->{'name'}, $tinfo->{'comment'}; + } + } + } +} + sub mtr_report_test_passed ($) { my $tinfo= shift; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ec105b29e3f..fcaf43d1b56 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -216,6 +216,7 @@ our $opt_extern; our $opt_fast; our $opt_force; our $opt_reorder; +our $opt_enable_disabled; our $opt_gcov; our $opt_gcov_err; @@ -661,6 +662,7 @@ sub command_line_setup () { 'netware' => \$opt_netware, 'old-master' => \$opt_old_master, 'reorder' => \$opt_reorder, + 'enable-disabled' => \$opt_enable_disabled, 'script-debug' => \$opt_script_debug, 'sleep=i' => \$opt_sleep, 'socket=s' => \$opt_socket, @@ -1781,12 +1783,12 @@ sub run_suite () { mtr_print_thick_line(); - mtr_report("Finding Tests in the '$suite' suite"); - mtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout); mtr_report("Starting Tests in the '$suite' suite"); + mtr_report_tests_not_skipped_though_disabled($tests); + mtr_print_header(); foreach my $tinfo ( @$tests ) From a5f184d5c7bf7da7f1fbcab7f6b8d41a5a676825 Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Thu, 6 Jul 2006 17:54:04 +0200 Subject: [PATCH 3/5] Fix for BUG#20649 "mixed replication mode does not work with INSERT DELAYED". The bug was that if the server was running in mixed binlogging mode, and an INSERT DELAYED used some needing-row-based components like UUID(), the server didn't binlog this row-based but statement-based, which thus failed to insert correct data on the slave. This changeset implements that when a delayed_insert thread is created, if the server's global binlog mode is "mixed", that thread will use row-based. This also fixes BUG#20633 "INSERT DELAYED RAND() or @user_var does not replicate statement-based": we don't fix it in statement-based mode (would require bookeeping of rand seeds and user variables used by each row), but at least it will now work in mixed mode (as row-based will be used). We re-enable rpl_switch_stm_row_mixed.test (so BUG#18590 which was about re-enabling this test, will be closed) to test the fixes. Between when it was disabled and now, some good changes to row-based binlogging (no generation of table map events for non-changed tables) induce changes in the test's result file. --- mysql-test/r/rpl_switch_stm_row_mixed.result | 24 ++++++++++++++------ mysql-test/t/disabled.def | 1 - mysql-test/t/rpl_switch_stm_row_mixed.test | 7 ++++++ sql/sql_insert.cc | 3 +++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/rpl_switch_stm_row_mixed.result b/mysql-test/r/rpl_switch_stm_row_mixed.result index 313037bb9dc..7c6a984bed8 100644 --- a/mysql-test/r/rpl_switch_stm_row_mixed.result +++ b/mysql-test/r/rpl_switch_stm_row_mixed.result @@ -142,12 +142,20 @@ select foo3(); ERROR HY000: Cannot change the binary logging format inside a stored function or trigger select * from t1 where a="alarm"; a +insert delayed into t2 values("delay_1_"); +insert delayed into t2 values(concat("delay_2_",UUID())); +Warnings: +Warning 1265 Data truncated for column 'UUID()' at row 1 +insert delayed into t2 values("delay_3_"),(concat("delay_4_",UUID())),("delay_5_"); +Warnings: +Warning 1265 Data truncated for column 'UUID()' at row 2 +insert delayed into t2 values("delay_6_"); select count(*) from t1; count(*) 36 select count(*) from t2; count(*) -1 +7 select count(*) from t3; count(*) 2 @@ -160,8 +168,6 @@ count(*) show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest1 -master-bin.000001 # Table_map 1 # table_id: # (mysql.proc) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # create database mysqltest1 master-bin.000001 # Query 1 # use `mysqltest1`; CREATE TABLE t1 (a varchar(100)) master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1) @@ -178,10 +184,6 @@ master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values("work") master-bin.000001 # User var 1 # @`string`=_latin1 0x656D657267656E6379 COLLATE latin1_swedish_ci master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 select @'string' @@ -269,4 +271,12 @@ master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t2) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t2) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t2) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t2) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F drop database mysqltest1; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 6f26847f8d7..a0b61f21047 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -32,7 +32,6 @@ rpl_ndb_ddl : BUG#18946 result file needs update + test needs to ch rpl_ndb_innodb2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement #rpl_ndb_log : BUG#18947 2006-03-21 tomas CRBR: order in binlog of create table and insert (on different table) not determ rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement -rpl_switch_stm_row_mixed : BUG#18590 2006-03-28 brian rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly rpl_row_func003 : BUG#19074 2006-13-04 andrei test failed rpl_sp : BUG#16456 2006-02-16 jmiller diff --git a/mysql-test/t/rpl_switch_stm_row_mixed.test b/mysql-test/t/rpl_switch_stm_row_mixed.test index 4a79b3995c4..f7d942c319b 100644 --- a/mysql-test/t/rpl_switch_stm_row_mixed.test +++ b/mysql-test/t/rpl_switch_stm_row_mixed.test @@ -154,6 +154,13 @@ call foo2(); select foo3(); select * from t1 where a="alarm"; +# Test that INSERT DELAYED works in mixed mode +insert delayed into t2 values("delay_1_"); +insert delayed into t2 values(concat("delay_2_",UUID())); +insert delayed into t2 values("delay_3_"),(concat("delay_4_",UUID())),("delay_5_"); +insert delayed into t2 values("delay_6_"); +sleep 4; # time for the delayed insert to reach disk + # If you want to do manual testing of the mixed mode regarding UDFs (not # testable automatically as quite platform- and compiler-dependent), # you just need to set the variable below to 1, and to diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 088bd3e59e5..8e08c79515e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1290,6 +1290,9 @@ public: thd.command=COM_DELAYED_INSERT; thd.lex->current_select= 0; // for my_message_sql thd.lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock() +#ifdef HAVE_ROW_BASED_REPLICATION + thd.set_current_stmt_binlog_row_based_if_mixed(); +#endif bzero((char*) &thd.net, sizeof(thd.net)); // Safety bzero((char*) &table_list, sizeof(table_list)); // Safety From a4768e115a09b39921017e08092ae63dc4fddb8b Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Thu, 6 Jul 2006 18:01:32 +0200 Subject: [PATCH 4/5] Fix for BUG#20349 "mysql-test-run.pl needs to add --debug to mysql_client_test like mysql-test-run". Nothing to document. --- mysql-test/mysql-test-run.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index d03f82f3866..90bc059b40b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3354,6 +3354,12 @@ sub run_mysqltest ($) { "--port=$master->[0]->{'path_myport'} " . "--socket=$master->[0]->{'path_mysock'}"; + if ( $opt_debug ) + { + $cmdline_mysql_client_test .= + " --debug=d:t:A,$opt_vardir_trace/log/mysql_client_test.trace"; + } + if ( $glob_use_embedded_server ) { $cmdline_mysql_client_test.= From 6ba4d22ca2b425f9639cab9a6716a50d1110dc8f Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Thu, 6 Jul 2006 22:03:35 +0200 Subject: [PATCH 5/5] Testcase for BUG#20633 "INSERT DELAYED RAND() or @user_var does not replicate statement-based" (bugfix was committed today): we verify that now it works in mixed mode. And a comment. --- mysql-test/r/rpl_switch_stm_row_mixed.result | 12 ++++++++++++ mysql-test/t/rpl_switch_stm_row_mixed.test | 14 ++++++++++++-- sql/sql_insert.cc | 6 ++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/rpl_switch_stm_row_mixed.result b/mysql-test/r/rpl_switch_stm_row_mixed.result index 7c6a984bed8..93fc7f450d0 100644 --- a/mysql-test/r/rpl_switch_stm_row_mixed.result +++ b/mysql-test/r/rpl_switch_stm_row_mixed.result @@ -150,6 +150,10 @@ insert delayed into t2 values("delay_3_"),(concat("delay_4_",UUID())),("delay_5_ Warnings: Warning 1265 Data truncated for column 'UUID()' at row 2 insert delayed into t2 values("delay_6_"); +create table t12 (a int, b float); +insert delayed into t12 values(1,rand()); +set @a=2.345; +insert delayed into t12 values(2,@a); select count(*) from t1; count(*) 36 @@ -165,6 +169,9 @@ count(*) select count(*) from t5; count(*) 58 +select count(*) from t12; +count(*) +2 show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest1 @@ -279,4 +286,9 @@ master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t2) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t2) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # use `mysqltest1`; create table t12 (a int, b float) +master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t12) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t12) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F drop database mysqltest1; diff --git a/mysql-test/t/rpl_switch_stm_row_mixed.test b/mysql-test/t/rpl_switch_stm_row_mixed.test index f7d942c319b..e29aea8f0b7 100644 --- a/mysql-test/t/rpl_switch_stm_row_mixed.test +++ b/mysql-test/t/rpl_switch_stm_row_mixed.test @@ -154,12 +154,21 @@ call foo2(); select foo3(); select * from t1 where a="alarm"; -# Test that INSERT DELAYED works in mixed mode +# Test that INSERT DELAYED works in mixed mode (BUG#20649) insert delayed into t2 values("delay_1_"); insert delayed into t2 values(concat("delay_2_",UUID())); insert delayed into t2 values("delay_3_"),(concat("delay_4_",UUID())),("delay_5_"); insert delayed into t2 values("delay_6_"); -sleep 4; # time for the delayed insert to reach disk + +# Test for BUG#20633 (INSERT DELAYED RAND()/user_variable does not +# replicate fine in statement-based ; we test that in mixed mode it +# works). +create table t12 (a int, b float); +insert delayed into t12 values(1,rand()); +set @a=2.345; +insert delayed into t12 values(2,@a); + +sleep 4; # time for the delayed inserts to reach disk # If you want to do manual testing of the mixed mode regarding UDFs (not # testable automatically as quite platform- and compiler-dependent), @@ -195,6 +204,7 @@ select count(*) from t2; select count(*) from t3; select count(*) from t4; select count(*) from t5; +select count(*) from t12; if ($you_want_to_test_UDF) { select count(*) from t6; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index aa81dc75867..30dbf3b7226 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1290,9 +1290,11 @@ public: thd.command=COM_DELAYED_INSERT; thd.lex->current_select= 0; // for my_message_sql thd.lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock() -#ifdef HAVE_ROW_BASED_REPLICATION + /* + Statement-based replication of INSERT DELAYED has problems with RAND() + and user vars, so in mixed mode we go to row-based. + */ thd.set_current_stmt_binlog_row_based_if_mixed(); -#endif bzero((char*) &thd.net, sizeof(thd.net)); // Safety bzero((char*) &table_list, sizeof(table_list)); // Safety