List:Commits« Previous MessageNext Message »
From:Martin Hansson Date:September 30 2009 7:31am
Subject:bzr commit into mysql-5.1-bugteam branch (martin.hansson:3141) Bug#35996
View as plain text  
#At file:///data0/martin/bzr/bug35996/5.1bt/ based on revid:martin.hansson@stripped

 3141 Martin Hansson	2009-09-30 [merge]
      Merge of Bug#35996

    added:
      mysql-test/std_data/binlog_transaction.000001
    modified:
      client/mysqlbinlog.cc
      libmysqld/lib_sql.cc
      mysql-test/include/concurrent.inc
      mysql-test/lib/mtr_cases.pm
      mysql-test/mysql-test-run.pl
      mysql-test/r/mysqlbinlog.result
      mysql-test/suite/binlog/r/binlog_killed_simulate.result
      mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
      mysql-test/suite/binlog/r/binlog_stm_blackhole.result
      mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
      mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
      mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
      mysql-test/suite/rpl/r/rpl_loaddata.result
      mysql-test/suite/rpl/r/rpl_loaddata_fatal.result
      mysql-test/suite/rpl/r/rpl_loaddata_map.result
      mysql-test/suite/rpl/r/rpl_loaddatalocal.result
      mysql-test/suite/rpl/r/rpl_stm_log.result
      mysql-test/suite/rpl/t/rpl_loaddatalocal.test
      mysql-test/t/mysqlbinlog.test
      sql/log_event.cc
      sql/log_event.h
      sql/sql_lex.h
      sql/sql_load.cc
      sql/sql_show.cc
      sql/sql_yacc.yy
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2009-07-13 19:11:16 +0000
+++ b/client/mysqlbinlog.cc	2009-09-30 02:31:25 +0000
@@ -726,7 +726,10 @@ Exit_status process_event(PRINT_EVENT_IN
 
     switch (ev_type) {
     case QUERY_EVENT:
-      if (shall_skip_database(((Query_log_event*)ev)->db))
+      if (strncmp(((Query_log_event*)ev)->query, "BEGIN", 5) && 
+          strncmp(((Query_log_event*)ev)->query, "COMMIT", 6) && 
+          strncmp(((Query_log_event*)ev)->query, "ROLLBACK", 8) &&  
+          shall_skip_database(((Query_log_event*)ev)->db))
         goto end;
       if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
       {

=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc	2009-07-29 20:07:08 +0000
+++ b/libmysqld/lib_sql.cc	2009-09-29 12:49:36 +0000
@@ -142,6 +142,8 @@ emb_advanced_command(MYSQL *mysql, enum 
   if (!skip_check)
     result= thd->is_error() ? -1 : 0;
 
+  thd->mysys_var= 0;
+
 #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
   thd->profiling.finish_current_query();
 #endif
@@ -634,6 +636,7 @@ void *create_embedded_thd(int client_fla
 
   thread_count++;
   threads.append(thd);
+  thd->mysys_var= 0;
   return thd;
 err:
   delete(thd);

=== modified file 'mysql-test/include/concurrent.inc'
--- a/mysql-test/include/concurrent.inc	2009-05-15 10:15:56 +0000
+++ b/mysql-test/include/concurrent.inc	2009-06-04 18:36:34 +0000
@@ -25,8 +25,6 @@
 #               new wrapper t/concurrent_innodb_safelog.test
 #
 
---source include/not_embedded.inc
-
 connection default;
 #
 # Show prerequisites for this test.

=== modified file 'mysql-test/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm	2009-09-23 12:12:12 +0000
+++ b/mysql-test/lib/mtr_cases.pm	2009-09-29 14:11:46 +0000
@@ -493,6 +493,7 @@ sub collect_one_suite($)
       $lib_innodb_plugin)
   {
     my @new_cases;
+    my $sep= (IS_WINDOWS) ? ';' : ':';
 
     foreach my $test (@cases)
     {
@@ -520,12 +521,13 @@ sub collect_one_suite($)
         }
       }
       my $plugin_filename= basename($lib_innodb_plugin);
+      my $plugin_list= "innodb=$plugin_filename" . $sep . "innodb_locks=$plugin_filename";
       push(@{$new_test->{master_opt}}, '--ignore-builtin-innodb');
       push(@{$new_test->{master_opt}}, '--plugin-dir=' . dirname($lib_innodb_plugin));
-      push(@{$new_test->{master_opt}}, "--plugin_load=innodb=$plugin_filename;innodb_locks=$plugin_filename");
+      push(@{$new_test->{master_opt}}, "--plugin_load=$plugin_list");
       push(@{$new_test->{slave_opt}}, '--ignore-builtin-innodb');
       push(@{$new_test->{slave_opt}}, '--plugin-dir=' . dirname($lib_innodb_plugin));
-      push(@{$new_test->{slave_opt}}, "--plugin_load=innodb=$plugin_filename;innodb_locks=$plugin_filename");
+      push(@{$new_test->{slave_opt}}, "--plugin_load=$plugin_list");
       if ($new_test->{combination})
       {
         $new_test->{combination}.= ' + InnoDB plugin';

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2009-09-02 21:29:11 +0000
+++ b/mysql-test/mysql-test-run.pl	2009-09-29 14:11:46 +0000
@@ -1812,7 +1812,7 @@ sub environment_setup {
       ($lib_example_plugin ? dirname($lib_example_plugin) : "");
 
     $ENV{'HA_EXAMPLE_SO'}="'".$plugin_filename."'";
-    $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=;EXAMPLE=".$plugin_filename.";";
+    $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=EXAMPLE=".$plugin_filename;
   }
 
   # ----------------------------------------------------

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2009-05-08 17:24:15 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2009-09-30 02:31:25 +0000
@@ -44,16 +44,16 @@ SET TIMESTAMP=1000000000/*!*/;
 insert into t2 values ()
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 DELIMITER ;
 # End of log file
@@ -144,16 +144,16 @@ SET TIMESTAMP=1000000000/*!*/;
 insert into t2 values ()
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 DELIMITER ;
 # End of log file
@@ -359,29 +359,29 @@ SET @@session.collation_database=DEFAULT
 create table t1 (a varchar(64) character set utf8)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.collation_database=7/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.collation_database=7/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.collation_database=DEFAULT/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO  table t1
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO  table t1 character set koi8r
+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)
 /*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 drop table t1
@@ -473,5 +473,94 @@ IS NOT NULL
 SET @@global.server_id= 1;
 RESET MASTER;
 FLUSH LOGS;
+RESET MASTER;
+FLUSH LOGS;
+#
+# Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is exist
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+use test/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+create table t1(a int) engine= innodb
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+insert into t1 (a) values (1)
+/*!*/;
+COMMIT/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+create table t3(a int) engine= innodb
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+insert into t3 (a) values (2)
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+ROLLBACK
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+create table t5(a int) engine= NDB
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+insert into t5 (a) values (3)
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+#
+# Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is not exist
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+BEGIN
+/*!*/;
+COMMIT/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+ROLLBACK
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=1253783037/*!*/;
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
 End of 5.0 tests
 End of 5.1 tests

=== added file 'mysql-test/std_data/binlog_transaction.000001'
Binary files a/mysql-test/std_data/binlog_transaction.000001	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/binlog_transaction.000001	2009-09-30 02:01:52 +0000 differ

=== modified file 'mysql-test/suite/binlog/r/binlog_killed_simulate.result'
--- a/mysql-test/suite/binlog/r/binlog_killed_simulate.result	2008-08-15 02:31:04 +0000
+++ b/mysql-test/suite/binlog/r/binlog_killed_simulate.result	2009-09-28 12:41:10 +0000
@@ -19,7 +19,7 @@ ERROR 70100: Query execution was interru
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=#
-master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile '../../std_data/rpl_loaddata.dat' into table t2 /* will be "killed" in the middle */ ;file_id=#
+master-bin.000001	#	Execute_load_query	#	#	use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t2` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (a, b) ;file_id=#
 select
 (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
 is not null;

=== modified file 'mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result'
--- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2009-08-26 23:13:03 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2009-09-28 12:41:10 +0000
@@ -917,7 +917,7 @@ master-bin.000001	#	User var	#	#	@`b`=_l
 master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=#
 master-bin.000001	#	Intvar	#	#	INSERT_ID=10
 master-bin.000001	#	User var	#	#	@`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
-master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2) ;file_id=#
+master-bin.000001	#	Execute_load_query	#	#	use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (a, @b) SET b=((@b) + `bug27417`(2)) ;file_id=#
 master-bin.000001	#	Query	#	#	ROLLBACK
 drop trigger trg_del_t2;
 drop table t1,t2,t3,t4,t5;

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_blackhole.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result	2009-05-31 05:44:41 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result	2009-09-28 12:41:10 +0000
@@ -127,7 +127,7 @@ master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	use `test`; create table t2 (a varchar(200)) engine=blackhole
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=581
-master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile '../../std_data/words.dat' into table t2 ;file_id=#
+master-bin.000001	#	Execute_load_query	#	#	use `test`; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE `t2` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (a) ;file_id=#
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	use `test`; alter table t1 add b int
 master-bin.000001	#	Query	#	#	use `test`; alter table t1 drop b

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result	2009-08-28 09:45:57 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result	2009-09-28 12:41:10 +0000
@@ -625,7 +625,7 @@ master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Intvar	#	#	INSERT_ID=10
 master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=#
 master-bin.000001	#	Intvar	#	#	INSERT_ID=10
-master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2) ;file_id=#
+master-bin.000001	#	Execute_load_query	#	#	use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (a, @b) SET b=((@b) + `bug27417`(2)) ;file_id=#
 master-bin.000001	#	Query	#	#	ROLLBACK
 /* the output must denote there is the query */;
 drop trigger trg_del_t2;
@@ -863,7 +863,7 @@ master-bin.000001	#	User var	#	#	@`b`=_l
 master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=#
 master-bin.000001	#	Intvar	#	#	INSERT_ID=10
 master-bin.000001	#	User var	#	#	@`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
-master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2) ;file_id=#
+master-bin.000001	#	Execute_load_query	#	#	use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (a, @b) SET b=((@b) + `bug27417`(2)) ;file_id=#
 master-bin.000001	#	Query	#	#	ROLLBACK
 drop trigger trg_del_t2;
 drop table t1,t2,t3,t4,t5;

=== modified file 'mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test'
--- a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test	2009-06-07 22:28:08 +0000
+++ b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test	2009-09-30 02:31:25 +0000
@@ -112,17 +112,22 @@ while($i)
   # remove unecessary files
   -- remove_file $outfile.1
   -- remove_file $outfile.2
-
+  
+  #
+  # The two tests are canceled since we introduced the patch of bug#46998,  
+  # which will make mydsqlbinlog output the 'BEGIN', 'COMMIT' and 'ROLLBACK' 
+  # in regardless of database filtering
+  #
   # assertion: events for database test are filtered
-  if (`SELECT INSTR(@b42941_output.1, 'test')`)
-  {
-    -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1).
-  }
-
-  if (`SELECT INSTR(@b42941_output.2, 'test')`)
-  {
-    -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2).
-  }
+  #if (`SELECT INSTR(@b42941_output.1, 'test')`)
+  #{
+    #-- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1).
+  #}
+
+  #if (`SELECT INSTR(@b42941_output.2, 'test')`)
+  #{
+    #-- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2).
+  #}
 
   # assertion: events for database b42941 are not filtered
   if (!`SELECT INSTR(@b42941_output.1, 'b42941')`)

