List:Commits« Previous MessageNext Message »
From:Luis Soares Date:November 23 2010 12:08am
Subject:bzr commit into mysql-next-mr branch (luis.soares:3214) WL#5597
View as plain text  
#At file:///home/lsoares/Workspace/bzr/work/features/wl5597/mysql-next-mr/ based on revid:luis.soares@stripped

 3214 Luis Soares	2010-11-23
      WL#5597
      
      Work-in-progress.
      
      Tests part I.
      
      Improvements on this cset:
      - moved rpl_row_idempotency contents to a file in extra/rpl_tests
      - made rpl_row_idempotency run twice: one time with TABLE_SCAN
        and another with HASH_SCAN by including 
        extra/rpl_tests/rpl_row_idempotency.test
      - added rpl_row_hash_scan.test with several assertions on
        HASH_SCAN algorithm (also provides coverage the new 
        code introduced).
      - fixed slave_rows_search_algorithm_basic.test that was broken
        from previous commit.
      - instrumented log_event.cc, mysqld.cc and mysqld.h with a new
        status var: slave_rows_last_search_algorithm_used so that 
        some sanity tests are written.

    added:
      mysql-test/extra/rpl_tests/rpl_row_idempotency.test
      mysql-test/suite/rpl/r/rpl_row_hash_scan.result
      mysql-test/suite/rpl/t/rpl_row_hash_scan.test
    renamed:
      mysql-test/suite/sys_vars/r/slave_rows_search_algorithm_basic.result => mysql-test/suite/sys_vars/r/slave_rows_search_algorithms_basic.result
      mysql-test/suite/sys_vars/t/slave_rows_search_algorithm_basic.test => mysql-test/suite/sys_vars/t/slave_rows_search_algorithms_basic.test
    modified:
      mysql-test/suite/rpl/r/rpl_row_idempotency.result
      mysql-test/suite/rpl/t/rpl_row_idempotency.test
      sql/log_event.cc
      sql/mysqld.cc
      sql/mysqld.h
      mysql-test/suite/sys_vars/r/slave_rows_search_algorithms_basic.result
      mysql-test/suite/sys_vars/t/slave_rows_search_algorithms_basic.test
