List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:August 25 2008 11:00am
Subject:bzr push into mysql-6.0 branch (mats:2704 to 2706)
View as plain text  
 2706 Mats Kindahl	2008-08-25 [merge]
      Merging 5.1-rpl --> 6.0-rpl
modified:
  include/my_global.h
  sql/log.cc
  sql/sql_class.cc
  sql/sql_class.h

 2705 Mats Kindahl	2008-08-25 [merge]
      Merge 5.1-rpl --> 6.0-rpl
modified:
  mysql-test/extra/binlog_tests/database.test
  mysql-test/suite/binlog/r/binlog_database.result
  mysql-test/suite/rpl/r/rpl_row_create_table.result
  mysql-test/suite/rpl/t/rpl_row_create_table.test
  sql/handler.cc
  sql/log.cc
  sql/si_objects.cc
  sql/sql_class.cc
  sql/sql_class.h
  sql/sql_db.cc
  sql/sql_insert.cc
  sql/sql_parse.cc
  sql/sql_show.cc
  sql/sql_show.h
  sql/sql_table.cc

 2704 Sven Sandberg	2008-08-22 [merge]
      Merged (merge of 5.1-rpl -> 6.0-rpl) with development in 6.0-rpl
removed:
  mysql-test/include/multi_range_count_basic.inc
  mysql-test/include/wait_timeout_basic.inc
  mysql-test/r/multi_range_count_basic_32.result
  mysql-test/r/multi_range_count_basic_64.result
  mysql-test/suite/rpl/t/rpl_row_err_daisychain-master.opt
  mysql-test/suite/rpl/t/rpl_row_err_daisychain-slave.opt
  mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb_2-master.opt
  mysql-test/t/innodb_bug35220.test
  mysql-test/t/multi_range_count_basic_32.test
  mysql-test/t/multi_range_count_basic_64.test
added:
  mysql-test/include/analyze-timeout.test
  mysql-test/r/innodb-autoinc-optimize.result
  mysql-test/suite/sys_vars/inc/multi_range_count_basic.inc
  mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result
  mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result
  mysql-test/suite/sys_vars/t/multi_range_count_basic_32.test
  mysql-test/suite/sys_vars/t/multi_range_count_basic_64.test
  mysql-test/t/innodb-autoinc-optimize.test
  mysql-test/t/innodb_bug35220.test
renamed:
  mysql-test/lib/mtr_unique.pl => mysql-test/lib/mtr_unique.pm
  mysql-test/suite/sys_vars/r/rpl_sync_binlog_basic_64.result.OTHER => mysql-test/suite/sys_vars/r/rpl_sync_binlog_basic_64.result