=== modified file 'mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result'
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result	2009-08-29 08:52:22 +0000
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result	2009-09-28 12:41:10 +0000
@@ -885,7 +885,7 @@ master-bin.000001	#	Query	1	#	use `test_
 master-bin.000001	#	Xid	1	#	#
 master-bin.000001	#	Query	1	#	BEGIN
 master-bin.000001	#	Begin_load_query	1	#	;file_id=#;block_len=#
-master-bin.000001	#	Execute_load_query	1	#	use `test_rpl`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;file_id=#
+master-bin.000001	#	Execute_load_query	1	#	use `test_rpl`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/rpl_mixed.dat' INTO TABLE `t1` FIELDS TERMINATED BY '|' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (a, b) ;file_id=#
 master-bin.000001	#	Xid	1	#	#
 master-bin.000001	#	Query	1	#	BEGIN
 master-bin.000001	#	Query	1	#	use `test_rpl`; DELETE FROM t1

=== modified file 'mysql-test/suite/rpl/r/rpl_loaddata.result'
--- a/mysql-test/suite/rpl/r/rpl_loaddata.result	2008-11-13 19:19:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_loaddata.result	2009-09-28 12:41:10 +0000
@@ -36,7 +36,7 @@ set global sql_slave_skip_counter=1;
 start slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master	Master_SSL_Verify_Server_Cert	Last_IO_Errno	Last_IO_Error	Last_SQL_Errno	Last_SQL_Error
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	1797	#	#	master-bin.000001	Yes	Yes				#			0		0	1797	#	None		0	No						#	No	0		0	
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	2009	#	#	master-bin.000001	Yes	Yes				#			0		0	2009	#	None		0	No						#	No	0		0	
 set sql_log_bin=0;
 delete from t1;
 set sql_log_bin=1;
