summaryrefslogtreecommitdiff
path: root/sql/log_event.cc
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 /sql/log_event.cc
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 'sql/log_event.cc')
-rw-r--r--sql/log_event.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 916a95e170f..b9da915ba96 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -2969,7 +2969,12 @@ void Query_log_event::print_query_header(IO_CACHE* file,
error_code);
}
- if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db)
+ if ((flags & LOG_EVENT_SUPPRESS_USE_F))
+ {
+ if (!is_trans_keyword())
+ print_event_info->db[0]= '\0';
+ }
+ else if (db)
{
different_db= memcmp(print_event_info->db, db, db_len + 1);
if (different_db)