| 1 |
# BUG#47312: RBR: Disabling key on slave breaks replication: |
| 2 |
# HA_ERR_WRONG_INDEX |
| 3 |
# |
| 4 |
# Description |
| 5 |
# =========== |
| 6 |
# |
| 7 |
# This test case checks whether disabling a key on a slave breaks |
| 8 |
# replication or not. |
| 9 |
# |
| 10 |
# Case #1, shows that while not using ALTER TABLE... DISABLE KEYS and |
| 11 |
# the slave has no key defined while the master has one, replication |
| 12 |
# won't break. |
| 13 |
# |
| 14 |
# |
| 15 |
|
| 16 |
-- source include/not_group_replication_plugin.inc |
| 17 |
-- source include/have_binlog_format_row.inc |
| 18 |
-- source include/master-slave.inc |
| 19 |
|
| 20 |
# |
| 21 |
# Case #1: master has key, but slave has not. |
| 22 |
# Replication does not break. |
| 23 |
# |
| 24 |
|
| 25 |
SET SQL_LOG_BIN=0; |
| 26 |
CREATE TABLE t (a int, b int, c int, key(b)); |
| 27 |
SET SQL_LOG_BIN=1; |
| 28 |
|
| 29 |
-- connection slave |
| 30 |
|
| 31 |
CREATE TABLE t (a int, b int, c int); |
| 32 |
|
| 33 |
-- connection master |
| 34 |
|
| 35 |
INSERT INTO t VALUES (1,2,4); |
| 36 |
INSERT INTO t VALUES (4,3,4); |
| 37 |
DELETE FROM t; |
| 38 |
|
| 39 |
--source include/sync_slave_sql_with_master.inc |
| 40 |
|
| 41 |
-- connection master |
| 42 |
DROP TABLE t; |
| 43 |
|
| 44 |
--source include/sync_slave_sql_with_master.inc |
| 45 |
|
| 46 |
# |
| 47 |
# BUG#53893: RBR: nullable unique key can lead to out-of-sync slave |
| 48 |
# |
| 49 |
|
| 50 |
# |
| 51 |
# We insert two rows. Both with part of UNIQUE KEY set to null. |
| 52 |
# Then we update the last row inserted. On master the correct |
| 53 |
# row is updated. On the slave the wrong row would be updated |
| 54 |
# because the engine would look it up by the NULL Unique KEY. |
| 55 |
# As a consquence, the wrong row would be updated. |
| 56 |
# |
| 57 |
|
| 58 |
-- source include/rpl_reset.inc |
| 59 |
-- connection master |
| 60 |
|
| 61 |
CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, c3 INT, UNIQUE KEY(c1,c3), KEY(c2)); |
| 62 |
INSERT INTO t1(c1,c2) VALUES(1,1); |
| 63 |
INSERT INTO t1(c1,c2) VALUES(1,2); |
| 64 |
UPDATE t1 SET c1=1000 WHERE c2=2; |
| 65 |
--source include/sync_slave_sql_with_master.inc |
| 66 |
|
| 67 |
-- let $diff_tables= master:t1, slave:t1 |
| 68 |
-- source include/diff_tables.inc |
| 69 |
|
| 70 |
-- connection master |
| 71 |
DROP TABLE t1; |
| 72 |
|
| 73 |
--echo # |
| 74 |
--echo # Bug#27244826: INVISIBLE INDEXES ARE NOT RESPECTED BY SLAVE UNDER ROW |
| 75 |
--echo # FORMAT |
| 76 |
--echo # |
| 77 |
|
| 78 |
CREATE TABLE t1 ( id INT, KEY idx_id(id) ); |
| 79 |
|
| 80 |
INSERT INTO t1 VALUES (1), (2), (3); |
| 81 |
--source include/sync_slave_sql_with_master.inc |
| 82 |
|
| 83 |
--echo # Alter idx_id index on slave to invisible. |
| 84 |
ALTER TABLE t1 ALTER INDEX idx_id INVISIBLE; |
| 85 |
|
| 86 |
--connection master |
| 87 |
DELETE FROM t1; |
| 88 |
--source include/sync_slave_sql_with_master.inc |
| 89 |
|
| 90 |
--echo # check whether invisible attribute is respected |
| 91 |
SELECT table_name, index_name, is_visible |
| 92 |
FROM information_schema.statistics |
| 93 |
WHERE index_name = 'idx_id'; |
| 94 |
|
| 95 |
# This prints warning 3719: |
| 96 |
# |
| 97 |
# 'utf8' is currently an alias for the character set UTF8MB3, which will be |
| 98 |
# replaced by UTF8MB4 in a future release. Please consider using UTF8MB4 in |
| 99 |
# order to be unambiguous. |
| 100 |
# |
| 101 |
# The number of warnings printed depends on the platform, |
| 102 |
# so use disable_warnings to get a stable result file. |
| 103 |
|
| 104 |
--disable_warnings |
| 105 |
SELECT * FROM sys.schema_unused_indexes WHERE index_name = 'idx_id'; |
| 106 |
--enable_warnings |
| 107 |
|
| 108 |
SELECT rows_selected |
| 109 |
FROM sys.schema_index_statistics |
| 110 |
WHERE index_name = 'idx_id'; |
| 111 |
|
| 112 |
--connection master |
| 113 |
DROP TABLE t1; |
| 114 |
|
| 115 |
--source include/rpl_end.inc |