@@ -46,7 +46,7 @@ change master to master_user='test';
 change master to master_user='root';
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master	Master_SSL_Verify_Server_Cert	Last_IO_Errno	Last_IO_Error	Last_SQL_Errno	Last_SQL_Error
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	1832	#	#	master-bin.000001	No	No				#			0		0	1832	#	None		0	No						#	No	0		0	
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	2044	#	#	master-bin.000001	No	No				#			0		0	2044	#	None		0	No						#	No	0		0	
 set global sql_slave_skip_counter=1;
 start slave;
 set sql_log_bin=0;

=== modified file 'mysql-test/suite/rpl/r/rpl_loaddata_fatal.result'
--- a/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result	2007-12-12 17:19:24 +0000
+++ b/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result	2009-09-28 12:41:10 +0000
@@ -53,7 +53,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	465
+Read_Master_Log_Pos	556
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001

=== modified file 'mysql-test/suite/rpl/r/rpl_loaddata_map.result'
--- a/mysql-test/suite/rpl/r/rpl_loaddata_map.result	2008-07-18 11:34:19 +0000
+++ b/mysql-test/suite/rpl/r/rpl_loaddata_map.result	2009-09-28 12:41:10 +0000
@@ -20,7 +20,7 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=#
 master-bin.000001	#	Append_block	#	#	;file_id=#;block_len=#
 master-bin.000001	#	Append_block	#	#	;file_id=#;block_len=#
