| 1 |
source include/have_log_bin.inc; |
| 2 |
source 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 |
|
| 7 |
reset master; |
| 8 |
create database testing_1; |
| 9 |
use testing_1; |
| 10 |
create table t1 (a int); |
| 11 |
create function sf1 (a int) returns int return a+1; |
| 12 |
create trigger tr1 before insert on t1 for each row insert into t2 values (2*new.a); |
| 13 |
create procedure sp1 (a int) insert into t1 values(a); |
| 14 |
drop database testing_1; |
| 15 |
source include/show_binlog_events.inc; |
| 16 |
|
| 17 |
# BUG#38773: DROP DATABASE cause switch to stmt-mode when there are |
| 18 |
# temporary tables open |
| 19 |
|
| 20 |
use test; |
| 21 |
reset master; |
| 22 |
create temporary table tt1 (a int); |
| 23 |
create table t1 (a int); |
| 24 |
insert into t1 values (1); |
| 25 |
disable_warnings; |
| 26 |
drop database if exists mysqltest1; |
| 27 |
enable_warnings; |
| 28 |
insert into t1 values (1); |
| 29 |
drop table tt1, t1; |
| 30 |
source include/show_binlog_events.inc; |
| 31 |
|
| 32 |
FLUSH 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. |
| 38 |
RESET MASTER; |
| 39 |
CREATE DATABASE testing_1; |
| 40 |
USE testing_1; |
| 41 |
CREATE TABLE t1(c1 INT); |
| 42 |
CREATE TABLE t2(c1 INT); |
| 43 |
|
| 44 |
let $prefix= `SELECT UUID()`; |
| 45 |
--echo # Create a file in the database directory |
| 46 |
--replace_result $prefix FAKE_FILE |
| 47 |
eval 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 |
| 57 |
DROP DATABASE testing_1; |
| 58 |
let $wait_binlog_event= DROP TABLE IF EXIST; |
| 59 |
source include/wait_for_binlog_event.inc; |
| 60 |
let $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. |
| 66 |
DROP 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 |
|
| 74 |
USE test; |
| 75 |
--disable_warnings |
| 76 |
DROP DATABASE IF EXISTS db1; |
| 77 |
DROP TABLE IF EXISTS t3; |
| 78 |
--enable_warnings |
| 79 |
|
| 80 |
CREATE DATABASE db1; |
| 81 |
CREATE TABLE db1.t1 (a INT); |
| 82 |
CREATE TABLE db1.t2 (b INT, KEY(b)) engine=innodb; |
| 83 |
CREATE TABLE t3 (a INT, KEY (a), FOREIGN KEY(a) REFERENCES db1.t2(b)) |
| 84 |
engine=innodb; |
| 85 |
RESET MASTER; |
| 86 |
|
| 87 |
--error ER_ROW_IS_REFERENCED_2 |
| 88 |
DROP DATABASE db1; # Fails because of the fk |
| 89 |
SHOW TABLES FROM db1; # t1 was dropped, t2 remains |
| 90 |
--source include/show_binlog_events.inc # Check that the binlog drops t1 |
| 91 |
|
| 92 |
# Cleanup |
| 93 |
DROP TABLE t3; |
| 94 |
DROP DATABASE db1; |