=== added file 'mysql-test/extra/rpl_tests/rpl_row_idempotency.test'
--- a/mysql-test/extra/rpl_tests/rpl_row_idempotency.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_row_idempotency.test	2010-11-23 00:08:01 +0000
@@ -0,0 +1,313 @@
+
+# bug#31609 Not all RBR slave errors reported as errors
+# bug#31552 Replication breaks when deleting rows from out-of-sync table
+#           without PK
+
+# The default for slave-exec-mode option and server
+# variable slave_exec_mode  is 'STRICT'.
+# When 'STRICT' mode is set, the slave SQL thread will stop whenever
+# the row to change is not found. In 'IDEMPOTENT' mode, the SQL thread
+# will continue running and apply the row - replace if it's Write_rows event -
+# or skip to the next event.
+
+# the previous part of the tests was with IDEMPOTENT slave's mode.
+
+
+#
+# Other than above idempotent errors dealing with foreign keys constraint
+#
+connection slave;
+
+set @old_slave_exec_mode= @@global.slave_exec_mode;
+set @@global.slave_exec_mode= IDEMPOTENT;
+
+connection master;
+
+create table ti1 (b int primary key) engine = innodb;
+create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
+     engine = innodb;
+set foreign_key_checks=1 /* ensure the check */;
+
+insert into ti1 values (1),(2),(3);
+insert into ti2 set a=2, b=2;
+
+sync_slave_with_master;
+
+#connection slave;
+select * from ti1 order by b /* must be (1),(2),(3) */;
+insert into ti2 set a=1, b=1;
+select * from ti2 order by b /* must be (1,1) (2,2) */;
+
+connection master;
+
+# from now on checking rbr specific idempotent errors
+set @save_binlog_format= @@session.binlog_format;
+set @@session.binlog_format= row;
+delete from ti1 where b=1;
+
+select * from ti1 order by b /* must be (2),(3) */;
+
+# slave must catch up (expect some warnings in error.log)
+sync_slave_with_master;
+
+#connection slave;
+select * from ti1 order by b /* must stays as were on master (1),(2),(3) */;
+
+delete from ti1 where b=3;
+
+connection master;
+insert into ti2 set a=3, b=3;
+
+# slave must catch up (expect some warnings in error.log)
+sync_slave_with_master;
+
+#connection slave;
+select * from ti2 order by b /* must be (1,1),(2,2) - not inserted */;
+
+
+#
+# Checking the new global sys variable
+#
+
+connection slave;
+
+set global slave_exec_mode='IDEMPOTENT';
+set global slave_exec_mode='STRICT';
+
+# checking mutual exclusion for the options
+--error ER_WRONG_VALUE_FOR_VAR
+set global slave_exec_mode='IDEMPOTENT,STRICT';
+
+select @@global.slave_exec_mode /* must be STRICT */;
+
+#
+# Checking stops.
+# In the following sections strict slave sql thread is going to
+# stop when faces an idempotent error. In order to proceed
+# the mode is temporarily switched to indempotent.
+#
+
+#
+--echo *** foreign keys errors as above now forces to stop
+#
+
+connection master;
+
+set foreign_key_checks=0;
+drop table ti2, ti1;
+
+create table ti1 (b int primary key) engine = innodb;
+create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
+     engine = innodb;
+set foreign_key_checks=1 /* ensure the check */;
+
+insert into ti1 values (1),(2),(3);
+insert into ti2 set a=2, b=2;
+
+sync_slave_with_master;
+
+#connection slave;
+select * from ti1 order by b /* must be (1),(2),(3) */;
+--echo *** conspire future problem
+insert into ti2 set a=1, b=1;
+select * from ti2 order by b /* must be (1,1) (2,2) */;
+
+connection master;
+
+delete from ti1 where b=1 /* offending delete event */;
+select * from ti1 order by b /* must be (2),(3) */;
+
+# foreign key: row is referenced
+
+--echo *** slave must stop (Trying to delete a referenced foreing key)
+connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
+disable_query_log;
+eval SELECT "$last_error" AS Last_SQL_Error;
+enable_query_log;
+
+select * from ti1 order by b /* must be (1),(2),(3) - not deleted */;
+set foreign_key_checks= 0;
+delete from ti2 where b=1;
+set foreign_key_checks= 1;
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+connection master;
+sync_slave_with_master;
+#connection slave;
+set global slave_exec_mode='STRICT';
+
+connection master;
+
+sync_slave_with_master;
+
+#connection slave;
+--echo *** conspire the following insert failure
+# foreign key: no referenced row
+
+--echo *** conspire future problem
+delete from ti1 where b=3;
+
+connection master;
+insert into ti2 set a=3, b=3 /* offending write event */;
+
+--echo *** slave must stop (Trying to insert an invalid foreign key)
+connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
+disable_query_log;
+eval SELECT "$last_error" AS Last_SQL_Error;
+enable_query_log;
+
+select * from ti2 order by b /* must be (2,2) */;
+set foreign_key_checks= 0;
+insert into ti1 set b=3;
+set foreign_key_checks= 1;
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+connection master;
+sync_slave_with_master;
+#connection slave;
+set global slave_exec_mode='STRICT';
+
+connection master;
+
+sync_slave_with_master;
+
+select * from ti2 order by b /* must be (2,2),(3,3) */;
+
+# 
+--echo *** other errors
+# 
+
+# dup key insert
+
+#connection slave;
+--echo *** conspiring query
+insert into ti1 set b=1;
+
+connection master;
+insert into ti1 set b=1 /* offending write event */;
+
+--echo *** slave must stop (Trying to insert a dupliacte key)
+connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
+disable_query_log;
+eval SELECT "$last_error" AS Last_SQL_Error;
+enable_query_log;
+
+set foreign_key_checks= 0;
+delete from ti1 where b=1;
+set foreign_key_checks= 1;
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+connection master;
+sync_slave_with_master;
+#connection slave;
+set global slave_exec_mode='STRICT';
+
+# key not found
+
+connection master;
+
+CREATE TABLE t1 (a INT PRIMARY KEY);
+CREATE TABLE t2 (a INT);
+INSERT INTO t1 VALUES (-1),(-2),(-3);
+INSERT INTO t2 VALUES (-1),(-2),(-3);
+sync_slave_with_master;
+
+#connection slave;
+DELETE FROM t1 WHERE a = -2;
+DELETE FROM t2 WHERE a = -2;
+connection master;
+DELETE FROM t1 WHERE a = -2;
+
+--echo *** slave must stop (Key was not found)
+connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
+disable_query_log;
+eval SELECT "$last_error" AS Last_SQL_Error;
+enable_query_log;
+
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+connection master;
+sync_slave_with_master;
+#connection slave;
+set global slave_exec_mode='STRICT';
+
+connection master;
+DELETE FROM t2 WHERE a = -2; 
+--echo *** slave must stop (Key was not found)
+connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
+disable_query_log;
+eval SELECT "$last_error" AS Last_SQL_Error;
+enable_query_log;
+
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+connection master;
+sync_slave_with_master;
+#connection slave;
+set global slave_exec_mode='STRICT';
+
+UPDATE t1 SET a = 1 WHERE a = -1;
+UPDATE t2 SET a = 1 WHERE a = -1;
+
+connection master;
+UPDATE t1 SET a = 1 WHERE a = -1;
+
+--echo *** slave must stop (Key was not found)
+connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
+disable_query_log;
+eval SELECT "$last_error" AS Last_SQL_Error;
+enable_query_log;
+
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+connection master;
+sync_slave_with_master;
+#connection slave;
+set global slave_exec_mode='STRICT';
+
+
+connection master;
+UPDATE t2 SET a = 1 WHERE a = -1;
+
+--echo *** slave must stop (Key was not found)
+connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
+disable_query_log;
+eval SELECT "$last_error" AS Last_SQL_Error;
+enable_query_log;
+
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+connection master;
+sync_slave_with_master;
+#connection slave;
+SET @@global.slave_exec_mode= @old_slave_exec_mode;
+
+# cleanup for bug#31609 tests
+
+connection master;
+
+drop table t1,t2,ti2,ti1;
+sync_slave_with_master;
+set @@global.slave_exec_mode= @old_slave_exec_mode;
+