-master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile 'MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2 ;file_id=#
+master-bin.000001	#	Execute_load_query	#	#	use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' INTO TABLE `t2` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (id) ;file_id=#
 ==== Verify results on slave ====
 [on slave]
 select count(*) from t2 /* 5 000 */;

=== modified file 'mysql-test/suite/rpl/r/rpl_loaddatalocal.result'
--- a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result	2009-03-16 08:21:29 +0000
+++ b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result	2009-09-28 12:41:10 +0000
@@ -54,3 +54,31 @@ a
 [on master]
 DROP TABLE t1;
 [on slave]
+
+Bug #43746:
+"return wrong query string when parse 'load data infile' sql statement"
+
+[master]
+SELECT @@SESSION.sql_mode INTO @old_mode;
+SET sql_mode='ignore_space';
+CREATE TABLE t1(a int);
+INSERT INTO t1 VALUES (1), (2), (3), (4);
+SELECT * INTO OUTFILE 'MYSQLD_DATADIR/bug43746.sql' FROM t1;
+TRUNCATE TABLE t1;
+LOAD DATA LOCAL INFILE 'MYSQLD_DATADIR/bug43746.sql' INTO TABLE t1;
+LOAD/* look mum, with comments in weird places! */DATA/* oh hai */LOCAL INFILE 'MYSQLD_DATADIR/bug43746.sql'/* we are */INTO/* from the internets */TABLE t1;
+LOAD DATA/*!10000 LOCAL */INFILE 'MYSQLD_DATADIR/bug43746.sql' INTO TABLE t1;
+LOAD DATA LOCAL INFILE 'MYSQLD_DATADIR/bug43746.sql' /*!10000 INTO */ TABLE t1;
+LOAD DATA LOCAL INFILE 'MYSQLD_DATADIR/bug43746.sql' /*!10000 INTO TABLE */ t1;
+LOAD DATA /*!10000 LOCAL INFILE 'MYSQLD_DATADIR/bug43746.sql' INTO TABLE */ t1;
+LOAD DATA/*!10000 LOCAL */INFILE 'MYSQLD_DATADIR/bug43746.sql'/*!10000 INTO*/TABLE t1;
+LOAD DATA/*!10000 LOCAL */INFILE 'MYSQLD_DATADIR/bug43746.sql'/* empty */INTO TABLE t1;
+LOAD DATA/*!10000 LOCAL */INFILE 'MYSQLD_DATADIR/bug43746.sql' INTO/* empty */TABLE t1;
+LOAD/*!99999 special comments that do not expand */DATA/*!99999 code from the future */LOCAL INFILE 'MYSQLD_DATADIR/bug43746.sql'/*!99999 have flux capacitor */INTO/*!99999 will travel */TABLE t1;
+SET sql_mode='PIPES_AS_CONCAT,ANSI_QUOTES,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER';
+LOAD DATA LOCAL INFILE 'MYSQLD_DATADIR/bug43746.sql' INTO TABLE t1;
+[slave]
+[master]
+DROP TABLE t1;
+SET SESSION sql_mode=@old_mode;
+[slave]

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_log.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_log.result	2009-03-16 08:21:29 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_log.result	2009-09-28 12:41:10 +0000
@@ -25,7 +25,7 @@ master-bin.000001	#	Query	1	#	use `test`
 master-bin.000001	#	Query	1	#	use `test`; drop table t1
 master-bin.000001	#	Query	1	#	use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
 master-bin.000001	#	Begin_load_query	1	#	;file_id=1;block_len=581
-master-bin.000001	#	Execute_load_query	1	#	use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1
+master-bin.000001	#	Execute_load_query	1	#	use `test`; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' IGNORE 1 LINES  (word) ;file_id=1
 show binlog events from 106 limit 1;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	1	#	use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
@@ -193,7 +193,7 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	use `test`; drop table t1
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
 master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=#