modified:
  client/Makefile.am
  client/mysql_upgrade.c
  client/mysqltest.cc
  config/ac-macros/character_sets.m4
  mysql-test/Makefile.am
  mysql-test/extra/binlog_tests/binlog_insert_delayed.test
  mysql-test/include/check-warnings.test
  mysql-test/include/mtr_warnings.sql
  mysql-test/include/restart_mysqld.inc
  mysql-test/include/show_binlog_events.inc
  mysql-test/lib/My/Platform.pm
  mysql-test/lib/My/SafeProcess.pm
  mysql-test/lib/mtr_io.pl
  mysql-test/mysql-test-run.pl
  mysql-test/r/func_if.result
  mysql-test/r/subselect.result
  mysql-test/r/subselect_no_mat.result
  mysql-test/r/subselect_no_opts.result
  mysql-test/r/subselect_no_semijoin.result
  mysql-test/suite/binlog/r/binlog_killed_simulate.result
  mysql-test/suite/binlog/r/binlog_row_binlog.result
  mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
  mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result
  mysql-test/suite/binlog/r/binlog_stm_binlog.result
  mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
  mysql-test/suite/funcs_1/triggers/triggers_03.inc
  mysql-test/suite/funcs_1/triggers/triggers_08.inc
  mysql-test/suite/funcs_1/triggers/triggers_1011ext.inc
  mysql-test/suite/rpl/r/rpl_loaddata_map.result
  mysql-test/suite/rpl/r/rpl_stm_log.result
  mysql-test/suite/rpl/r/rpl_variables.result
  mysql-test/suite/rpl/t/disabled.def
  mysql-test/suite/rpl/t/rpl_incident.test
  mysql-test/suite/rpl/t/rpl_loaddata_map.test
  mysql-test/suite/rpl/t/rpl_trunc_temp.test
  mysql-test/suite/rpl/t/rpl_variables.test
  mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_2ch.test
  mysql-test/suite/rpl_ndb_big/t/rpl_ndb_mixed_engines_transactions.test
  mysql-test/t/disabled.def
  mysql-test/t/func_if.test
  mysql-test/t/subselect.test
  sql/field.h
  sql/item.cc
  sql/item.h
  sql/item_cmpfunc.cc
  sql/item_func.cc
  sql/mysql_priv.h
  sql/share/errmsg.txt
  sql/sp_head.cc
  sql/sql_acl.cc
  sql/sql_base.cc
  sql/sql_lex.h
  sql/sql_list.h
  sql/sql_parse.cc
  sql/sql_select.cc
  sql/sql_string.h
  sql/table.cc
  sql/table.h
  support-files/build-tags
  tests/mysql_client_test.c
  mysql-test/lib/mtr_unique.pm

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2008-07-22 14:16:22 +0000
+++ b/include/my_global.h	2008-08-25 11:00:00 +0000
@@ -1163,6 +1163,9 @@ typedef char		bool;	/* Ordinary boolean 
 #define dbug_volatile
 #endif
 
+/* Some helper macros */
+#define YESNO(X) ((X) ? "yes" : "no")
+
 /* Defines for time function */
 #define SCALE_SEC	100
 #define SCALE_USEC	10000

=== modified file 'mysql-test/extra/binlog_tests/database.test'
--- a/mysql-test/extra/binlog_tests/database.test	2007-11-16 14:55:22 +0000
+++ b/mysql-test/extra/binlog_tests/database.test	2008-08-20 08:06:50 +0000
@@ -13,3 +13,18 @@ create trigger tr1 before insert on t1 f
 create procedure sp1 (a int) insert into t1 values(a);
 drop database testing_1;
 source include/show_binlog_events.inc;
+
+# BUG#38773: DROP DATABASE cause switch to stmt-mode when there are
+# temporary tables open
+
+use test;
+reset master;
+create temporary table tt1 (a int);
+create table t1 (a int);
+insert into t1 values (1);
+disable_warnings;
+drop database if exists mysqltest1;
+enable_warnings;
+insert into t1 values (1);
+drop table tt1, t1;
+source include/show_binlog_events.inc;

=== modified file 'mysql-test/suite/binlog/r/binlog_database.result'
--- a/mysql-test/suite/binlog/r/binlog_database.result	2008-08-04 14:30:50 +0000
+++ b/mysql-test/suite/binlog/r/binlog_database.result	2008-08-25 10:16:09 +0000
@@ -17,6 +17,22 @@ master-bin.000001	#	Query	#	#	use `testi
 master-bin.000001	#	Query	#	#	use `testing_1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `sp1`(a int)
 insert into t1 values(a)
 master-bin.000001	#	Query	#	#	drop database testing_1
+use test;
+reset master;
+create temporary table tt1 (a int);
+create table t1 (a int);
+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>;
+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)
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1)
+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
 set binlog_format=mixed;
 reset master;
 create database testing_1;
@@ -36,6 +52,22 @@ master-bin.000001	#	Query	#	#	use `testi
 master-bin.000001	#	Query	#	#	use `testing_1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `sp1`(a int)
 insert into t1 values(a)
 master-bin.000001	#	Query	#	#	drop database testing_1
