| 1 |
--source include/have_ndb.inc |
| 2 |
--source include/have_binlog_format_mixed_or_row.inc |
| 3 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 4 |
|
| 5 |
# |
| 6 |
# Slave behaviour when replicating unique index operations |
| 7 |
# |
| 8 |
# |
| 9 |
|
| 10 |
--connection master |
| 11 |
|
| 12 |
CREATE TABLE t1 (pk int primary key, uk1 int not null, uk2 int not null, |
| 13 |
unique(uk1), unique(uk2)) engine=ndb; |
| 14 |
|
| 15 |
# Now perform some operations which do not result in uniqueness |
| 16 |
# violations when applied in-order, but which can result in them |
| 17 |
# when applied out-of-order |
| 18 |
# 5 distinct values chosen to increase the chance of different |
| 19 |
# fragments (and therefore potentially different SUMA->Binlog |
| 20 |
# orders) being seen. |
| 21 |
# |
| 22 |
insert into t1 values (1,1,1); |
| 23 |
insert into t1 values (2,2,2); |
| 24 |
insert into t1 values (3,3,3); |
| 25 |
insert into t1 values (4,4,4); |
| 26 |
insert into t1 values (5,5,5); |
| 27 |
|
| 28 |
--sorted_result |
| 29 |
select * from t1 where uk1 in (1,2,3,4,5); |
| 30 |
|
| 31 |
# Do a 'right shift' on the unique key values |
| 32 |
update t1 set uk1=uk1-1 order by pk; |
| 33 |
update t1 set uk2=uk2+1 order by pk desc; |
| 34 |
|
| 35 |
--sorted_result |
| 36 |
select * from t1 where uk1 in (0,1,2,3,4); |
| 37 |
|
| 38 |
--echo Master table contents |
| 39 |
select * from t1 order by pk; |
| 40 |
|
| 41 |
flush logs; |
| 42 |
|
| 43 |
--sync_slave_with_master |
| 44 |
|
| 45 |
--connection slave |
| 46 |
|
| 47 |
--echo Slave table contents |
| 48 |
select * from t1 order by pk; |
| 49 |
select * from t1 where uk1 in (0,1,2,3,4); |
| 50 |
|
| 51 |
--connection master |
| 52 |
drop table t1; |
| 53 |
|
| 54 |
--source include/rpl_end.inc |