-master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=#
+master-bin.000001	#	Execute_load_query	#	#	use `test`; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' IGNORE 1 LINES  (word) ;file_id=#
 master-bin.000001	#	Rotate	#	#	master-bin.000002;pos=4
 show binlog events in 'master-bin.000002';
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
@@ -218,7 +218,7 @@ slave-bin.000001	#	Query	1	#	use `test`;
 slave-bin.000001	#	Query	1	#	use `test`; drop table t1
 slave-bin.000001	#	Query	1	#	use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
 slave-bin.000001	#	Begin_load_query	1	#	;file_id=1;block_len=581
-slave-bin.000001	#	Execute_load_query	1	#	use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO  table t1 ignore 1 lines ;file_id=1
+slave-bin.000001	#	Execute_load_query	1	#	use `test`; LOAD DATA INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' IGNORE 1 LINES  (word) ;file_id=1
 slave-bin.000001	#	Query	1	#	use `test`; create table t3 (a int)ENGINE=MyISAM
 slave-bin.000001	#	Rotate	2	#	slave-bin.000002;pos=4
 show binlog events in 'slave-bin.000002' from 4;

=== modified file 'mysql-test/suite/rpl/t/rpl_loaddatalocal.test'
--- a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test	2009-03-16 08:21:29 +0000
+++ b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test	2009-09-28 12:41:10 +0000
@@ -98,3 +98,73 @@ DROP TABLE t1;
 --echo [on slave]
 sync_slave_with_master;
 
+--echo
+--echo Bug #43746:
+--echo "return wrong query string when parse 'load data infile' sql statement"
+--echo
+
+--echo [master]
+connection master;
+let $MYSQLD_DATADIR= `select @@datadir`;
+SELECT @@SESSION.sql_mode INTO @old_mode;
+
+SET sql_mode='ignore_space';
+
+CREATE TABLE t1(a int);
+INSERT INTO t1 VALUES (1), (2), (3), (4);
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval SELECT * INTO OUTFILE '$MYSQLD_DATADIR/bug43746.sql' FROM t1;
+TRUNCATE TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/bug43746.sql' INTO TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD/* look mum, with comments in weird places! */DATA/* oh hai */LOCAL INFILE '$MYSQLD_DATADIR/bug43746.sql'/* we are */INTO/* from the internets */TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA/*!10000 LOCAL */INFILE '$MYSQLD_DATADIR/bug43746.sql' INTO TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/bug43746.sql' /*!10000 INTO */ TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/bug43746.sql' /*!10000 INTO TABLE */ t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA /*!10000 LOCAL INFILE '$MYSQLD_DATADIR/bug43746.sql' INTO TABLE */ t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA/*!10000 LOCAL */INFILE '$MYSQLD_DATADIR/bug43746.sql'/*!10000 INTO*/TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA/*!10000 LOCAL */INFILE '$MYSQLD_DATADIR/bug43746.sql'/* empty */INTO TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA/*!10000 LOCAL */INFILE '$MYSQLD_DATADIR/bug43746.sql' INTO/* empty */TABLE t1;
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD/*!99999 special comments that do not expand */DATA/*!99999 code from the future */LOCAL INFILE '$MYSQLD_DATADIR/bug43746.sql'/*!99999 have flux capacitor */INTO/*!99999 will travel */TABLE t1;
+
+SET sql_mode='PIPES_AS_CONCAT,ANSI_QUOTES,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER';
+
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/bug43746.sql' INTO TABLE t1;
+
+--echo [slave]
+sync_slave_with_master;
+
+# cleanup
+
+--remove_file $MYSQLD_DATADIR/bug43746.sql
+
+--echo [master]
+connection master;
+DROP TABLE t1;
+SET SESSION sql_mode=@old_mode;
+
+--echo [slave]
+sync_slave_with_master;
+
+connection master;

=== modified file 'mysql-test/t/mysqlbinlog.test'
--- a/mysql-test/t/mysqlbinlog.test	2009-05-08 17:24:15 +0000
+++ b/mysql-test/t/mysqlbinlog.test	2009-09-30 02:31:25 +0000
@@ -71,7 +71,8 @@ select "--- --position --" as "";
 --enable_query_log
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=239 $MYSQLD_DATADIR/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=330 $MYSQLD_DATADIR/master-bin.000002
+
 
 # These are tests for remote binlog.
 # They should return the same as previous test.
@@ -107,7 +108,7 @@ select "--- --position --" as "";
 --enable_query_log
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=239 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=330 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
 
 # Bug#7853 mysqlbinlog does not accept input from stdin
 --disable_query_log
