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.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b54aea94424..93c65d820c3 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1113,6 +1113,8 @@ void THD::cleanup_after_query() free_items(); /* Reset where. */ where= THD::DEFAULT_WHERE; + /* reset table map for multi-table update */ + table_map_for_update= 0; } -- cgit v1.2.1 From 1d5e2c8dc41e7261e9cc4d2a6548509c10945d3d Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Thu, 7 Aug 2008 09:33:01 +0800 Subject: post push fix for BUG#37051 mysql-test/r/multi_update.result: update result sql/sql_class.cc: Initialize table_map_for_update to 0 --- sql/sql_class.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index cab69423ee4..c83ca0d1899 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -514,6 +514,7 @@ THD::THD() lock_id(&main_lock_id), user_time(0), in_sub_stmt(0), binlog_table_maps(0), binlog_flags(0UL), + table_map_for_update(0), arg_of_last_insert_id_function(FALSE), first_successful_insert_id_in_prev_stmt(0), first_successful_insert_id_in_prev_stmt_for_binlog(0), -- 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.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index c83ca0d1899..b6070c61974 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3528,6 +3528,24 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end) } +static const char * +show_query_type(THD::enum_binlog_query_type qtype) +{ + switch (qtype) { + case THD::ROW_QUERY_TYPE: + return "ROW"; + case THD::STMT_QUERY_TYPE: + return "STMT"; + case THD::MYSQL_QUERY_TYPE: + return "MYSQL"; + } + + static char buf[64]; + sprintf(buf, "UNKNOWN#%d", qtype); + return buf; +} + + /* Member function that will log query, either row-based or statement-based depending on the value of the 'current_stmt_binlog_row_based' @@ -3556,7 +3574,8 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, 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()); /* @@ -3595,6 +3614,9 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, 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 */ -- 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.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b6070c61974..50888c6f7af 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3528,22 +3528,24 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end) } +#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; } - - static char buf[64]; - sprintf(buf, "UNKNOWN#%d", qtype); - return buf; } +#endif /* -- 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.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 12b773c91d0..da24b1cf39d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -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