From 70b18065d002eee1d484a0191238ea4f5594e5bf Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Wed, 8 Oct 2008 11:15:00 +0200 Subject: Bug #34707: Row based replication: slave creates table within wrong database The failure was caused by executing a CREATE-SELECT statement that creates a table in another database than the current one. In row-based logging, the CREATE statement was written to the binary log without the database, hence creating the table in the wrong database, causing the following inserts to fail since the table didn't exist in the given database. Fixed the bug by adding a parameter to store_create_info() that will make the function print the database name before the table name and used that in the calls that write the CREATE statement to the binary log. The database name is only printed if it is different than the currently selected database. The output of SHOW CREATE TABLE has not changed and is still printed without the database name. --- sql/sql_insert.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/sql_insert.cc') diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 268e040288e..8762d3dc8fa 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3635,7 +3635,8 @@ select_create::binlog_show_create_table(TABLE **tables, uint count) 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 */ if (mysql_bin_log.is_open()) -- cgit v1.2.1