summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/binlog/include/drop_temp_table.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/binlog/include/drop_temp_table.test')
-rw-r--r--mysql-test/suite/binlog/include/drop_temp_table.test176
1 files changed, 176 insertions, 0 deletions
diff --git a/mysql-test/suite/binlog/include/drop_temp_table.test b/mysql-test/suite/binlog/include/drop_temp_table.test
new file mode 100644
index 00000000..7c95195e
--- /dev/null
+++ b/mysql-test/suite/binlog/include/drop_temp_table.test
@@ -0,0 +1,176 @@
+--source include/have_innodb.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS `drop-temp+table-test`;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connection con1;
+RESET MASTER;
+CREATE DATABASE `drop-temp+table-test`;
+USE `drop-temp+table-test`;
+CREATE TEMPORARY TABLE shortn1 (a INT);
+CREATE TEMPORARY TABLE `table:name` (a INT);
+CREATE TEMPORARY TABLE shortn2 (a INT);
+
+##############################################################################
+# MDEV-20091: DROP TEMPORARY TABLE IF EXISTS statements will be written
+# to binlog only if the corresponding temporary table exists.
+##############################################################################
+CREATE TEMPORARY TABLE tmp(c1 int);
+CREATE TEMPORARY TABLE tmp1(c1 int);
+CREATE TEMPORARY TABLE tmp2(c1 int);
+CREATE TEMPORARY TABLE tmp3(c1 int);
+CREATE TABLE t(c1 int);
+
+DROP TEMPORARY TABLE IF EXISTS tmp;
+
+--disable_warnings
+# Post MDEV-20091: Following DROP TEMPORARY TABLE statement should not be
+# logged as the table is already dropped above.
+DROP TEMPORARY TABLE IF EXISTS tmp;
+
+# Post MDEV-20091: Only DROP TEMPORARY TABLE statement should be written only
+# for 'tmp1' table.
+DROP TEMPORARY TABLE IF EXISTS tmp, tmp1;
+DROP TEMPORARY TABLE tmp3;
+
+#In RBR, tmp2 will NOT be binlogged, because it is a temporary table.
+DROP TABLE IF EXISTS tmp2, t;
+
+#In RBR, tmp2 will be binlogged, because it does not exist and master do not know
+# whether it is a temporary table or not.
+DROP TABLE IF EXISTS tmp2, t;
+--enable_warnings
+
+SELECT GET_LOCK("a",10);
+
+#
+# BUG48216 Replication fails on all slaves after upgrade to 5.0.86 on master
+#
+# When the session is closed, any temporary tables of the session are dropped
+# and are binlogged. But it will be binlogged with a wrong database name when
+# the length of the database name('drop-temp-table-test') is greater than the
+# current database name('test').
+#
+USE test;
+disconnect con1;
+
+connection con2;
+# We want to SHOW BINLOG EVENTS, to know what was logged. But there is no
+# guarantee that logging of the terminated con1 has been done yet.
+# To be sure that logging has been done, we use a user lock.
+SELECT GET_LOCK("a",10);
+let $VERSION=`SELECT VERSION()`;
+source include/show_binlog_events.inc;
+DROP DATABASE `drop-temp+table-test`;
+
+
+#
+# Bug #54842: DROP TEMPORARY TABLE not binlogged after manual switching binlog format to ROW
+#
+# Sanity test. Checking that implicit DROP event is logged.
+#
+# After BUG#52616, the switch to ROW mode becomes effective even
+# if there are open temporary tables. As such the implicit drop
+# for temporary tables on session closing must be logged.
+#
+# MDEV-20091: DROP TEMPORARY TABLE IF EXISTS statements will be written to
+# binlog only if the corresponding temporary table exists. In row based
+# replication temporary tables are not replicated hence their corresponding
+# DROP TEMPORARY TABLE statement will be not be written to binary log upon
+# session closure.
+#
+
+RESET MASTER;
+
+CREATE TABLE t1 ( i text );
+
+--connect(con1,localhost,root,,)
+CREATE TEMPORARY TABLE ttmp1 ( i text );
+SET @@session.binlog_format=ROW;
+INSERT INTO t1 VALUES ('1');
+SELECT @@session.binlog_format;
+--disconnect con1
+
+-- connection default
+if (!`SELECT @@BINLOG_FORMAT = 'ROW'`) {
+--let $wait_binlog_event= DROP
+--source include/wait_for_binlog_event.inc
+}
+-- source include/show_binlog_events.inc
+RESET MASTER;
+
+DROP TABLE t1;
+
+# End of 4.1 tests
+
+
+--echo #
+--echo # BUG#28642318: POINT IN TIME RECOVERY USING MYSQLBINLOG BROKEN
+--echo # WITH TEMPORARY TABLE -> ERRORS
+
+--echo # Test case for DELETE query.
+
+RESET MASTER;
+connect (con1,localhost,root,,);
+
+--echo # Set up.
+--connection default
+--disable_warnings
+SET @save_binlog_format= @@session.binlog_format;
+SET @@session.binlog_format=STATEMENT;
+let $MYSQLD_DATADIR= `select @@datadir`;
+CREATE TABLE t1 (a INT) ENGINE=INNODB;
+
+--connection con1
+SET @@session.binlog_format=STATEMENT;
+CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
+
+--connection default
+DELETE d1, d2 FROM t1 AS d1, t1 AS d2 WHERE d1.a<>d2.a;
+
+--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql
+
+--connection default
+DROP TABLE t1;
+
+--echo # DELETE query fails with table re-open error without patch.
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug28642318.sql
+
+--echo # Clean up.
+--connection con1
+DROP TABLE IF EXISTS t1;
+
+--connection default
+DROP TABLE IF EXISTS t1;
+RESET MASTER;
+
+--echo # Test case for DROP query.
+
+--connection default
+CREATE TABLE t2 (a INT) ENGINE=INNODB;
+
+--connection con1
+CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB;
+
+--connection default
+DROP TABLE t2;
+
+--connection con1
+DROP TABLE t2;
+
+--connection default
+--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql
+
+--echo # DROP table query fails with unknown table error without patch.
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug28642318.sql
+
+--echo # Clean up
+--connection default
+SET @@session.binlog_format= @save_binlog_format;
+RESET MASTER;
+
+--disconnect con1
+--enable_warnings