+use test;
+reset master;
+create temporary table tt1 (a int);
+create table t1 (a int);
+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>;
+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)
+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1)
+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
 set binlog_format=row;
 reset master;
 create database testing_1;
@@ -55,6 +87,27 @@ master-bin.000001	#	Query	#	#	use `testi
 master-bin.000001	#	Query	#	#	use `testing_1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `sp1`(a int)
 insert into t1 values(a)
 master-bin.000001	#	Query	#	#	drop database testing_1
+use test;
+reset master;
+create temporary table tt1 (a int);
+create table t1 (a int);
+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>;
+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	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
 show databases;
 Database
 information_schema

=== modified file 'mysql-test/suite/rpl/r/rpl_row_create_table.result'
--- a/mysql-test/suite/rpl/r/rpl_row_create_table.result	2008-06-10 22:27:52 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result	2008-08-25 10:16:09 +0000
@@ -430,4 +430,25 @@ a
 1
 2
 DROP TABLE t1;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE DATABASE mysqltest1;
+CREATE TABLE mysqltest1.without_select (f1 BIGINT);
+CREATE TABLE mysqltest1.with_select AS SELECT 1 AS f1;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	CREATE DATABASE mysqltest1
+master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE mysqltest1.without_select (f1 BIGINT)
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE `mysqltest1`.`with_select` (
+  `f1` int(1) NOT NULL DEFAULT '0'
+)
+master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.with_select)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+DROP DATABASE mysqltest1;
 end of the tests

=== modified file 'mysql-test/suite/rpl/t/rpl_row_create_table.test'
--- a/mysql-test/suite/rpl/t/rpl_row_create_table.test	2008-06-22 20:05:19 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test	2008-08-25 10:16:09 +0000
@@ -267,5 +267,22 @@ connection master;
 DROP TABLE t1;
 sync_slave_with_master;
 
+#
+# BUG#34707: Row based replication: slave creates table within wrong database
+#
+
+source include/master-slave-reset.inc;
+
+connection master;
+CREATE DATABASE mysqltest1;
+
+CREATE TABLE mysqltest1.without_select (f1 BIGINT);
+CREATE TABLE mysqltest1.with_select AS SELECT 1 AS f1;
+source include/show_binlog_events.inc;
+sync_slave_with_master;
+
+connection master;
+DROP DATABASE mysqltest1;
+sync_slave_with_master;
 
 --echo end of the tests

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2008-08-05 11:20:20 +0000
+++ b/sql/handler.cc	2008-08-25 10:16:09 +0000
@@ -5199,6 +5199,8 @@ static int write_locked_table_maps(THD *
   DBUG_PRINT("enter", ("thd: %p  thd->lock: %p thd->extra_lock: %p",
                        thd, thd->lock, thd->extra_lock));
 
+  DBUG_PRINT("debug", ("get_binlog_table_maps(): %d", thd->get_binlog_table_maps()));
+
   if (thd->get_binlog_table_maps() == 0)
   {
     MYSQL_LOCK *locks[2];

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2008-08-05 11:20:20 +0000
+++ b/sql/log.cc	2008-08-25 11:00:00 +0000
@@ -1392,6 +1392,8 @@ binlog_end_trans(THD *thd, binlog_trx_da
                       FLAGSTR(thd->options, OPTION_NOT_AUTOCOMMIT),
                       FLAGSTR(thd->options, OPTION_BEGIN)));
 
+  thd->binlog_flush_pending_rows_event(TRUE);
+
   /*
     NULL denotes ROLLBACK with nothing to replicate: i.e., rollback of
     only transactional tables.  If the transaction contain changes to
@@ -1410,8 +1412,6 @@ binlog_end_trans(THD *thd, binlog_trx_da
       were, we would have to ensure that we're not ending a statement
       inside a stored function.
      */
-    thd->binlog_flush_pending_rows_event(TRUE);
-
     error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev);
     trx_data->reset();
 
@@ -1468,8 +1468,6 @@ static int binlog_prepare(handlerton *ht
   return 0;
 }
 
