MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Dao-Gang.Qu Date:November 29 2010 2:40am
Subject:bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3521) Bug#50914
View as plain text  
#At file:///home/daogang/bzrwork/bug50914/mysql-5.1-bugteam/ based on revid:azundris@stripped

 3521 Dao-Gang.Qu@stripped	2010-11-29
      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. Which will cause
      "No Database Selected" error when dropping and recreating that database
      though.
      
      To fix the problem, mysqlbinlog will print "use $database" statements
      to its output stream for every query log event as long as the database
      is not suppressed expressly.
     @ mysql-test/extra/binlog_tests/database.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 though.
     @ mysql-test/r/mysqlbinlog.result
        Updated for the patch of Bug#50914.
     @ mysql-test/r/mysqlbinlog2.result
        Updated for the patch of Bug#50914.
     @ mysql-test/r/user_var-binlog.result
        Updated for the patch of Bug#50914.
     @ mysql-test/suite/binlog/r/binlog_database.result
        Test result for Bug#50914.
     @ mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result
        Updated for the patch of Bug#50914.
     @ mysql-test/suite/rpl/r/rpl_sp.result
        Updated for the patch of Bug#50914.
     @ sql/log_event.cc
        Updated code to make mysqlbinlog print "use $database" statements
        to its output stream for every query log event as long as the
        database is not suppressed expressly.

    modified:
      mysql-test/extra/binlog_tests/database.test
      mysql-test/r/mysqlbinlog.result
      mysql-test/r/mysqlbinlog2.result
      mysql-test/r/user_var-binlog.result
      mysql-test/suite/binlog/r/binlog_database.result
      mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result
      mysql-test/suite/rpl/r/rpl_sp.result
      sql/log_event.cc
=== modified file 'mysql-test/extra/binlog_tests/database.test'
--- a/mysql-test/extra/binlog_tests/database.test	2009-01-23 12:22:05 +0000
+++ b/mysql-test/extra/binlog_tests/database.test	2010-11-29 02:40:31 +0000
@@ -12,6 +12,7 @@ create function sf1 (a int) returns int
 create trigger tr1 before insert on t1 for each row insert into t2 values (2*new.a);
 create procedure sp1 (a int) insert into t1 values(a);
 drop database testing_1;
+let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
 source include/show_binlog_events.inc;
 
 # BUG#38773: DROP DATABASE cause switch to stmt-mode when there are
@@ -27,6 +28,34 @@ drop database if exists mysqltest1;
 enable_warnings;
 insert into t1 values (1);
 drop table tt1, t1;
+let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
+source include/show_binlog_events.inc;
+
+#
+# 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 though.
+#
+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;
 
 FLUSH STATUS;
+

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2010-03-28 11:57:33 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2010-11-29 02:40:31 +0000
@@ -30,28 +30,36 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 drop table if exists t1,t2,t3,t4,t5,t03,t04
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 create table t1 (word varchar(20))
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 create table t2 (id int auto_increment not null primary key)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 insert into t1 values ("abirvalg")
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 insert into t2 values ()
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
 /*!*/;
@@ -131,28 +139,36 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 drop table if exists t1,t2,t3,t4,t5,t03,t04
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 create table t1 (word varchar(20))
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 create table t2 (id int auto_increment not null primary key)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 insert into t1 values ("abirvalg")
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 insert into t2 values ()
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
 /*!*/;
@@ -228,6 +244,7 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 BEGIN
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1108844555/*!*/;
 insert t1 values (1)
 /*!*/;
@@ -247,6 +264,7 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 BEGIN
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1108844555/*!*/;
 insert t1 values (1)
 /*!*/;
@@ -361,31 +379,39 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 create table t1 (a varchar(64) character set utf8)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.collation_database=7/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.collation_database=7/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO TABLE `t1` CHARACTER SET koi8r FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 drop table t1
 /*!*/;
@@ -499,28 +525,33 @@ create table t1(a int) engine= innodb
 SET TIMESTAMP=1253783037/*!*/;
 BEGIN
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1253783037/*!*/;
 insert into t1 (a) values (1)
 /*!*/;
 COMMIT/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1253783037/*!*/;
 create table t3(a int) engine= innodb
 /*!*/;
 SET TIMESTAMP=1253783037/*!*/;
 BEGIN
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1253783037/*!*/;
 insert into t3 (a) values (2)
 /*!*/;
 SET TIMESTAMP=1253783037/*!*/;
 ROLLBACK
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1253783037/*!*/;
 create table t5(a int) engine= NDB
 /*!*/;
 SET TIMESTAMP=1253783037/*!*/;
 BEGIN
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1253783037/*!*/;
 insert into t5 (a) values (3)
 /*!*/;