=== added file 'mysql-test/suite/rpl/r/rpl_row_hash_scan.result'
--- a/mysql-test/suite/rpl/r/rpl_row_hash_scan.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_hash_scan.result	2010-11-23 00:08:01 +0000
@@ -0,0 +1,105 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+call mtr.add_suppression(" Slave: Can't find record in 't1' Error_code: 1032");
+SET @saved_slave_rows_search_algorithms= @@global.slave_rows_search_algorithms;
+SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,HASH_SCAN';
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (1), (2), (3);
+DELETE FROM t1;
+INSERT INTO t1 VALUES (2), (1), (3), (1);
+UPDATE t1 SET a=1000 WHERE a=1;
+Comparing tables master:test.t1 and master:test.t1
+DELETE FROM t1 WHERE a=1000;
+DELETE FROM t1 WHERE a=2 OR a=3;
+Comparing tables master:test.t1 and slave:test.t1
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+SET SQL_LOG_BIN=0;
+CREATE TABLE t1 (a INT, b INT);
+SET SQL_LOG_BIN=1;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2);
+UPDATE t1 SET a=1000 WHERE a=1;
+SELECT * FROM t1;
+a	b
+1000	1
+1000	2
+2	1
+2	2
+SELECT * FROM t1;
+a
+1000
+1000
+2
+2
+DELETE FROM t1 WHERE a=1000;
+DELETE FROM t1 WHERE a=2;
+SELECT * FROM t1;
+a	b
+SELECT * FROM t1;
+a
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (1), (2), (3);
+DELETE FROM t1 WHERE a=1;
+DELETE FROM t1 WHERE a=2;
+UPDATE t1 SET a=1000 WHERE a=1;
+--source include/wait_for_slave_sql_error_and_skip.inc
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+include/start_slave.inc
+DELETE FROM t1 WHERE a=2;
+--source include/wait_for_slave_sql_error_and_skip.inc
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+include/start_slave.inc
+DROP TABLE t1;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE TABLE t1 (a INT, b TINYBLOB);
+INSERT INTO t1 VALUES (1,'a'), (1, 'b'), (2,'aa'), (2, 'aa');
+UPDATE t1 SET b='c' WHERE a=1;
+Comparing tables master:test.t1 and slave:test.t1
+UPDATE t1 SET a=10000 WHERE b='aa';
+Comparing tables master:test.t1 and slave:test.t1
+UPDATE t1 SET b='c' WHERE b='aa';
+Comparing tables master:test.t1 and slave:test.t1
+DELETE FROM t1 WHERE b='c';
+Comparing tables master:test.t1 and slave:test.t1
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE TABLE t1 (a TINYBLOB, b TINYBLOB);
+INSERT INTO t1 VALUES ('a','a'), ('b', 'b'), ('a','aa'), ('a', 'aa');
+UPDATE t1 SET b='c' WHERE b='aa';
+Comparing tables master:test.t1 and slave:test.t1
+DELETE FROM t1;
+Comparing tables master:test.t1 and slave:test.t1
+INSERT INTO t1 VALUES (NULL,NULL), (NULL, NULL);
+DELETE FROM t1;
+Comparing tables master:test.t1 and slave:test.t1
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+SET @@global.slave_rows_search_algorithms= @saved_slave_rows_search_algorithms;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_idempotency.result'
--- a/mysql-test/suite/rpl/r/rpl_row_idempotency.result	2010-01-12 17:52:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_idempotency.result	2010-11-23 00:08:01 +0000
@@ -7,6 +7,8 @@ start slave;
 call mtr.add_suppression("Slave: Can't find record in 't.' Error_code: 1032");
 call mtr.add_suppression("Slave: Cannot delete or update a parent row: a foreign key constraint fails .* Error_code: 1451");
 call mtr.add_suppression("Slave: Cannot add or update a child row: a foreign key constraint fails .* Error_code: 1452");
+set @saved_slave_rows_search_algorithms= @@global.slave_rows_search_algorithms;
+SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,TABLE_SCAN';
 set @old_slave_exec_mode= @@global.slave_exec_mode;
 set @@global.slave_exec_mode= IDEMPOTENT;
 create table ti1 (b int primary key) engine = innodb;
@@ -160,4 +162,165 @@ start slave sql_thread;
 SET @@global.slave_exec_mode= @old_slave_exec_mode;
 drop table t1,t2,ti2,ti1;
 set @@global.slave_exec_mode= @old_slave_exec_mode;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,HASH_SCAN';
