| 1 |
########################################################### |
| 2 |
# See if queries that use both auto_increment and LAST_INSERT_ID() |
| 3 |
# are replicated well |
| 4 |
############################################################ |
| 5 |
# REQUIREMENT |
| 6 |
# Auto increment should work for a table with auto_increment column |
| 7 |
# and primary key. |
| 8 |
############################################################## |
| 9 |
|
| 10 |
# We also check how the foreign_key_check variable is replicated |
| 11 |
|
| 12 |
-- source include/master-slave.inc |
| 13 |
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); |
| 14 |
|
| 15 |
#should work for both SBR and RBR |
| 16 |
|
| 17 |
create table t1(a int auto_increment, primary key(a)); |
| 18 |
create table t2(b int auto_increment, c int, primary key(b)); |
| 19 |
insert into t1 values (1),(2),(3); |
| 20 |
insert into t1 values (null); |
| 21 |
insert into t2 values (null,last_insert_id()); |
| 22 |
sync_slave_with_master; |
| 23 |
select * from t1 ORDER BY a; |
| 24 |
select * from t2 ORDER BY b; |
| 25 |
connection master; |
| 26 |
#check if multi-line inserts, |
| 27 |
#which set last_insert_id to the first id inserted, |
| 28 |
#are replicated the same way |
| 29 |
drop table t1; |
| 30 |
drop table t2; |
| 31 |
--disable_warnings |
| 32 |
eval create table t1(a int auto_increment, key(a)) engine=$engine_type; |
| 33 |
eval create table t2(b int auto_increment, c int, key(b), foreign key(b) references t1(a)) engine=$engine_type; |
| 34 |
--enable_warnings |
| 35 |
SET FOREIGN_KEY_CHECKS=0; |
| 36 |
insert into t1 values (10); |
| 37 |
insert into t1 values (null),(null),(null); |
| 38 |
insert into t2 values (5,0); |
| 39 |
insert into t2 values (null,last_insert_id()); |
| 40 |
SET FOREIGN_KEY_CHECKS=1; |
| 41 |
sync_slave_with_master; |
| 42 |
select * from t1; |
| 43 |
select * from t2; |
| 44 |
connection master; |
| 45 |
|
| 46 |
# check if INSERT SELECT in auto_increment is well replicated (bug #490) |
| 47 |
|
| 48 |
drop table t2; |
| 49 |
drop table t1; |
| 50 |
create table t1(a int auto_increment, primary key(a)); |
| 51 |
create table t2(b int auto_increment, c int, primary key(b)); |
| 52 |
insert into t1 values (10); |
| 53 |
insert into t1 values (null),(null),(null); |
| 54 |
insert into t2 values (5,0); |
| 55 |
--disable_warnings ONCE |
| 56 |
insert into t2 (c) select * from t1 ORDER BY a; |
| 57 |
select * from t2 ORDER BY b; |
| 58 |
sync_slave_with_master; |
| 59 |
select * from t1 ORDER BY a; |
| 60 |
select * from t2 ORDER BY b; |
| 61 |
connection master; |
| 62 |
drop table t1; |
| 63 |
drop table t2; |
| 64 |
sync_slave_with_master; |
| 65 |
|
| 66 |
# |
| 67 |
# Bug#8412: Error codes reported in binary log for CHARACTER SET, |
| 68 |
# FOREIGN_KEY_CHECKS |
| 69 |
# |
| 70 |
connection master; |
| 71 |
SET TIMESTAMP=1000000000; |
| 72 |
CREATE TABLE t1 ( a INT UNIQUE ); |
| 73 |
SET FOREIGN_KEY_CHECKS=0; |
| 74 |
# Duplicate Key Errors codes |
| 75 |
--error 1022, ER_DUP_ENTRY |
| 76 |
INSERT INTO t1 VALUES (1),(1); |
| 77 |
sync_slave_with_master; |
| 78 |
connection master; |
| 79 |
drop table t1; |
| 80 |
|
| 81 |
# End of 4.1 tests |
| 82 |
|
| 83 |
--source include/rpl_end.inc |