@@ -589,6 +620,7 @@ use db1/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
 /*!*/;
+use db1/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 INSERT INTO db1.t1 VALUES(40)
 /*!*/;
@@ -600,6 +632,7 @@ use db1/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 INSERT INTO db1.t2 VALUES("after rollback to")
 /*!*/;
+use db1/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 INSERT INTO db1.t1 VALUES(50)
 /*!*/;
@@ -628,6 +661,7 @@ use test/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 SavePoint mixed_cases
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1266652094/*!*/;
 ROLLBACK TO mixed_cases
 /*!*/;

=== modified file 'mysql-test/r/mysqlbinlog2.result'
--- a/mysql-test/r/mysqlbinlog2.result	2008-04-02 09:49:22 +0000
+++ b/mysql-test/r/mysqlbinlog2.result	2010-11-29 02:40:31 +0000
@@ -32,22 +32,27 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -75,18 +80,22 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -114,6 +123,7 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -140,14 +150,17 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
@@ -198,10 +211,12 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -228,10 +243,12 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
@@ -259,22 +276,27 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -317,18 +339,22 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -371,6 +397,7 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -412,22 +439,27 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -458,10 +490,12 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -503,10 +537,12 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
@@ -533,22 +569,27 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -576,18 +617,22 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -614,6 +659,7 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -640,14 +686,17 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
@@ -697,10 +746,12 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -727,10 +778,12 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
@@ -757,22 +810,27 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -815,18 +873,22 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -868,6 +930,7 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -909,22 +972,27 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -955,10 +1023,12 @@ SET @@session.collation_database=DEFAULT
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
@@ -1000,10 +1070,12 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
@@ -1030,26 +1102,32 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a int auto_increment not null primary key, b char(3))
 /*!*/;
 SET INSERT_ID=1/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "a")
 /*!*/;
 SET INSERT_ID=2/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 insert into t1 values(null, "b")
 /*!*/;
 SET INSERT_ID=3/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")
 /*!*/;
 SET INSERT_ID=4/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "d")
 /*!*/;
 SET INSERT_ID=5/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 insert into t1 values(null, "e")
 /*!*/;
 SET INSERT_ID=6/*!*/;
+use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 insert into t1 values(null, "f")
 /*!*/;

=== modified file 'mysql-test/r/user_var-binlog.result'
--- a/mysql-test/r/user_var-binlog.result	2008-04-02 09:49:22 +0000
+++ b/mysql-test/r/user_var-binlog.result	2010-11-29 02:40:31 +0000
@@ -33,6 +33,7 @@ INSERT INTO t1 VALUES(@`a b`)
 /*!*/;
 SET @`var1`:=_latin1 0x273B616161 COLLATE `latin1_swedish_ci`/*!*/;
 SET @`var2`:=_binary 0x61 COLLATE `binary`/*!*/;
+use test/*!*/;
 SET TIMESTAMP=10000/*!*/;
 insert into t1 values (@var1),(@var2)
 /*!*/;

=== modified file 'mysql-test/suite/binlog/r/binlog_database.result'
--- a/mysql-test/suite/binlog/r/binlog_database.result	2009-05-31 05:44:41 +0000
+++ b/mysql-test/suite/binlog/r/binlog_database.result	2010-11-29 02:40:31 +0000
@@ -7,7 +7,7 @@ create function sf1 (a int) returns int
 create trigger tr1 before insert on t1 for each row insert into t2 values (2*new.a);
 create procedure sp1 (a int) insert into t1 values(a);
 drop database testing_1;
-show binlog events from <binlog_start>;
+show binlog events in 'master-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	create database testing_1
 master-bin.000001	#	Query	#	#	use `testing_1`; create table t1 (a int)
@@ -25,7 +25,7 @@ insert into t1 values (1);
 drop database if exists mysqltest1;
 insert into t1 values (1);
 drop table tt1, t1;
-show binlog events from <binlog_start>;
+show binlog events in 'master-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; create temporary table tt1 (a int)
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int)
@@ -33,6 +33,26 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1)
 master-bin.000001	#	Query	#	#	use `test`; drop table tt1, t1