+set @old_slave_exec_mode= @@global.slave_exec_mode;
+set @@global.slave_exec_mode= IDEMPOTENT;
+create table ti1 (b int primary key) engine = innodb;
+create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
+engine = innodb;
+set foreign_key_checks=1 /* ensure the check */;
+insert into ti1 values (1),(2),(3);
+insert into ti2 set a=2, b=2;
+select * from ti1 order by b /* must be (1),(2),(3) */;
+b
+1
+2
+3
+insert into ti2 set a=1, b=1;
+select * from ti2 order by b /* must be (1,1) (2,2) */;
+a	b
+1	1
+2	2
+set @save_binlog_format= @@session.binlog_format;
+set @@session.binlog_format= row;
+delete from ti1 where b=1;
+select * from ti1 order by b /* must be (2),(3) */;
+b
+2
+3
+select * from ti1 order by b /* must stays as were on master (1),(2),(3) */;
+b
+1
+2
+3
+delete from ti1 where b=3;
+insert into ti2 set a=3, b=3;
+select * from ti2 order by b /* must be (1,1),(2,2) - not inserted */;
+a	b
+1	1
+2	2
+set global slave_exec_mode='IDEMPOTENT';
+set global slave_exec_mode='STRICT';
+set global slave_exec_mode='IDEMPOTENT,STRICT';
+ERROR 42000: Variable 'slave_exec_mode' can't be set to the value of 'IDEMPOTENT,STRICT'
+select @@global.slave_exec_mode /* must be STRICT */;
+@@global.slave_exec_mode
+STRICT
+*** foreign keys errors as above now forces to stop
+set foreign_key_checks=0;
+drop table ti2, ti1;
+create table ti1 (b int primary key) engine = innodb;
+create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
+engine = innodb;
+set foreign_key_checks=1 /* ensure the check */;
+insert into ti1 values (1),(2),(3);
+insert into ti2 set a=2, b=2;
+select * from ti1 order by b /* must be (1),(2),(3) */;
+b
+1
+2
+3
+*** conspire future problem
+insert into ti2 set a=1, b=1;
+select * from ti2 order by b /* must be (1,1) (2,2) */;
+a	b
+1	1
+2	2
+delete from ti1 where b=1 /* offending delete event */;
+select * from ti1 order by b /* must be (2),(3) */;
+b
+2
+3
+*** slave must stop (Trying to delete a referenced foreing key)
+Last_SQL_Error
+1451
+select * from ti1 order by b /* must be (1),(2),(3) - not deleted */;
+b
+1
+2
+3
+set foreign_key_checks= 0;
+delete from ti2 where b=1;
+set foreign_key_checks= 1;
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+set global slave_exec_mode='STRICT';
+*** conspire the following insert failure
+*** conspire future problem
+delete from ti1 where b=3;
+insert into ti2 set a=3, b=3 /* offending write event */;
+*** slave must stop (Trying to insert an invalid foreign key)
+Last_SQL_Error
+1452
+select * from ti2 order by b /* must be (2,2) */;
+a	b
+2	2
+set foreign_key_checks= 0;
+insert into ti1 set b=3;
+set foreign_key_checks= 1;
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+set global slave_exec_mode='STRICT';
+select * from ti2 order by b /* must be (2,2),(3,3) */;
+a	b
+2	2
+3	3
+*** other errors
+*** conspiring query
+insert into ti1 set b=1;
+insert into ti1 set b=1 /* offending write event */;
+*** slave must stop (Trying to insert a dupliacte key)
+Last_SQL_Error
+1062
+set foreign_key_checks= 0;
+delete from ti1 where b=1;
+set foreign_key_checks= 1;
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+set global slave_exec_mode='STRICT';
+CREATE TABLE t1 (a INT PRIMARY KEY);
+CREATE TABLE t2 (a INT);
+INSERT INTO t1 VALUES (-1),(-2),(-3);
+INSERT INTO t2 VALUES (-1),(-2),(-3);
+DELETE FROM t1 WHERE a = -2;
+DELETE FROM t2 WHERE a = -2;
+DELETE FROM t1 WHERE a = -2;
+*** slave must stop (Key was not found)
+Last_SQL_Error
+1032
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+set global slave_exec_mode='STRICT';
+DELETE FROM t2 WHERE a = -2;
+*** slave must stop (Key was not found)
+Last_SQL_Error
+1032
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+set global slave_exec_mode='STRICT';
+UPDATE t1 SET a = 1 WHERE a = -1;
+UPDATE t2 SET a = 1 WHERE a = -1;
+UPDATE t1 SET a = 1 WHERE a = -1;
+*** slave must stop (Key was not found)
+Last_SQL_Error
+1032
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+set global slave_exec_mode='STRICT';
+UPDATE t2 SET a = 1 WHERE a = -1;
+*** slave must stop (Key was not found)
+Last_SQL_Error
+1032
+set global slave_exec_mode='IDEMPOTENT';
+start slave sql_thread;
+SET @@global.slave_exec_mode= @old_slave_exec_mode;
+drop table t1,t2,ti2,ti1;
+set @@global.slave_exec_mode= @old_slave_exec_mode;
+set @@global.slave_rows_search_algorithms= @saved_slave_rows_search_algorithms;
 *** end of tests

