| 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/set_privilege_checks_user_as_system_user.inc |
| 9 |
source include/master-slave.inc; |
| 10 |
source include/have_binlog_format_mixed.inc; |
| 11 |
source include/force_myisam_default.inc; |
| 12 |
source include/have_myisam.inc; |
| 13 |
|
| 14 |
|
| 15 |
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); |
| 16 |
|
| 17 |
--connection master |
| 18 |
create table tm (b int auto_increment, a int, primary key (a,b)) engine= myisam; |
| 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 |
|
| 25 |
delimiter //; |
| 26 |
create function multi_part_pk_with_autoinc (arg int) |
| 27 |
returns int |
| 28 |
begin |
| 29 |
insert into tm set b=null, a=arg; |
| 30 |
return arg; |
| 31 |
end// |
| 32 |
delimiter ;// |
| 33 |
|
| 34 |
select multi_part_pk_with_autoinc (3); |
| 35 |
--echo *** autoincrement field is not the first in PK warning must be there: *** |
| 36 |
show warnings; |
| 37 |
|
| 38 |
set @@binlog_format=mixed; |
| 39 |
insert into tm set b=null, a=2; |
| 40 |
|
| 41 |
--source include/sync_slave_sql_with_master.inc |
| 42 |
|
| 43 |
if (`select count(*) <> 3 from tm`) |
| 44 |
{ |
| 45 |
--echo Wrong result from SELECT on the slave side. |
| 46 |
select * from tm; |
| 47 |
--die |
| 48 |
} |
| 49 |
|
| 50 |
# cleanup |
| 51 |
|
| 52 |
--connection master |
| 53 |
|
| 54 |
drop table tm; |
| 55 |
drop function multi_part_pk_with_autoinc; |
| 56 |
|
| 57 |
--source include/sync_slave_sql_with_master.inc |
| 58 |
|
| 59 |
--source include/rpl_end.inc |