+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;
+FLUSH LOGS;
+show binlog events in 'master-bin.000002' from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000002	#	Query	#	#	CREATE DATABASE test1
+master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
+master-bin.000002	#	Query	#	#	DROP DATABASE test1
+master-bin.000002	#	Query	#	#	CREATE DATABASE test1
+master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
+master-bin.000002	#	Query	#	#	use `test1`; DROP TABLE t1
+master-bin.000002	#	Query	#	#	DROP DATABASE test1
 FLUSH STATUS;
 set binlog_format=mixed;
 reset master;
@@ -43,7 +63,7 @@ create function sf1 (a int) returns int
 create trigger tr1 before insert on t1 for each row insert into t2 values (2*new.a);
 create procedure sp1 (a int) insert into t1 values(a);
 drop database testing_1;
-show binlog events from <binlog_start>;
+show binlog events in 'master-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	create database testing_1
 master-bin.000001	#	Query	#	#	use `testing_1`; create table t1 (a int)
@@ -61,7 +81,7 @@ insert into t1 values (1);
 drop database if exists mysqltest1;
 insert into t1 values (1);
 drop table tt1, t1;
-show binlog events from <binlog_start>;
+show binlog events in 'master-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; create temporary table tt1 (a int)
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int)
@@ -69,6 +89,26 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1)
 master-bin.000001	#	Query	#	#	use `test`; drop table tt1, t1
+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;
+FLUSH LOGS;
+show binlog events in 'master-bin.000002' from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000002	#	Query	#	#	CREATE DATABASE test1
+master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
+master-bin.000002	#	Query	#	#	DROP DATABASE test1
+master-bin.000002	#	Query	#	#	CREATE DATABASE test1
+master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
+master-bin.000002	#	Query	#	#	use `test1`; DROP TABLE t1
+master-bin.000002	#	Query	#	#	DROP DATABASE test1
 FLUSH STATUS;
 set binlog_format=row;
 reset master;
@@ -79,7 +119,7 @@ create function sf1 (a int) returns int
 create trigger tr1 before insert on t1 for each row insert into t2 values (2*new.a);
 create procedure sp1 (a int) insert into t1 values(a);
 drop database testing_1;
-show binlog events from <binlog_start>;
+show binlog events in 'master-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	create database testing_1
 master-bin.000001	#	Query	#	#	use `testing_1`; create table t1 (a int)
@@ -97,7 +137,7 @@ insert into t1 values (1);
 drop database if exists mysqltest1;
 insert into t1 values (1);
 drop table tt1, t1;
-show binlog events from <binlog_start>;
+show binlog events in 'master-bin.000001' from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int)
 master-bin.000001	#	Query	#	#	BEGIN
@@ -110,6 +150,26 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+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;
+FLUSH LOGS;
+show binlog events in 'master-bin.000002' from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000002	#	Query	#	#	CREATE DATABASE test1
+master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
+master-bin.000002	#	Query	#	#	DROP DATABASE test1
+master-bin.000002	#	Query	#	#	CREATE DATABASE test1
+master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
+master-bin.000002	#	Query	#	#	use `test1`; DROP TABLE t1
+master-bin.000002	#	Query	#	#	DROP DATABASE test1
 FLUSH STATUS;
 show databases;
 Database

=== modified file 'mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result'
--- a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result	2010-01-27 12:23:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result	2010-11-29 02:40:31 +0000
@@ -191,12 +191,15 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 DROP TABLE IF EXISTS t1,t2,t3
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 CREATE TABLE t1(word VARCHAR(20))
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT)
 /*!*/;
@@ -300,12 +303,15 @@ SET @@session.lc_time_names=0/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
 DROP TABLE IF EXISTS t1,t2,t3
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 CREATE TABLE t1(word VARCHAR(20))
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT)
 /*!*/;

=== modified file 'mysql-test/suite/rpl/r/rpl_sp.result'
--- a/mysql-test/suite/rpl/r/rpl_sp.result	2010-05-24 13:54:08 +0000
+++ b/mysql-test/suite/rpl/r/rpl_sp.result	2010-11-29 02:40:31 +0000
@@ -635,6 +635,7 @@ use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 create table t1 (a varchar(100))
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` PROCEDURE `foo`()
 begin
@@ -644,45 +645,58 @@ insert into t1 values (b);
 insert into t1 values (unix_timestamp());
 end
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t1 values ( NAME_CONST('b',8))
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t1 values (unix_timestamp())
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 delete from t1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` PROCEDURE `foo2`()
 select * from mysqltest1.t1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 alter procedure foo2 contains sql
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop table t1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 create table t1 (a int)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 create table t2 like t1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` PROCEDURE `foo3`()
     DETERMINISTIC
 insert into t1 values (15)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` PROCEDURE `foo4`()
     DETERMINISTIC