=== added file 'mysql-test/suite/rpl/t/rpl_row_hash_scan.test'
--- a/mysql-test/suite/rpl/t/rpl_row_hash_scan.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_hash_scan.test	2010-11-23 00:08:01 +0000
@@ -0,0 +1,218 @@
+-- source include/master-slave.inc
+-- source include/have_binlog_format_row.inc
+
+#
+# Test cases for WL#5597
+#
+# In this file, we only test for the following cases:
+
+#
+# CASE #1: update/delete multiple records from a table that share the
+#          same hashtable key (in slave HASH_SCAN algorithm).
+
+#
+# CASE #2: same as CASE #1, but the reason is that the master has more
+#          columns than the slave, thence duplicate keys in slave's
+#          hashtable are a side effect, but should not be a problem.
+
+#
+# CASE #3: the slave stops gracefully when it is updating a row that
+#          does not exist on its table.
+
+#
+# CASE #4: update/delete multiple records with blobs. Given that blobs
+#          are not included in hashing, some records keys will collide.
+
+#
+# CASE #5: update/delete tables with only blob columns.
+# 
+
+-- connection slave
+call mtr.add_suppression(" Slave: Can't find record in 't1' Error_code: 1032");
+
+SET @saved_slave_rows_search_algorithms= @@global.slave_rows_search_algorithms;
+SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,HASH_SCAN';
+
+#
+# CASE #1: entries that generating the same key for the slave internal
+#          hash table.
+#
+# ASSERTS that no updates are lost due to having multiple entries for
+#         the same hashtable key in the slave HASH_SCAN.
+#
+
+-- connection master
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (1), (2), (3);
+-- sync_slave_with_master
+DELETE FROM t1;
+
+# try to change the order of the rows in the engine.
+INSERT INTO t1 VALUES (2), (1), (3), (1);
+
+-- connection master
+UPDATE t1 SET a=1000 WHERE a=1;
+-- sync_slave_with_master
+
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=master:test.t1
+-- source include/diff_tables.inc
+
+-- connection master
+DELETE FROM t1 WHERE a=1000;
+DELETE FROM t1 WHERE a=2 OR a=3;
+-- sync_slave_with_master
+
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=slave:test.t1
+-- source include/diff_tables.inc
+
+-- source include/master-slave-reset.inc
+
+# CASE #2: entries generating the same key for the slave internal
+#          hashtable because master table has more columns than the
+#          slave's.
+#
+# ASSERTS that no updates are lost due to having multiple entries for
+#         the same hashtable key in the slave HASH_SCAN when master
+#         has more tables than the slave.
+
+-- connection master
+
+SET SQL_LOG_BIN=0;
+CREATE TABLE t1 (a INT, b INT);
+SET SQL_LOG_BIN=1;
+-- connection slave
+CREATE TABLE t1 (a INT);
+-- connection master
+INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2);
+UPDATE t1 SET a=1000 WHERE a=1;
+
+SELECT * FROM t1;
+-- sync_slave_with_master
+SELECT * FROM t1;
+
+-- connection master
+DELETE FROM t1 WHERE a=1000;
+DELETE FROM t1 WHERE a=2;
+SELECT * FROM t1;
+-- sync_slave_with_master
+SELECT * FROM t1;
+
+-- source include/master-slave-reset.inc
+
+#
+# CASE #3: The master updates and deletes some row that the slave does
+#          not have.
+#
+# ASSERTS that the slave shall fail gracefully when the row is not found.
+#
+
+-- connection master
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (1), (2), (3);
+-- sync_slave_with_master
+DELETE FROM t1 WHERE a=1;
+DELETE FROM t1 WHERE a=2;
+
+-- connection master
+UPDATE t1 SET a=1000 WHERE a=1;
+
+-- let $slave_sql_errno= 1032
+-- source include/wait_for_slave_sql_error_and_skip.inc
+
+-- connection master
+DELETE FROM t1 WHERE a=2;
+-- let $slave_sql_errno= 1032
+-- source include/wait_for_slave_sql_error_and_skip.inc
+DROP TABLE t1;
+-- sync_slave_with_master
+
+-- source include/master-slave-reset.inc
+
+#
+# CASE #4: covers the case of tables that have blobs in them.
+#
+# ASSERTS that there are no lost updates
+
+-- connection master
+
+CREATE TABLE t1 (a INT, b TINYBLOB);
+INSERT INTO t1 VALUES (1,'a'), (1, 'b'), (2,'aa'), (2, 'aa');
+
+UPDATE t1 SET b='c' WHERE a=1;
+-- sync_slave_with_master
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=slave:test.t1
+-- source include/diff_tables.inc
+
+-- connection master
+
+UPDATE t1 SET a=10000 WHERE b='aa';
+-- sync_slave_with_master
+
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=slave:test.t1
+-- source include/diff_tables.inc
+
+-- connection master
+
+UPDATE t1 SET b='c' WHERE b='aa';
+-- sync_slave_with_master
+
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=slave:test.t1
+-- source include/diff_tables.inc
+
+-- connection master
+
+DELETE FROM t1 WHERE b='c';
+-- sync_slave_with_master
+
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=slave:test.t1
+-- source include/diff_tables.inc
+
+-- source include/master-slave-reset.inc
+
+#
+# CASE #5: covers the case on which the table has only blobs in it.
+#
+# ASSERTS that there are no issues even if blobs are skipped from the
+#         hashing. Tables on master and slave will not go out-of-sync.
+#
+
+-- connection master
+
+CREATE TABLE t1 (a TINYBLOB, b TINYBLOB);
+INSERT INTO t1 VALUES ('a','a'), ('b', 'b'), ('a','aa'), ('a', 'aa');
+
+UPDATE t1 SET b='c' WHERE b='aa';
+-- sync_slave_with_master
+
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=slave:test.t1
+-- source include/diff_tables.inc
+
+-- connection master
+
+DELETE FROM t1;
+-- sync_slave_with_master
+
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=slave:test.t1
+-- source include/diff_tables.inc
+
+-- connection master
+INSERT INTO t1 VALUES (NULL,NULL), (NULL, NULL);
+DELETE FROM t1;
+
+-- sync_slave_with_master
+-- let $diff_table_1=master:test.t1
+-- let $diff_table_2=slave:test.t1
+-- source include/diff_tables.inc
+
+-- source include/master-slave-reset.inc
+
+SET @@global.slave_rows_search_algorithms= @saved_slave_rows_search_algorithms;
\ No newline at end of file

