1source include/have_log_bin.inc;
2source include/not_embedded.inc;
3
4# Checking that the drop of a database does not replicate anything in
5# addition to the drop of the database
6
7reset master;
8create database testing_1;
9use testing_1;
10create table t1 (a int);
11create function sf1 (a int) returns int return a+1;
12create trigger tr1 before insert on t1 for each row insert into t2 values (2*new.a);
13create procedure sp1 (a int) insert into t1 values(a);
14drop database testing_1;
15source include/show_binlog_events.inc;
16
17# BUG#38773: DROP DATABASE cause switch to stmt-mode when there are
18# temporary tables open
19
20use test;
21reset master;
22create temporary table tt1 (a int);
23create table t1 (a int);
24insert into t1 values (1);
25disable_warnings;
26drop database if exists mysqltest1;
27enable_warnings;
28insert into t1 values (1);
29drop table tt1, t1;
30source include/show_binlog_events.inc;
31
32FLUSH STATUS;
33
34--echo
35--echo # 'DROP TABLE IF EXISTS <deleted tables>' is binlogged
36--echo # when 'DROP DATABASE' fails and at least one table is deleted
37--echo # from the database.
38RESET MASTER;
39CREATE DATABASE testing_1;
40USE testing_1;
41CREATE TABLE t1(c1 INT);
42CREATE TABLE t2(c1 INT);
43
44let $prefix= `SELECT UUID()`;
45--echo # Create a file in the database directory
46--replace_result $prefix FAKE_FILE
47eval SELECT 'hello' INTO OUTFILE 'fake_file.$prefix';
48
49--echo
50--echo # 'DROP DATABASE' will fail if there is any other file in the the
51--echo # database directory
52
53# Use '/' instead of '\' in the error message. On windows platform, dir is
54# formed with '\'.
55--replace_regex /\\testing_1\\*/\/testing_1\// /66/39/ /93/39/ /17/39/ /247/39/ /File exists/Directory not empty/
56--error 1010
57DROP DATABASE testing_1;
58let $wait_binlog_event= DROP TABLE IF EXIST;
59source include/wait_for_binlog_event.inc;
60let $MYSQLD_DATADIR= `SELECT @@datadir`;
61
62--echo
63--echo # Remove the fake file.
64--remove_file $MYSQLD_DATADIR/testing_1/fake_file.$prefix
65--echo # Now we can drop the database.
66DROP DATABASE testing_1;
67
68
69--echo #
70--echo # Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
71--echo #              BASED REPLICATION
72--echo #
73
74USE test;
75--disable_warnings
76DROP DATABASE IF EXISTS db1;
77DROP TABLE IF EXISTS t3;
78--enable_warnings
79
80CREATE DATABASE db1;
81CREATE TABLE db1.t1 (a INT);
82CREATE TABLE db1.t2 (b INT, KEY(b)) engine=innodb;
83CREATE TABLE t3 (a INT, KEY (a), FOREIGN KEY(a) REFERENCES db1.t2(b))
84  engine=innodb;
85RESET MASTER;
86
87--error ER_ROW_IS_REFERENCED_2
88DROP DATABASE db1;                      # Fails because of the fk
89SHOW TABLES FROM db1;                   # t1 was dropped, t2 remains
90--source include/show_binlog_events.inc # Check that the binlog drops t1
91
92# Cleanup
93DROP TABLE t3;
94DROP DATABASE db1;
95