@@ -377,6 +378,68 @@ FLUSH LOGS;
 # We do not need the results, just make sure that mysqlbinlog does not crash
 --exec $MYSQL_BINLOG --hexdump --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT  master-bin.000001 >/dev/null
 
+#
+# #46998
+# This test verifies if the 'BEGIN', 'COMMIT' and 'ROLLBACK' are output 
+# in regardless of database filtering
+#
+
+RESET MASTER;
+FLUSH LOGS;
+
+# The following three test cases were wrtten into binlog_transaction.000001
+# Test case1: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database 
+# in transaction1 base on innodb engine tables
+# use test;
+# create table t1(a int) engine= innodb;
+# use mysql;
+# create table t2(a int) engine= innodb;
+# Transaction1 begin
+# begin;
+# use test;
+# insert into t1 (a) values (1);
+# use mysql;
+# insert into t2 (a) values (1);
+# commit;
+# Transaction1 end
+
+# Test case2: Test if the 'BEGIN' and 'ROLLBACK' are output for the 'test' database 
+# in transaction2 base on innodb and myisam engine tables
+# use test;
+# create table t3(a int) engine= innodb;
+# use mysql;
+# create table t4(a int) engine= myisam;
+# Transaction2 begin
+# begin;
+# use test;
+# insert into t3 (a) values (2);
+# use mysql;
+# insert into t4 (a) values (2);
+# rollback;
+# Transaction2 end
+
+# Test case3: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database 
+# in transaction3 base on NDB engine tables
+# use test;
+# create table t5(a int) engine= NDB;
+# use mysql;
+# create table t6(a int) engine= NDB;
+# Transaction3 begin
+# begin;
+# use test;
+# insert into t5 (a) values (3);
+# use mysql;
+# insert into t6 (a) values (3);
+# commit;
+# Transaction3 end
+
+--echo #
+--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is exist
+--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
+--echo #
+--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is not exist
+--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
+
 --echo End of 5.0 tests
 
 --echo End of 5.1 tests

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2009-09-27 21:02:47 +0000
+++ b/sql/log_event.cc	2009-09-29 13:08:18 +0000
@@ -4010,7 +4010,7 @@ uint Load_log_event::get_query_buffer_le
 }
 
 
-void Load_log_event::print_query(bool need_db, char *buf,
+void Load_log_event::print_query(bool need_db, const char *cs, char *buf,
                                  char **end, char **fn_start, char **fn_end)
 {
   char *pos= buf;
@@ -4034,9 +4034,9 @@ void Load_log_event::print_query(bool ne
   pos= strmov(pos+fname_len, "' ");
 
   if (sql_ex.opt_flags & REPLACE_FLAG)
-    pos= strmov(pos, " REPLACE ");
+    pos= strmov(pos, "REPLACE ");
   else if (sql_ex.opt_flags & IGNORE_FLAG)
-    pos= strmov(pos, " IGNORE ");
+    pos= strmov(pos, "IGNORE ");
 
   pos= strmov(pos ,"INTO");
 
@@ -4047,8 +4047,16 @@ void Load_log_event::print_query(bool ne
   memcpy(pos, table_name, table_name_len);
   pos+= table_name_len;
 
-  /* We have to create all optinal fields as the default is not empty */
-  pos= strmov(pos, "` FIELDS TERMINATED BY ");
+  if (cs != NULL)
+  {
+    pos= strmov(pos ,"` CHARACTER SET ");
+    pos= strmov(pos ,  cs);
+  }
+  else
+    pos= strmov(pos, "`");
+
+  /* We have to create all optional fields as the default is not empty */
+  pos= strmov(pos, " FIELDS TERMINATED BY ");
   pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len);
   if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
     pos= strmov(pos, " OPTIONALLY ");
@@ -4102,7 +4110,7 @@ void Load_log_event::pack_info(Protocol 
 
   if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME))))
     return;
-  print_query(TRUE, buf, &end, 0, 0);
+  print_query(TRUE, NULL, buf, &end, 0, 0);
   protocol->store(buf, end-buf, &my_charset_bin);
   my_free(buf, MYF(0));
 }