@@ -691,33 +705,43 @@ insert into t2 values(3);
 insert into t1 values (5);
 end
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t2 values(3)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t1 values (15)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t2 values(3)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 alter procedure foo4 sql security invoker
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t2 values(3)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t1 values (5)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 delete from t2
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 alter table t2 add unique (a)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop procedure foo4
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` PROCEDURE `foo4`()
     DETERMINISTIC
@@ -725,21 +749,27 @@ begin
 insert into t2 values(20),(20);
 end
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t2 values(20),(20)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop procedure foo4
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop procedure foo
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop procedure foo2
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop procedure foo3
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`(x int) RETURNS int(11)
     DETERMINISTIC
@@ -748,18 +778,23 @@ insert into t1 values (x);
 return x+2;
 end
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 delete t1,t2 from t1,t2
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 SELECT `mysqltest1`.`fn1`(20)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t2 values(fn1(21))
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop function fn1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`() RETURNS int(11)
     NO SQL
@@ -767,12 +802,15 @@ begin
 return unix_timestamp();
 end
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 delete from t1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t1 values(fn1())
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` FUNCTION `fn2`() RETURNS int(11)
     NO SQL
@@ -780,6 +818,7 @@ begin
 return unix_timestamp();
 end
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` FUNCTION `fn3`() RETURNS int(11)
     READS SQL DATA
@@ -787,15 +826,19 @@ begin
 return 0;
 end
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 delete from t2
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 alter table t2 add unique (a)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop function fn1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`(x int) RETURNS int(11)
 begin
@@ -803,38 +846,49 @@ insert into t2 values(x),(x);
 return 10;
 end
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 SELECT `mysqltest1`.`fn1`(100)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 SELECT `mysqltest1`.`fn1`(20)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 delete from t1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` trigger trg before insert on t1 for each row set new.a= 10
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t1 values (1)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 delete from t1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop trigger trg
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t1 values (1)
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` PROCEDURE `foo`()
     READS SQL DATA
 select * from t1
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop procedure foo
 /*!*/;
+use mysqltest1/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop function fn1
 /*!*/;
@@ -848,6 +902,7 @@ use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop function if exists f1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
     READS SQL DATA
@@ -860,60 +915,78 @@ close c;
 return var;
 end
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 as a
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 create table t1 (a int)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t1 (a) values (f1())
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop view v1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop function f1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 DROP PROCEDURE IF EXISTS p1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 DROP TABLE IF EXISTS t1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE TABLE t1(col VARCHAR(10))
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(arg VARCHAR(10))
 INSERT INTO t1 VALUES(arg)
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test' COLLATE 'latin1_swedish_ci'))
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 DROP PROCEDURE p1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 DROP PROCEDURE IF EXISTS p1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 DROP FUNCTION IF EXISTS f1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
 SET @a = 1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
 RETURN 0
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 DROP PROCEDURE p1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 DROP FUNCTION f1
 /*!*/;
+use test/*!*/;
 SET TIMESTAMP=t/*!*/;
 drop table t1
 /*!*/;
@@ -933,13 +1006,16 @@ use mysqltest2/*!*/;
 SET TIMESTAMP=t/*!*/;
 create table t ( t integer )
 /*!*/;
+use mysqltest2/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltest`.`test`()
 begin end
 /*!*/;
+use mysqltest2/*!*/;
 SET TIMESTAMP=t/*!*/;
 insert into t values ( 1 )
 /*!*/;
+use mysqltest2/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
 begin
@@ -972,6 +1048,7 @@ begin
 select a;
 end
 /*!*/;
+use mysql/*!*/;
 SET TIMESTAMP=t/*!*/;
 CREATE DEFINER=`root`@`localhost` FUNCTION `test`.`mysqltestbug36570_f1`() RETURNS int(11)
     DETERMINISTIC

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-10-23 12:55:44 +0000
+++ b/sql/log_event.cc	2010-11-29 02:40:31 +0000
@@ -2899,7 +2899,7 @@ void Query_log_event::print_query_header
     different_db= memcmp(print_event_info->db, db, db_len + 1);
     if (different_db)
       memcpy(print_event_info->db, db, db_len + 1);
-    if (db[0] && different_db) 
+    if (db[0])
       my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
   }
 


Attachment: [text/bzr-bundle] bzr/dao-gang.qu@sun.com-20101129024031-dxr6ll4ih74rn7f0.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3521) Bug#50914Dao-Gang.Qu29 Nov