summaryrefslogtreecommitdiff
path: root/mysql-test/t/mysqlbinlog.test
diff options
context:
space:
mode:
authorunknown <Dao-Gang.Qu@sun.com>2010-12-29 13:22:52 +0800
committerunknown <Dao-Gang.Qu@sun.com>2010-12-29 13:22:52 +0800
commit7f6ce96df7188513bf3b502270aa2d8df1d2168e (patch)
treecb67b7a964821370a414aeae47472a4c25b57b47 /mysql-test/t/mysqlbinlog.test
parentbe6c3fd8aa3f99074ae9d8ac729062585544b3b8 (diff)
parent22639a066cde7b18133f81ca8c0528e115c08677 (diff)
downloadmariadb-git-7f6ce96df7188513bf3b502270aa2d8df1d2168e.tar.gz
Bug #50914 mysqlbinlog not handling drop of current default database
mysqlbinlog only prints "use $database" statements to its output stream when the active default database changes between events. This will cause "No Database Selected" error when dropping and recreating that database. To fix the problem, we clear print_event_info->db when printing an event of CREATE/DROP/ALTER database statements, so that the Query_log_event after such statements will be printed with the use 'db' anyway except transaction keywords. mysql-test/r/mysqlbinlog.result: Test result for Bug#50914. mysql-test/t/mysqlbinlog.test: Added test to verify if the approach of the mysqlbinlog prints "use $database" statements to its output stream will cause "No Database Selected" error when dropping and recreating that database. sql/log_event.cc: Updated code to clear print_event_info->db when printing an event of CREATE/DROP/ALTER database statements, so that the Query_log_event after such statements will be printed with the use 'db' anyway except transaction keywords.
Diffstat (limited to 'mysql-test/t/mysqlbinlog.test')
-rw-r--r--mysql-test/t/mysqlbinlog.test27
1 files changed, 26 insertions, 1 deletions
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index 76f6c63fc1d..714cfbbaa9b 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -491,7 +491,6 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn;
#
# WL#5625: Deprecate mysqlbinlog options --base64-output=always and --base64-output
#
-
--echo # Expect deprecation warning.
--exec $MYSQL_BINLOG --base64-output=always std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
--cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
@@ -502,3 +501,29 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn;
# Clean up this part of the test.
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+
+# BUG#50914
+# This test verifies if the approach of the mysqlbinlog prints
+# "use $database" statements to its output stream will cause
+# "No Database Selected" error when dropping and recreating
+# that database.
+#
+RESET MASTER;
+CREATE DATABASE test1;
+USE test1;
+CREATE TABLE t1(id int);
+DROP DATABASE test1;
+CREATE DATABASE test1;
+USE test1;
+CREATE TABLE t1(id int);
+DROP TABLE t1;
+DROP DATABASE test1;
+let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
+FLUSH LOGS;
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+exec $MYSQL_BINLOG $MYSQLD_DATADIR/$master_binlog | $MYSQL test 2>&1;
+
+let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
+source include/show_binlog_events.inc;
+