From a018e98cba6158e7a2885cffcc092ab66a934d5e Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Thu, 31 Jul 2008 14:24:27 +0800 Subject: BUG#37051 Replication rules not evaluated correctly The problem of this bug is that we need to get the list of tables to be updated for a multi-table update statement, which requires to open all the tables referenced by the statement and resolve all the fields involved in update in order to figure out the list of tables for update. However if there are replicate filter rules, some tables might not exist on slave and result in a failure before we could examine the filter rules. I think the whole problem can not be solved on slave alone, the master must record and send the information of tables involved for update to slave, so that the slave do not need to open all the tables referenced by the multi-table update statement to figure out which tables are involved for update. So a status variable is added to Query_log event to store the value of table map for update on master. And on slave, it will try to get the value of this variable and use it to examine filter rules without opening any tables on slave, if this values is not available, the old approach is used and thus the bug will still occur for when replicating from old masters. sql/sql_class.h: add member table_map_for_update to THD sql/sql_parse.cc: check filter rules by using table_map_for_update value sql/sql_update.cc: save the value of table_map_for_update --- sql/sql_class.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index a86b4d36d00..cf238de776b 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -396,7 +396,6 @@ struct system_variables DATE_TIME_FORMAT *datetime_format; DATE_TIME_FORMAT *time_format; my_bool sysdate_is_now; - }; @@ -1446,6 +1445,13 @@ public: Note: in the parser, stmt_arena == thd, even for PS/SP. */ Query_arena *stmt_arena; + + /* + map for tables that will be updated for a multi-table update query + statement, for other query statements, this will be zero. + */ + table_map table_map_for_update; + /* Tells if LAST_INSERT_ID(#) was called for the current statement */ bool arg_of_last_insert_id_function; /* -- cgit v1.2.1 From 5cd9d96a68e0f861b1c81d9e20a19b848fe48083 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Tue, 19 Aug 2008 13:18:59 +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. 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(). --- sql/sql_class.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sql/sql_class.h') 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)) { -- cgit v1.2.1 From 8b637b284784d92b912318cd3b52d1550920fa09 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Fri, 22 Aug 2008 12:40:21 +0200 Subject: Fixning compiler warnings. Fixing build failure for valgrind platform. include/my_global.h: Moving YESNO() macro here from log.cc (it prints either "yes" or "no" depending on a boolean value). sql/log.cc: Moving YESNO() function to my_global.h. sql/sql_class.cc: Adding default case to printout function to avoid warning. Only defining function for debug builds since it isn't used in non-debug build (hence produce a warning). sql/sql_class.h: Printing yes/no answer instead of memory address since the case produces an error/warning on valgrind platform. --- sql/sql_class.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index 7381930dc93..0bc8d00b22c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2100,8 +2100,8 @@ 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, + ("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)) -- cgit v1.2.1 From aa67166ef208cc7346b5ad36900f3f93bdee28d9 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Mon, 25 Aug 2008 14:23:49 +0200 Subject: Eliminating some compiler warnings. sql/sql_class.h: Adding default return clause. --- sql/sql_class.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index 0bc8d00b22c..488a35ff070 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1001,6 +1001,7 @@ show_system_thread(enum_thread_type thread) { #define RETURN_NAME_AS_STRING(NAME) case (NAME): return #NAME switch (thread) { + static char buf[64]; RETURN_NAME_AS_STRING(NON_SYSTEM_THREAD); RETURN_NAME_AS_STRING(SYSTEM_THREAD_DELAYED_INSERT); RETURN_NAME_AS_STRING(SYSTEM_THREAD_SLAVE_IO); @@ -1008,6 +1009,9 @@ show_system_thread(enum_thread_type thread) RETURN_NAME_AS_STRING(SYSTEM_THREAD_NDBCLUSTER_BINLOG); RETURN_NAME_AS_STRING(SYSTEM_THREAD_EVENT_SCHEDULER); RETURN_NAME_AS_STRING(SYSTEM_THREAD_EVENT_WORKER); + default: + sprintf(buf, "", thread); + return buf; } #undef RETURN_NAME_AS_STRING } -- cgit v1.2.1 From e85fe79430d74f4ca4f972bf13594a5c1fbcddb2 Mon Sep 17 00:00:00 2001 From: Build Team Date: Mon, 10 Nov 2008 21:21:49 +0100 Subject: Added "Sun Microsystems, Inc." to copyright headers on files modified since Oct 1st --- sql/sql_class.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index f5cf31d1030..d726ce90521 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit v1.2.1 From 952d284ba4617958840005d314ae8d19428df1c3 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 17 Dec 2008 17:23:21 +0400 Subject: Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines(for 5.1) mysql-test/r/myisampack.result: result fix mysql-test/t/myisampack.test: test case fix --- sql/sql_class.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index f5cf31d1030..96b73ea76a2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -456,8 +456,15 @@ typedef struct system_status_var ulong com_stmt_fetch; ulong com_stmt_reset; ulong com_stmt_close; - /* + Number of statements sent from the client + */ + ulong questions; + /* + IMPORTANT! + SEE last_system_status_var DEFINITION BELOW. + Below 'last_system_status_var' are all variables which doesn't make any + sense to add to the /global/ status variable counter. Status variables which it does not make sense to add to global status variable counter */ @@ -470,7 +477,7 @@ typedef struct system_status_var counter */ -#define last_system_status_var com_stmt_close +#define last_system_status_var questions void mark_transaction_to_rollback(THD *thd, bool all); -- cgit v1.2.1