mariadb/mysql-test/suite/rpl/r/rpl_drop.result
Alfranio Correia f62e89fade BUG#55625 RBR breaks on failing 'CREATE TABLE'
A CREATE...SELECT that fails is written to the binary log if a non-transactional
statement is updated. If the logging format is ROW, the CREATE statement and the
changes are written to the binary log as distinct events and by consequence the
created table is not rolled back in the slave.

In this patch, we opted to let the slave goes out of sync by not writting to the
binary log the CREATE statement. We do this by simply reseting the binary log's
cache.

mysql-test/suite/rpl/r/rpl_drop.result:
  Added a test case.
mysql-test/suite/rpl/t/rpl_drop.test:
  Added a test case.
sql/log.cc:
  Introduced a function to clean up the cache.
sql/log.h:
  Introduced a function to clean up the cache.
sql/sql_insert.cc:
  Cleaned up the binary log cache if a CREATE...SELECT fails.
2010-08-02 20:48:56 +01:00

34 lines
1.1 KiB
Text

stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop table if exists t1, t2;
create table t1 (a int);
drop table t1, t2;
ERROR 42S02: Unknown table 't2'
include/stop_slave.inc
SET @old_binlog_format= @@global.binlog_format;
SET GLOBAL binlog_format = ROW;
include/start_slave.inc
SET @old_binlog_format= @@global.binlog_format;
SET binlog_format = ROW;
CREATE TABLE t2(a INT) ENGINE=MYISAM;
CREATE TABLE t3(a INT) ENGINE=INNODB;
CREATE FUNCTION f1() RETURNS INT
BEGIN
insert into t2 values(1);
insert into t3 values(1);
return 1;
END|
CREATE TABLE t1(UNIQUE(a)) ENGINE=MYISAM SELECT 1 AS a UNION ALL SELECT f1();
ERROR 23000: Duplicate entry '1' for key 'a'
CREATE TABLE t1(UNIQUE(a)) ENGINE=INNODB SELECT 1 AS a UNION ALL SELECT f1();
ERROR 23000: Duplicate entry '1' for key 'a'
show binlog events in 'master-bin.000001' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
DROP FUNCTION f1;
DROP TABLE t2, t3;
SET @@global.binlog_format= @old_binlog_format;
SET @@global.binlog_format= @old_binlog_format;