| 1 |
# =========== Purpose =========== |
| 2 |
# |
| 3 |
# To test that if different primary key is used on master and slave |
| 4 |
# and if there is an Unique key present on slave then that should be |
| 5 |
# used for lookup replicated rows. |
| 6 |
# Earlier in above cases a TABLE_SCAN was being performed which can be |
| 7 |
# slower than INDEX_SCAN that will be performed after the bug fix. |
| 8 |
# |
| 9 |
# ========= Reference ========== |
| 10 |
# Bug#26450129:DEAD BRANCH IN SEARCH_KEY_IN_TABLE() |
| 11 |
|
| 12 |
# The status variable Replica_rows_last_search_algorithm_used is defined |
| 13 |
# only in Debug mode, running this test in non-debug mode will cause |
| 14 |
# assert failure. |
| 15 |
--source include/have_debug.inc |
| 16 |
--source include/have_binlog_format_row.inc |
| 17 |
--let $rpl_skip_start_slave = 1 |
| 18 |
--source include/master-slave.inc |
| 19 |
|
| 20 |
--echo ==== Initialize ==== |
| 21 |
|
| 22 |
--source include/rpl_connection_slave.inc |
| 23 |
SET @old_slave_rows_search_algorithms = @@global.slave_rows_search_algorithms; |
| 24 |
SET @@global.slave_rows_search_algorithms = 'INDEX_SCAN,TABLE_SCAN'; |
| 25 |
--source include/start_slave.inc |
| 26 |
|
| 27 |
--source include/rpl_connection_master.inc |
| 28 |
SET @@session.binlog_row_image = 'MINIMAL'; |
| 29 |
|
| 30 |
SET @@session.sql_log_bin = 0; |
| 31 |
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(b)); |
| 32 |
SET @@session.sql_log_bin = 1; |
| 33 |
--source include/rpl_connection_slave.inc |
| 34 |
CREATE TABLE t1 (a INT, b INT NOT NULL, UNIQUE KEY(b), PRIMARY KEY(a)); |
| 35 |
--source include/rpl_connection_master.inc |
| 36 |
|
| 37 |
--let $row_count = 100 |
| 38 |
--let $rows = (0, 0) |
| 39 |
--let $i = 1 |
| 40 |
while ($i < $row_count) { |
| 41 |
--let $rows = $rows, ($i, $i) |
| 42 |
--inc $i |
| 43 |
} |
| 44 |
--disable_query_log |
| 45 |
--echo INSERT INTO t1 VALUES [$row_count rows]; |
| 46 |
eval INSERT INTO t1 VALUES $rows; |
| 47 |
--enable_query_log |
| 48 |
--source include/sync_slave_sql_with_master.inc |
| 49 |
|
| 50 |
--echo ==== Test ==== |
| 51 |
|
| 52 |
--source include/rpl_connection_master.inc |
| 53 |
|
| 54 |
DELETE FROM t1 WHERE b != 0 ORDER BY b DESC; |
| 55 |
--source include/sync_slave_sql_with_master.inc |
| 56 |
|
| 57 |
|
| 58 |
--let $assert_cond = "[SHOW STATUS LIKE \"Replica_rows_last_search_algorithm_used\", Value, 1]" = "INDEX_SCAN" |
| 59 |
--let $assert_text= The search algorithm used while deleting rows is INDEX_SCAN, in the code before this bug it was TABLE_SCAN |
| 60 |
--source include/assert.inc |
| 61 |
|
| 62 |
# Cleanup |
| 63 |
--source include/rpl_connection_master.inc |
| 64 |
DROP TABLE t1; |
| 65 |
--source include/sync_slave_sql_with_master.inc |
| 66 |
--source include/stop_slave.inc |
| 67 |
SET @@global.slave_rows_search_algorithms = @old_slave_rows_search_algorithms; |
| 68 |
|
| 69 |
--let $rpl_only_running_threads=1 |
| 70 |
--source include/rpl_end.inc |