Debian Codegraph @

mysql-test/suite/rpl/t/rpl_auto_increment_bug45679.test

raw
1 # Test of auto-increment.
2 #
3 # BUG#11754117-45670
4 # Multipart primary key with the autoincrement part not first in it
5 # is replication unsafe.
6 #
7
8 source include/have_binlog_format_mixed.inc;
9 source include/have_innodb.inc;
10 source include/master-slave.inc;
11
12 call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
13
14 --connection master
15 create table tm (b int auto_increment, a int, primary key (a,b)) engine= myisam;
16 --error ER_WRONG_AUTO_KEY
17 create table ti (b int auto_increment, a int, primary key (a,b)) engine= innodb;
18 create table ti (b int auto_increment, a int, primary key (b,a)) engine= innodb;
19
20 set @@binlog_format=statement;
21 --echo *** autoincrement field is not the first in PK warning must be there: ***
22 insert into tm set b=null, a=1;
23 show warnings;
24 --echo *** no warning when autoincrement is the first in PK
25 insert into ti set b=null, a=1;
26 show warnings;
27
28 delimiter //;
29 create function multi_part_pk_with_autoinc (arg int)
30 returns int
31 begin
32 insert into tm set b=null, a=arg;
33 return arg;
34 end//
35 delimiter ;//
36
37 --disable_ps2_protocol
38 select multi_part_pk_with_autoinc (3);
39 --enable_ps2_protocol
40 --echo *** autoincrement field is not the first in PK warning must be there: ***
41 show warnings;
42
43 set @@binlog_format=mixed;
44 insert into tm set b=null, a=2;
45
46 sync_slave_with_master;
47
48 if (`select count(*) <> 3 from tm`)
49 {
50 --echo Wrong result from SELECT on the slave side.
51 select * from tm;
52 --die
53 }
54
55 # cleanup
56
57 --connection master
58
59 drop table tm, ti;
60 drop function multi_part_pk_with_autoinc;
61
62 sync_slave_with_master;
63
64 --source include/rpl_end.inc