mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
f94e7288e3
FAILED DROP DATABASE CAN BREAK STATEMENT BASED REPLICATION The first phase of DROP DATABASE is to delete the tables in the database. If deletion of one or more of the tables fail (e.g. due to a FOREIGN KEY constraint), DROP DATABASE will be aborted. However, some tables could still have been deleted. The problem was that nothing would be written to the binary log in this case, so any slaves would not delete these tables. Therefore the master and the slaves would get out of sync. This patch fixes the problem by making sure that DROP TABLE is written to the binary log for the tables that were in fact deleted by the failed DROP DATABASE statement. Test case added to binlog.binlog_database.test.
59 lines
1.6 KiB
Text
59 lines
1.6 KiB
Text
source include/have_log_bin.inc;
|
|
source include/not_embedded.inc;
|
|
|
|
# Checking that the drop of a database does not replicate anything in
|
|
# addition to the drop of the database
|
|
|
|
reset master;
|
|
create database testing_1;
|
|
use testing_1;
|
|
create table t1 (a int);
|
|
create function sf1 (a int) returns int return a+1;
|
|
create trigger tr1 before insert on t1 for each row insert into t2 values (2*new.a);
|
|
create procedure sp1 (a int) insert into t1 values(a);
|
|
drop database testing_1;
|
|
source include/show_binlog_events.inc;
|
|
|
|
# BUG#38773: DROP DATABASE cause switch to stmt-mode when there are
|
|
# temporary tables open
|
|
|
|
use test;
|
|
reset master;
|
|
create temporary table tt1 (a int);
|
|
create table t1 (a int);
|
|
insert into t1 values (1);
|
|
disable_warnings;
|
|
drop database if exists mysqltest1;
|
|
enable_warnings;
|
|
insert into t1 values (1);
|
|
drop table tt1, t1;
|
|
source include/show_binlog_events.inc;
|
|
|
|
FLUSH STATUS;
|
|
|
|
|
|
--echo #
|
|
--echo # Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
|
|
--echo # BASED REPLICATION
|
|
--echo #
|
|
|
|
--disable_warnings
|
|
DROP DATABASE IF EXISTS db1;
|
|
DROP TABLE IF EXISTS t3;
|
|
--enable_warnings
|
|
|
|
CREATE DATABASE db1;
|
|
CREATE TABLE db1.t1 (a INT);
|
|
CREATE TABLE db1.t2 (b INT, KEY(b)) engine=innodb;
|
|
CREATE TABLE t3 (a INT, KEY (a), FOREIGN KEY(a) REFERENCES db1.t2(b))
|
|
engine=innodb;
|
|
RESET MASTER;
|
|
|
|
--error ER_ROW_IS_REFERENCED
|
|
DROP DATABASE db1; # Fails because of the fk
|
|
SHOW TABLES FROM db1; # t1 was dropped, t2 remains
|
|
--source include/show_binlog_events.inc # Check that the binlog drops t1
|
|
|
|
# Cleanup
|
|
DROP TABLE t3;
|
|
DROP DATABASE db1;
|