=== modified file 'mysql-test/suite/rpl/t/rpl_row_idempotency.test'
--- a/mysql-test/suite/rpl/t/rpl_row_idempotency.test	2010-01-12 17:52:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_idempotency.test	2010-11-23 00:08:01 +0000
@@ -13,319 +13,17 @@ call mtr.add_suppression("Slave: Can't f
 call mtr.add_suppression("Slave: Cannot delete or update a parent row: a foreign key constraint fails .* Error_code: 1451");
 call mtr.add_suppression("Slave: Cannot add or update a child row: a foreign key constraint fails .* Error_code: 1452");
 
+set @saved_slave_rows_search_algorithms= @@global.slave_rows_search_algorithms;
 
-# bug#31609 Not all RBR slave errors reported as errors
-# bug#31552 Replication breaks when deleting rows from out-of-sync table
-#           without PK
+SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,TABLE_SCAN';
+-- source extra/rpl_tests/rpl_row_idempotency.test
 
-# The default for slave-exec-mode option and server
-# variable slave_exec_mode  is 'STRICT'.
-# When 'STRICT' mode is set, the slave SQL thread will stop whenever
-# the row to change is not found. In 'IDEMPOTENT' mode, the SQL thread
-# will continue running and apply the row - replace if it's Write_rows event -
-# or skip to the next event.
+-- source include/master-slave-reset.inc
 
-# the previous part of the tests was with IDEMPOTENT slave's mode.
-
-
-#
-# Other than above idempotent errors dealing with foreign keys constraint
-#
-connection slave;
-
-set @old_slave_exec_mode= @@global.slave_exec_mode;
-set @@global.slave_exec_mode= IDEMPOTENT;
-
-connection master;
-
-create table ti1 (b int primary key) engine = innodb;
-create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
-     engine = innodb;
-set foreign_key_checks=1 /* ensure the check */;
-
-insert into ti1 values (1),(2),(3);
-insert into ti2 set a=2, b=2;
-
-sync_slave_with_master;
-
-#connection slave;
-select * from ti1 order by b /* must be (1),(2),(3) */;
-insert into ti2 set a=1, b=1;
-select * from ti2 order by b /* must be (1,1) (2,2) */;
-
-connection master;
-
-# from now on checking rbr specific idempotent errors
-set @save_binlog_format= @@session.binlog_format;
-set @@session.binlog_format= row;
-delete from ti1 where b=1;
-
-select * from ti1 order by b /* must be (2),(3) */;
-
-# slave must catch up (expect some warnings in error.log)
-sync_slave_with_master;
-
-#connection slave;
-select * from ti1 order by b /* must stays as were on master (1),(2),(3) */;
-
-delete from ti1 where b=3;
-
-connection master;
-insert into ti2 set a=3, b=3;
-
-# slave must catch up (expect some warnings in error.log)
-sync_slave_with_master;
-
-#connection slave;
-select * from ti2 order by b /* must be (1,1),(2,2) - not inserted */;
-
-
-#
-# Checking the new global sys variable
-#
-
-connection slave;
-
-set global slave_exec_mode='IDEMPOTENT';
-set global slave_exec_mode='STRICT';
-
-# checking mutual exclusion for the options
---error ER_WRONG_VALUE_FOR_VAR
-set global slave_exec_mode='IDEMPOTENT,STRICT';
-
-select @@global.slave_exec_mode /* must be STRICT */;
-
-#
-# Checking stops.
-# In the following sections strict slave sql thread is going to
-# stop when faces an idempotent error. In order to proceed
-# the mode is temporarily switched to indempotent.
-#
-
-#
---echo *** foreign keys errors as above now forces to stop
-#
-
-connection master;
-
-set foreign_key_checks=0;
-drop table ti2, ti1;
-
-create table ti1 (b int primary key) engine = innodb;
-create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
-     engine = innodb;
-set foreign_key_checks=1 /* ensure the check */;
-
-insert into ti1 values (1),(2),(3);
-insert into ti2 set a=2, b=2;
-
-sync_slave_with_master;
-
-#connection slave;
-select * from ti1 order by b /* must be (1),(2),(3) */;
---echo *** conspire future problem
-insert into ti2 set a=1, b=1;
-select * from ti2 order by b /* must be (1,1) (2,2) */;
-
-connection master;
-
-delete from ti1 where b=1 /* offending delete event */;
-select * from ti1 order by b /* must be (2),(3) */;
-
-# foreign key: row is referenced
-
---echo *** slave must stop (Trying to delete a referenced foreing key)
-connection slave;
-source include/wait_for_slave_sql_to_stop.inc;
-
-let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
-disable_query_log;
-eval SELECT "$last_error" AS Last_SQL_Error;
-enable_query_log;
-
-select * from ti1 order by b /* must be (1),(2),(3) - not deleted */;
-set foreign_key_checks= 0;
-delete from ti2 where b=1;
-set foreign_key_checks= 1;
-set global slave_exec_mode='IDEMPOTENT';
-start slave sql_thread;
-connection master;
-sync_slave_with_master;
-#connection slave;
-set global slave_exec_mode='STRICT';
-
-connection master;
-
-sync_slave_with_master;
-
-#connection slave;
---echo *** conspire the following insert failure
-# foreign key: no referenced row
-
---echo *** conspire future problem
-delete from ti1 where b=3;
-
-connection master;
-insert into ti2 set a=3, b=3 /* offending write event */;
-
---echo *** slave must stop (Trying to insert an invalid foreign key)
-connection slave;
-source include/wait_for_slave_sql_to_stop.inc;
-
-let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
-disable_query_log;
-eval SELECT "$last_error" AS Last_SQL_Error;
-enable_query_log;
-
-select * from ti2 order by b /* must be (2,2) */;
-set foreign_key_checks= 0;
-insert into ti1 set b=3;
-set foreign_key_checks= 1;
-set global slave_exec_mode='IDEMPOTENT';
-start slave sql_thread;
-connection master;
-sync_slave_with_master;
-#connection slave;
-set global slave_exec_mode='STRICT';
-
-connection master;
-
-sync_slave_with_master;
-
-select * from ti2 order by b /* must be (2,2),(3,3) */;
-
-# 
---echo *** other errors
-# 
-
-# dup key insert
-
-#connection slave;
---echo *** conspiring query
-insert into ti1 set b=1;
-
-connection master;
-insert into ti1 set b=1 /* offending write event */;
-
---echo *** slave must stop (Trying to insert a dupliacte key)
-connection slave;
-source include/wait_for_slave_sql_to_stop.inc;
-
-let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
-disable_query_log;
-eval SELECT "$last_error" AS Last_SQL_Error;
-enable_query_log;
-
-set foreign_key_checks= 0;
-delete from ti1 where b=1;
-set foreign_key_checks= 1;
-set global slave_exec_mode='IDEMPOTENT';
-start slave sql_thread;
-connection master;
-sync_slave_with_master;
-#connection slave;
-set global slave_exec_mode='STRICT';
-
-# key not found
-
-connection master;
-
-CREATE TABLE t1 (a INT PRIMARY KEY);
-CREATE TABLE t2 (a INT);
-INSERT INTO t1 VALUES (-1),(-2),(-3);
-INSERT INTO t2 VALUES (-1),(-2),(-3);
-sync_slave_with_master;
-
-#connection slave;
-DELETE FROM t1 WHERE a = -2;
-DELETE FROM t2 WHERE a = -2;
-connection master;
-DELETE FROM t1 WHERE a = -2;
-
---echo *** slave must stop (Key was not found)
-connection slave;
-source include/wait_for_slave_sql_to_stop.inc;
-
-let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
-disable_query_log;
-eval SELECT "$last_error" AS Last_SQL_Error;
-enable_query_log;
-
-set global slave_exec_mode='IDEMPOTENT';
-start slave sql_thread;
-connection master;
-sync_slave_with_master;
-#connection slave;
-set global slave_exec_mode='STRICT';
-
-connection master;
-DELETE FROM t2 WHERE a = -2; 
---echo *** slave must stop (Key was not found)
-connection slave;
-source include/wait_for_slave_sql_to_stop.inc;
-
-let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
-disable_query_log;
-eval SELECT "$last_error" AS Last_SQL_Error;
-enable_query_log;
-
-set global slave_exec_mode='IDEMPOTENT';
-start slave sql_thread;
-connection master;
-sync_slave_with_master;
-#connection slave;
-set global slave_exec_mode='STRICT';
-
-UPDATE t1 SET a = 1 WHERE a = -1;
-UPDATE t2 SET a = 1 WHERE a = -1;
-
-connection master;
-UPDATE t1 SET a = 1 WHERE a = -1;
-
---echo *** slave must stop (Key was not found)
-connection slave;
-source include/wait_for_slave_sql_to_stop.inc;
-
-let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
-disable_query_log;
-eval SELECT "$last_error" AS Last_SQL_Error;
-enable_query_log;
-
-set global slave_exec_mode='IDEMPOTENT';
-start slave sql_thread;
-connection master;
-sync_slave_with_master;
-#connection slave;
-set global slave_exec_mode='STRICT';
-
-
-connection master;
-UPDATE t2 SET a = 1 WHERE a = -1;
-
---echo *** slave must stop (Key was not found)
-connection slave;
-source include/wait_for_slave_sql_to_stop.inc;
-
-let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1);
-disable_query_log;
-eval SELECT "$last_error" AS Last_SQL_Error;
-enable_query_log;
-
-set global slave_exec_mode='IDEMPOTENT';
-start slave sql_thread;
-connection master;
-sync_slave_with_master;
-#connection slave;
-SET @@global.slave_exec_mode= @old_slave_exec_mode;
-
-# cleanup for bug#31609 tests
-
-connection master;
-
-drop table t1,t2,ti2,ti1;
-sync_slave_with_master;
-set @@global.slave_exec_mode= @old_slave_exec_mode;
+SET GLOBAL slave_rows_search_algorithms= 'INDEX_SCAN,HASH_SCAN';
+-- source extra/rpl_tests/rpl_row_idempotency.test
 