@@ -4367,9 +4375,9 @@ void Load_log_event::print(FILE* file_ar
   my_b_printf(&cache, "INFILE '%-*s' ", fname_len, fname);
 
   if (sql_ex.opt_flags & REPLACE_FLAG)
-    my_b_printf(&cache," REPLACE ");
+    my_b_printf(&cache,"REPLACE ");
   else if (sql_ex.opt_flags & IGNORE_FLAG)
-    my_b_printf(&cache," IGNORE ");
+    my_b_printf(&cache,"IGNORE ");
   
   my_b_printf(&cache, "INTO TABLE `%s`", table_name);
   my_b_printf(&cache, " FIELDS TERMINATED BY ");
@@ -4577,8 +4585,7 @@ int Load_log_event::do_apply_event(NET* 
         goto error;
       }
 
-      print_query(FALSE, load_data_query, &end, (char **)&thd->lex->fname_start,
-                  (char **)&thd->lex->fname_end);
+      print_query(FALSE, NULL, load_data_query, &end, NULL, NULL);
       *end= 0;
       thd->set_query(load_data_query, (uint) (end - load_data_query));
 
@@ -6732,7 +6739,7 @@ void Execute_load_query_log_event::print
     my_b_printf(&cache, "\'");
     if (dup_handling == LOAD_DUP_REPLACE)
       my_b_printf(&cache, " REPLACE");
-    my_b_printf(&cache, " INTO ");
+    my_b_printf(&cache, " INTO");
     my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end);
     my_b_printf(&cache, "\n%s\n", print_event_info->delimiter);
   }

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2009-06-30 18:40:38 +0000
+++ b/sql/log_event.h	2009-09-28 12:41:10 +0000
@@ -1960,15 +1960,15 @@ private:
 class Load_log_event: public Log_event
 {
 private:
-  uint get_query_buffer_length();
-  void print_query(bool need_db, char *buf, char **end,
-                   char **fn_start, char **fn_end);
 protected:
   int copy_log_event(const char *buf, ulong event_len,
                      int body_offset,
                      const Format_description_log_event* description_event);
 
 public:
+  uint get_query_buffer_length();
+  void print_query(bool need_db, const char *cs, char *buf, char **end,
+                   char **fn_start, char **fn_end);
   ulong thread_id;
   ulong slave_proxy_id;
   uint32 table_name_len;

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2009-08-10 18:46:20 +0000
+++ b/sql/sql_lex.h	2009-09-28 12:41:10 +0000
@@ -1735,13 +1735,6 @@ typedef struct st_lex : public Query_tab
 
   const char *stmt_definition_end;
 
-  /*
-    Pointers to part of LOAD DATA statement that should be rewritten
-    during replication ("LOCAL 'filename' REPLACE INTO" part).
-  */
-  const char *fname_start;
-  const char *fname_end;
-  
   /**
     During name resolution search only in the table list given by 
     Name_resolution_context::first_name_resolution_table and

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2009-07-31 17:14:52 +0000
+++ b/sql/sql_load.cc	2009-09-28 12:41:10 +0000
@@ -83,10 +83,13 @@ static int read_sep_field(THD *thd, COPY
 			  String &enclosed, ulong skip_lines,
 			  bool ignore_check_option_errors);
 #ifndef EMBEDDED_LIBRARY
-static bool write_execute_load_query_log_event(THD *thd,
-					       bool duplicates, bool ignore,
-					       bool transactional_table,
-                                               int errcode);
+static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
+                                               const char* db_arg,
+                                               const char* table_name_arg,
+                                               enum enum_duplicates duplicates,
+                                               bool ignore,
+                                               bool transactional_table,
+                                               int errocode);
 #endif /* EMBEDDED_LIBRARY */
 
 /*
@@ -497,8 +500,10 @@ int mysql_load(THD *thd,sql_exchange *ex
           int errcode= query_error_code(thd, killed_status == THD::NOT_KILLED);
           
 	  if (thd->transaction.stmt.modified_non_trans_table)
-	    write_execute_load_query_log_event(thd, handle_duplicates,
-					       ignore, transactional_table,
+            write_execute_load_query_log_event(thd, ex,
+                                               tdb, table_list->table_name,
+                                               handle_duplicates, ignore,
+                                               transactional_table,
                                                errcode);
 	  else
 	  {
@@ -542,8 +547,11 @@ int mysql_load(THD *thd,sql_exchange *ex
       if (lf_info.wrote_create_file)
       {
         int errcode= query_error_code(thd, killed_status == THD::NOT_KILLED);
-        write_execute_load_query_log_event(thd, handle_duplicates, ignore,
-                                           transactional_table, errcode);
+        write_execute_load_query_log_event(thd, ex,
+                                           tdb, table_list->table_name,
+                                           handle_duplicates, ignore,
+                                           transactional_table,
+                                           errcode);
       }
     }
   }
@@ -564,15 +572,95 @@ err:
 #ifndef EMBEDDED_LIBRARY
 
 /* Not a very useful function; just to avoid duplication of code */
-static bool write_execute_load_query_log_event(THD *thd,
-					       bool duplicates, bool ignore,
-					       bool transactional_table,
+static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
+                                               const char* db_arg,
+                                               const char* table_name_arg,
+                                               enum enum_duplicates duplicates,
+                                               bool ignore,
+                                               bool transactional_table,
                                                int errcode)
 {
+  char                *load_data_query,
+                      *end,
+                      *fname_start,
+                      *fname_end,
+                      *p= NULL;
+  size_t               pl= 0;
+  List<Item>           fv;
+  Item                *item, *val;
+  String               pfield, pfields;
+  int                  n;
+
+  Load_log_event       lle(thd, ex, db_arg, table_name_arg, fv, duplicates,
+                           ignore, transactional_table);
+
+  /*
+    force in a LOCAL if there was one in the original.
+  */
+  if (thd->lex->local_file)
+    lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
+
+  /*
+    prepare fields-list and SET if needed; print_query won't do that for us.
+  */
+  if (!thd->lex->field_list.is_empty())
+  {
+    List_iterator<Item>  li(thd->lex->field_list);
+
+    pfields.append(" (");
+    n= 0;
+
+    while ((item= li++))
+    {
+      if (n++)
+        pfields.append(", ");
+      if (item->name)
+        pfields.append(item->name);
+      else
+        item->print(&pfields, QT_ORDINARY);
+    }
+    pfields.append(")");
+  }
+
+  if (!thd->lex->update_list.is_empty())
+  {
+    List_iterator<Item> lu(thd->lex->update_list);
+    List_iterator<Item> lv(thd->lex->value_list);
+
+    pfields.append(" SET ");
+    n= 0;
+
+    while ((item= lu++))
+    {
+      val= lv++;
+      if (n++)
+        pfields.append(", ");
+      pfields.append(item->name);
+      pfields.append("=");
+      val->print(&pfields, QT_ORDINARY);
+    }
+  }
+
+  p= pfields.c_ptr_safe();
+  pl= strlen(p);
+
+  if (!(load_data_query= (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl)))
+    return TRUE;
+
+  lle.print_query(FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
+                  load_data_query, &end,
+                  (char **)&fname_start, (char **)&fname_end);
+
+  strcpy(end, p);
+  end += pl;
+
+  thd->query_length= end - load_data_query;
+  thd->query= load_data_query;
+
   Execute_load_query_log_event
     e(thd, thd->query, thd->query_length,
-      (uint) ((char*)thd->lex->fname_start - (char*)thd->query),
-      (uint) ((char*)thd->lex->fname_end - (char*)thd->query),
+      (uint) ((char*)fname_start - (char*)thd->query - 1),
+      (uint) ((char*)fname_end - (char*)thd->query),
       (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
       (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
       transactional_table, FALSE, errcode);

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2009-09-28 11:25:47 +0000
+++ b/sql/sql_show.cc	2009-09-30 07:31:20 +0000
@@ -1980,7 +1980,7 @@ int fill_schema_processlist(THD* thd, TA
                     tmp->mysys_var->current_cond ?
                     "Waiting on cond" : NullS);
 #else
-      val= (char *) "Writing to net";
+      val= (char *) (tmp->proc_info ? tmp->proc_info : NullS);
 #endif
       if (val)
       {

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2009-09-07 09:57:22 +0000
+++ b/sql/sql_yacc.yy	2009-09-29 16:09:17 +0000
@@ -10425,14 +10425,12 @@ load:
           {
             THD *thd= YYTHD;
             LEX *lex= thd->lex;
-            Lex_input_stream *lip= YYLIP;
 
             if (lex->sphead)
             {
               my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD DATA");
               MYSQL_YYABORT;
             }
-            lex->fname_start= lip->get_ptr();
           }
           load_data
           {}
@@ -10464,14 +10462,10 @@ load_data:
             if (!(lex->exchange= new sql_exchange($4.str, 0)))
               MYSQL_YYABORT;
           }
-          opt_duplicate INTO
-          {
-            Lex->fname_end= YYLIP->get_ptr();
-          }
-          TABLE_SYM table_ident
+          opt_duplicate INTO TABLE_SYM table_ident
           {
             LEX *lex=Lex;
-            if (!Select->add_table_to_list(YYTHD, $10, NULL, TL_OPTION_UPDATING,
+            if (!Select->add_table_to_list(YYTHD, $9, NULL, TL_OPTION_UPDATING,
                                            lex->lock_option))
               MYSQL_YYABORT;
             lex->field_list.empty();
@@ -10479,7 +10473,7 @@ load_data:
             lex->value_list.empty();
           }
           opt_load_data_charset
-          { Lex->exchange->cs= $12; }
+          { Lex->exchange->cs= $11; }
           opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
           opt_load_data_set_spec
           {}


Attachment: [text/bzr-bundle] bzr/martin.hansson@sun.com-20090930073120-uzskc5v782if7rk0.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (martin.hansson:3141) Bug#35996Martin Hansson30 Sep