-#define YESNO(X) ((X) ? "yes" : "no")
-
 /**
   This function is called once after each statement.
 

=== modified file 'sql/si_objects.cc'
--- a/sql/si_objects.cc	2008-07-28 20:48:30 +0000
+++ b/sql/si_objects.cc	2008-08-25 10:16:09 +0000
@@ -1809,7 +1809,7 @@ bool TableObj::do_serialize(THD *thd, St
   */
   ret= m_table_is_view ?
     view_store_create_info(thd, table_list, serialization) :
-    store_create_info(thd, table_list, serialization, NULL);
+    store_create_info(thd, table_list, serialization, NULL, FALSE);
   close_thread_tables(thd);
   serialization->set_charset(system_charset_info);
   thd->lex->select_lex.table_list.empty();

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2008-08-07 20:51:09 +0000
+++ b/sql/sql_class.cc	2008-08-25 11:00:00 +0000
@@ -3554,6 +3554,26 @@ int THD::binlog_flush_pending_rows_event
 }
 
 
+#ifndef DBUG_OFF
+static const char *
+show_query_type(THD::enum_binlog_query_type qtype)
+{
+  switch (qtype) {
+    static char buf[64];
+  case THD::ROW_QUERY_TYPE:
+    return "ROW";
+  case THD::STMT_QUERY_TYPE:
+    return "STMT";
+  case THD::MYSQL_QUERY_TYPE:
+    return "MYSQL";
+  default:
+    sprintf(buf, "UNKNOWN#%d", qtype);
+    return buf;
+  }
+}
+#endif
+
+
 /*
   Member function that will log query, either row-based or
   statement-based depending on the value of the 'current_stmt_binlog_row_based'
@@ -3582,7 +3602,8 @@ int THD::binlog_query(THD::enum_binlog_q
                       THD::killed_state killed_status_arg)
 {
   DBUG_ENTER("THD::binlog_query");
-  DBUG_PRINT("enter", ("qtype: %d  query: '%s'", qtype, query_arg));
+  DBUG_PRINT("enter", ("qtype: %s  query: '%s'",
+                       show_query_type(qtype), query_arg));
   DBUG_ASSERT(query_arg && mysql_bin_log.is_open());
 
   /*
@@ -3621,6 +3642,9 @@ int THD::binlog_query(THD::enum_binlog_q
 
   switch (qtype) {
   case THD::ROW_QUERY_TYPE:
+    DBUG_PRINT("debug",
+               ("current_stmt_binlog_row_based: %d",
+                current_stmt_binlog_row_based));
     if (current_stmt_binlog_row_based)
       DBUG_RETURN(0);
     /* Otherwise, we fall through */

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2008-08-07 20:51:09 +0000
+++ b/sql/sql_class.h	2008-08-25 11:00:00 +0000
@@ -1070,6 +1070,22 @@ enum enum_thread_type
   SYSTEM_THREAD_BACKUP= 64
 };
 
+inline char const *
+show_system_thread(enum_thread_type thread)
+{
+#define RETURN_NAME_AS_STRING(NAME) case (NAME): return #NAME
+  switch (thread) {
+    RETURN_NAME_AS_STRING(NON_SYSTEM_THREAD);
+    RETURN_NAME_AS_STRING(SYSTEM_THREAD_DELAYED_INSERT);
+    RETURN_NAME_AS_STRING(SYSTEM_THREAD_SLAVE_IO);
+    RETURN_NAME_AS_STRING(SYSTEM_THREAD_SLAVE_SQL);
+    RETURN_NAME_AS_STRING(SYSTEM_THREAD_NDBCLUSTER_BINLOG);
+    RETURN_NAME_AS_STRING(SYSTEM_THREAD_EVENT_SCHEDULER);
+    RETURN_NAME_AS_STRING(SYSTEM_THREAD_EVENT_WORKER);
+    RETURN_NAME_AS_STRING(SYSTEM_THREAD_BACKUP);
+  }
+#undef RETURN_NAME_AS_STRING
+}
 
 /**
   This class represents the interface for internal error handlers.
@@ -2261,6 +2277,10 @@ public:
 
       Don't reset binlog format for NDB binlog injector thread.
     */