+set @@global.slave_rows_search_algorithms= @saved_slave_rows_search_algorithms;
 --source include/master-slave-end.inc
 
 --echo *** end of tests

=== renamed file 'mysql-test/suite/sys_vars/r/slave_rows_search_algorithm_basic.result' => 'mysql-test/suite/sys_vars/r/slave_rows_search_algorithms_basic.result'
--- a/mysql-test/suite/sys_vars/r/slave_rows_search_algorithm_basic.result	2010-11-22 21:10:41 +0000
+++ b/mysql-test/suite/sys_vars/r/slave_rows_search_algorithms_basic.result	2010-11-23 00:08:01 +0000
@@ -1,51 +1,51 @@
-set @saved_slave_rows_search_algorithm = @@global.slave_rows_search_algorithm;
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+set @saved_slave_rows_search_algorithms = @@global.slave_rows_search_algorithms;
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 TABLE_SCAN,INDEX_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 TABLE_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='HASH_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='HASH_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 HASH_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='INDEX_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='INDEX_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 INDEX_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_SCAN,HASH_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_SCAN,HASH_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 TABLE_SCAN,HASH_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_SCAN,HASH_SCAN,INDEX_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_SCAN,HASH_SCAN,INDEX_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 TABLE_SCAN,INDEX_SCAN,HASH_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_SCAN,INDEX_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_SCAN,INDEX_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 TABLE_SCAN,INDEX_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='HASH_SCAN,INDEX_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='HASH_SCAN,INDEX_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 INDEX_SCAN,HASH_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_5CAN';
-ERROR 42000: Variable 'slave_rows_search_algorithm' can't be set to the value of 'TABLE_5CAN'
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_5CAN';
+ERROR 42000: Variable 'slave_rows_search_algorithms' can't be set to the value of 'TABLE_5CAN'
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 INDEX_SCAN,HASH_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='';
-ERROR 42000: Variable 'slave_rows_search_algorithm' can't be set to the value of ''
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='';
+ERROR 42000: Variable 'slave_rows_search_algorithms' can't be set to the value of ''
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 INDEX_SCAN,HASH_SCAN
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='1';
-ERROR 42000: Variable 'slave_rows_search_algorithm' can't be set to the value of '1'
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='1';
+ERROR 42000: Variable 'slave_rows_search_algorithms' can't be set to the value of '1'
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 INDEX_SCAN,HASH_SCAN
-set global slave_rows_search_algorithm = @saved_slave_rows_search_algorithm;
-SELECT @@global.slave_rows_search_algorithm;
-@@global.slave_rows_search_algorithm
+set global slave_rows_search_algorithms = @saved_slave_rows_search_algorithms;
+SELECT @@global.slave_rows_search_algorithms;
+@@global.slave_rows_search_algorithms
 TABLE_SCAN,INDEX_SCAN

=== renamed file 'mysql-test/suite/sys_vars/t/slave_rows_search_algorithm_basic.test' => 'mysql-test/suite/sys_vars/t/slave_rows_search_algorithms_basic.test'
--- a/mysql-test/suite/sys_vars/t/slave_rows_search_algorithm_basic.test	2010-11-22 21:10:41 +0000
+++ b/mysql-test/suite/sys_vars/t/slave_rows_search_algorithms_basic.test	2010-11-23 00:08:01 +0000
@@ -1,44 +1,44 @@
 --source include/not_embedded.inc
 
