summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorMats Kindahl <mats@mysql.com>2008-08-19 13:18:59 +0200
committerMats Kindahl <mats@mysql.com>2008-08-19 13:18:59 +0200
commit5cd9d96a68e0f861b1c81d9e20a19b848fe48083 (patch)
tree89b6e599ad7e34de64a6cbe42a0dc25ae5716f1f /sql/sql_class.h
parent93d835213e1c5bb6bad455ef6a4877a960e638f3 (diff)
downloadmariadb-git-5cd9d96a68e0f861b1c81d9e20a19b848fe48083.tar.gz
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. mysql-test/suite/rpl/r/rpl_row_create_table.result: Result file change. mysql-test/suite/rpl/t/rpl_row_create_table.test: Added test to check that CREATE-SELECT into another database than the current one replicates. sql/sql_insert.cc: Adding parameter to calls to store_create_info(). sql/sql_show.cc: Adding parameter to calls to store_create_info(). Extending store_create_info() with parameter 'show_database' that will cause the database to be written before the table name. sql/sql_show.h: Adding parameter to call to store_create_info() to tell if the database should be shown or not. sql/sql_table.cc: Adding parameter to calls to store_create_info().
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 8ceb93940ab..7381930dc93 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -996,6 +996,21 @@ enum enum_thread_type
SYSTEM_THREAD_EVENT_WORKER= 32
};
+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);
+ }
+#undef RETURN_NAME_AS_STRING
+}
/**
This class represents the interface for internal error handlers.
@@ -2084,6 +2099,10 @@ public:
Don't reset binlog format for NDB binlog injector thread.
*/
+ DBUG_PRINT("debug",
+ ("temporary_tables: %d, in_sub_stmt: %d, system_thread: %s",
+ (int) temporary_tables, in_sub_stmt,
+ show_system_thread(system_thread)));
if ((temporary_tables == NULL) && (in_sub_stmt == 0) &&
(system_thread != SYSTEM_THREAD_NDBCLUSTER_BINLOG))
{