+    DBUG_PRINT("debug",
+               ("temporary_tables: %s, in_sub_stmt: %s, system_thread: %s",
+                YESNO(temporary_tables), YESNO(in_sub_stmt),
+                show_system_thread(system_thread)));
     if ((temporary_tables == NULL) && (in_sub_stmt == 0) &&
         (system_thread != SYSTEM_THREAD_NDBCLUSTER_BINLOG))
     {

=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc	2008-07-22 14:16:22 +0000
+++ b/sql/sql_db.cc	2008-08-25 10:16:09 +0000
@@ -883,13 +883,6 @@ bool mysql_rm_db(THD *thd,char *db,bool 
 
   pthread_mutex_lock(&LOCK_mysql_create_db);
 
-  /*
-    This statement will be replicated as a statement, even when using
-    row-based replication. The flag will be reset at the end of the
-    statement.
-  */
-  thd->clear_current_stmt_binlog_row_based();
-
   length= build_table_filename(path, sizeof(path), db, "", "", 0);
   strmov(path+length, MY_DB_OPT_FILE);		// Append db option file name
   del_dbopt(path);				// Remove dboption hash entry
@@ -911,6 +904,20 @@ bool mysql_rm_db(THD *thd,char *db,bool 
   else
   {
     error= -1;
+    /*
+      We temporarily disable the binary log while dropping the objects
+      in the database. Since the DROP DATABASE statement is always
+      replicated as a statement, execution of it will drop all objects
+      in the database on the slave as well, so there is no need to
+      replicate the removal of the individual objects in the database
+      as well.
+
+      This is more of a safety precaution, since normally no objects
+      should be dropped while the database is being cleaned, but in
+      the event that a change in the code to remove other objects is
+      made, these drops should still not be logged.
+     */
+    tmp_disable_binlog(thd);
     if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0,
                                        &dropped_tables)) >= 0)
     {
@@ -922,6 +929,7 @@ bool mysql_rm_db(THD *thd,char *db,bool 
 #endif
       error = 0;
     }
+    reenable_binlog(thd);
   }
   if (!silent && deleted>=0)
   {

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2008-07-22 14:16:22 +0000
+++ b/sql/sql_insert.cc	2008-08-25 10:16:09 +0000
@@ -3682,7 +3682,8 @@ select_create::binlog_show_create_table(
   tmp_table_list.table = *tables;
   query.length(0);      // Have to zero it since constructor doesn't
 
-  result= store_create_info(thd, &tmp_table_list, &query, create_info);
+  result= store_create_info(thd, &tmp_table_list, &query, create_info,
+                            /* show_database */ TRUE);
   DBUG_ASSERT(result == 0); /* store_create_info() always return 0 */
 
   thd->binlog_query(THD::STMT_QUERY_TYPE,

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-08-22 17:03:15 +0000
+++ b/sql/sql_parse.cc	2008-08-25 10:16:09 +0000
@@ -5654,6 +5654,10 @@ void mysql_reset_thd_for_next_command(TH
   */
   thd->reset_current_stmt_binlog_row_based();
 
+  DBUG_PRINT("debug",
+             ("current_stmt_binlog_row_based: %d",
+              thd->current_stmt_binlog_row_based));
+
   DBUG_VOID_RETURN;
 }
 

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2008-08-05 11:20:20 +0000
+++ b/sql/sql_show.cc	2008-08-25 10:16:09 +0000
@@ -541,7 +541,8 @@ mysqld_show_create(THD *thd, TABLE_LIST 
 
   if ((table_list->view ?
        view_store_create_info(thd, table_list, &buffer) :
-       store_create_info(thd, table_list, &buffer, NULL)))
+       store_create_info(thd, table_list, &buffer, NULL,
+                         FALSE /* show_database */)))
     DBUG_RETURN(TRUE);
 
   List<Item> field_list;
@@ -698,6 +699,34 @@ mysqld_list_fields(THD *thd, TABLE_LIST 
 }
 
 
+int
+mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd)
+{
+  Protocol *protocol= thd->protocol;
+  String *packet= protocol->storage_packet();
+  DBUG_ENTER("mysqld_dump_create_info");
+  DBUG_PRINT("enter",("table: %s",table_list->table->s->table_name.str));
+
+  protocol->prepare_for_resend();
+  if (store_create_info(thd, table_list, packet, NULL,
+                        FALSE /* show_database */))
+    DBUG_RETURN(-1);
+
+  if (fd < 0)
+  {
+    if (protocol->write())
+      DBUG_RETURN(-1);
+    protocol->flush();
+  }
+  else
+  {
+    if (my_write(fd, (const uchar*) packet->ptr(), packet->length(),
+		 MYF(MY_WME)))
+      DBUG_RETURN(-1);
+  }
+  DBUG_RETURN(0);
+}
+
 /*
   Go through all character combinations and ensure that sql_lex.cc can
   parse it as an identifier.
@@ -932,7 +961,7 @@ static bool get_field_default_value(THD 
  */
 
 int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
-                      HA_CREATE_INFO *create_info_arg)
+                      HA_CREATE_INFO *create_info_arg, bool show_database)
 {
   List<Item> field_list;
   char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], def_value_buf[MAX_FIELD_WIDTH];