-set @saved_slave_rows_search_algorithm = @@global.slave_rows_search_algorithm;
+set @saved_slave_rows_search_algorithms = @@global.slave_rows_search_algorithms;
 
 
-SELECT @@global.slave_rows_search_algorithm;
+SELECT @@global.slave_rows_search_algorithms;
 
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
 
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='HASH_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='HASH_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
 
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='INDEX_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='INDEX_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
 
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_SCAN,HASH_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_SCAN,HASH_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
 
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_SCAN,HASH_SCAN,INDEX_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_SCAN,HASH_SCAN,INDEX_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
 
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_SCAN,INDEX_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_SCAN,INDEX_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
 
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='HASH_SCAN,INDEX_SCAN';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='HASH_SCAN,INDEX_SCAN';
+SELECT @@global.slave_rows_search_algorithms;
 
 
 # checking that setting variable to a non existing value raises error
 --error ER_WRONG_VALUE_FOR_VAR
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='TABLE_5CAN';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='TABLE_5CAN';
+SELECT @@global.slave_rows_search_algorithms;
 
 --error ER_WRONG_VALUE_FOR_VAR
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='';
+SELECT @@global.slave_rows_search_algorithms;
 
 --error ER_WRONG_VALUE_FOR_VAR
-SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHM='1';
-SELECT @@global.slave_rows_search_algorithm;
+SET GLOBAL SLAVE_ROWS_SEARCH_ALGORITHMS='1';
+SELECT @@global.slave_rows_search_algorithms;
 
-set global slave_rows_search_algorithm = @saved_slave_rows_search_algorithm;
-SELECT @@global.slave_rows_search_algorithm;
+set global slave_rows_search_algorithms = @saved_slave_rows_search_algorithms;
+SELECT @@global.slave_rows_search_algorithms;

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-11-22 21:36:08 +0000
+++ b/sql/log_event.cc	2010-11-23 00:08:01 +0000
@@ -7797,6 +7797,9 @@ static uint decide_row_lookup_algorithm(
   const char* s= ((res == Rows_log_event::ROW_LOOKUP_TABLE_SCAN) ? "TABLE_SCAN" :
                   ((res == Rows_log_event::ROW_LOOKUP_HASH_SCAN) ? "HASH_SCAN" : 
                    "INDEX_SCAN"));
+
+  // only for testing purposes
+  slave_rows_last_search_algorithm_used= res;
   DBUG_PRINT("debug", ("Row lookup method: %s", s));
 #endif
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-11-22 21:10:41 +0000
+++ b/sql/mysqld.cc	2010-11-23 00:08:01 +0000
@@ -461,6 +461,9 @@ uint  slave_net_timeout;
 ulong slave_exec_mode_options;
 ulonglong slave_type_conversions_options;
 ulonglong slave_rows_search_algorithms_options;
+#ifndef DBUG_OFF
+uint slave_rows_last_search_algorithm_used;
+#endif
 ulong thread_cache_size=0;
 ulong binlog_cache_size=0;
 ulonglong  max_binlog_cache_size=0;
@@ -6277,6 +6280,21 @@ static int show_heartbeat_period(THD *th
   return 0;
 }
 
+#ifndef DBUG_OFF
+static int show_slave_rows_last_search_algorithm_used(THD *thd, SHOW_VAR *var, char *buff)
+{
+  uint res= slave_rows_last_search_algorithm_used;
+  const char* s= ((res == Rows_log_event::ROW_LOOKUP_TABLE_SCAN) ? "TABLE_SCAN" :
+                  ((res == Rows_log_event::ROW_LOOKUP_HASH_SCAN) ? "HASH_SCAN" : 
+                   "INDEX_SCAN"));
+
+  var->type= SHOW_CHAR;
+  var->value= buff;
+  sprintf(buff, "%s", s);
+
+  return 0;
+}
+#endif
 
 #endif /* HAVE_REPLICATION */
 
@@ -6643,6 +6661,9 @@ SHOW_VAR status_vars[]= {
   {"Slave_retried_transactions",(char*) &show_slave_retried_trans, SHOW_FUNC},
   {"Slave_heartbeat_period",   (char*) &show_heartbeat_period, SHOW_FUNC},
   {"Slave_received_heartbeats",(char*) &show_slave_received_heartbeats, SHOW_FUNC},
+#ifndef DBUG_OFF
+  {"Slave_rows_last_search_algorithm_used",(char*) &show_slave_rows_last_search_algorithm_used, SHOW_FUNC},
+#endif
   {"Slave_running",            (char*) &show_slave_running,     SHOW_FUNC},
 #endif
   {"Slow_launch_threads",      (char*) &slow_launch_threads,    SHOW_LONG},

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2010-11-22 21:10:41 +0000
+++ b/sql/mysqld.h	2010-11-23 00:08:01 +0000
@@ -108,6 +108,9 @@ extern my_bool opt_slave_compressed_prot
 extern ulong slave_exec_mode_options;
 extern ulonglong slave_type_conversions_options;
 extern ulonglong slave_rows_search_algorithms_options;
+#ifndef DBUG_OFF
+extern uint slave_rows_last_search_algorithm_used;
+#endif
 extern my_bool opt_readonly, lower_case_file_system;
 extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
 extern my_bool opt_secure_auth;


Attachment: [text/bzr-bundle] bzr/luis.soares@oracle.com-20101123000801-5j21scemuaeww11h.bundle
Thread
bzr commit into mysql-next-mr branch (luis.soares:3214) WL#5597Luis Soares23 Nov