| 1 |
# |
| 2 |
# Test of auto_increment |
| 3 |
# BUG#11932 |
| 4 |
# |
| 5 |
# Bug reported that master and slave get out of sync after TRUNCATE |
| 6 |
# TABLE. |
| 7 |
# |
| 8 |
# Test supplied by Are Casilla |
| 9 |
|
| 10 |
source include/set_privilege_checks_user_as_system_user.inc; |
| 11 |
source include/master-slave.inc; |
| 12 |
|
| 13 |
SET SESSION sql_log_bin= 0; |
| 14 |
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); |
| 15 |
SET SESSION sql_log_bin= 1; |
| 16 |
|
| 17 |
--disable_warnings |
| 18 |
connection master; |
| 19 |
drop database if exists test1; |
| 20 |
--enable_warnings |
| 21 |
create database test1; |
| 22 |
use test1; |
| 23 |
|
| 24 |
CREATE TABLE `t1` ( |
| 25 |
`id` int(10) unsigned NOT NULL auto_increment, |
| 26 |
`fname` varchar(100) default NULL, |
| 27 |
PRIMARY KEY (`id`) |
| 28 |
) DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; |
| 29 |
|
| 30 |
INSERT INTO `t1` VALUES (1, 'blablabla'); |
| 31 |
|
| 32 |
CREATE TABLE `t2` ( |
| 33 |
`id` int(10) NOT NULL auto_increment, |
| 34 |
`comment` varchar(255) NOT NULL default '', |
| 35 |
PRIMARY KEY (`id`) |
| 36 |
) AUTO_INCREMENT=3 ; |
| 37 |
|
| 38 |
INSERT INTO `t2` VALUES (1, 'testtest 1'); |
| 39 |
INSERT INTO `t2` VALUES (2, 'test 2'); |
| 40 |
|
| 41 |
DELIMITER $; |
| 42 |
CREATE PROCEDURE simpleproc3 () |
| 43 |
NOT DETERMINISTIC |
| 44 |
BEGIN |
| 45 |
INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1'); |
| 46 |
INSERT INTO t1 (fname) VALUES('test'); |
| 47 |
END |
| 48 |
$ |
| 49 |
DELIMITER ;$ |
| 50 |
|
| 51 |
--disable_warnings |
| 52 |
CALL simpleproc3(); |
| 53 |
--enable_warnings |
| 54 |
|
| 55 |
select * from t2; |
| 56 |
|
| 57 |
TRUNCATE TABLE `t1`; |
| 58 |
--disable_warnings |
| 59 |
CALL simpleproc3(); |
| 60 |
--enable_warnings |
| 61 |
|
| 62 |
select * from t1; |
| 63 |
|
| 64 |
--source include/sync_slave_sql_with_master.inc |
| 65 |
|
| 66 |
SET SESSION sql_log_bin= 0; |
| 67 |
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); |
| 68 |
SET SESSION sql_log_bin= 1; |
| 69 |
|
| 70 |
use test1; |
| 71 |
select * from t1; |
| 72 |
|
| 73 |
connection master; |
| 74 |
drop database test1; |
| 75 |
--source include/rpl_end.inc |