@@ -980,6 +1009,25 @@ int store_create_info(THD *thd, TABLE_LI
       alias= share->table_name.str;
     }
   }
+
+  /*
+    Print the database before the table name if told to do that. The
+    database name is only printed in the event that it is different
+    from the current database.  The main reason for doing this is to
+    avoid having to update gazillions of tests and result files, but
+    it also saves a few bytes of the binary log.
+   */
+  if (show_database)
+  {
+    const LEX_STRING *const db=
+      table_list->schema_table ? &INFORMATION_SCHEMA_NAME : &table->s->db;
+    if (strcmp(db->str, thd->db) != 0)
+    {
+      append_identifier(thd, packet, db->str, db->length);
+      packet->append(STRING_WITH_LEN("."));
+    }
+  }
+
   append_identifier(thd, packet, alias, strlen(alias));
   packet->append(STRING_WITH_LEN(" (\n"));
   /*

=== modified file 'sql/sql_show.h'
--- a/sql/sql_show.h	2008-01-14 19:49:27 +0000
+++ b/sql/sql_show.h	2008-08-25 10:16:09 +0000
@@ -33,7 +33,7 @@ find_files_result find_files(THD *thd, L
                              const char *path, const char *wild, bool dir);
 
 int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
-                      HA_CREATE_INFO  *create_info_arg);
+                      HA_CREATE_INFO  *create_info_arg, bool show_database);
 bool store_db_create_info(THD *thd, const char *dbname, String *buffer,
                           HA_CREATE_INFO *create_info);
 int view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2008-08-05 11:20:20 +0000
+++ b/sql/sql_table.cc	2008-08-25 10:16:09 +0000
@@ -4929,8 +4929,9 @@ bool mysql_create_like_table(THD* thd, T
                        MYSQL_OPEN_REOPEN))
           goto err;
 
-        IF_DBUG(int result=) store_create_info(thd, table, &query,
-                                               create_info);
+        IF_DBUG(int result=)
+          store_create_info(thd, table, &query,
+                            create_info, FALSE /* show_database */);
 
         DBUG_ASSERT(result == 0); // store_create_info() always return 0
         write_bin_log(thd, TRUE, query.ptr(), query.length());

Thread
bzr push into mysql-6.0 branch (mats:2704 to 2706) Mats Kindahl25 Aug