From 5e04d4695ba8dfef7945882923b977df554be2e2 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Thu, 24 Sep 2009 15:52:52 +0100 Subject: BUG#42829: binlogging enabled for all schemas regardless of binlog-db-db / binlog-ignore-db InnoDB will return an error if statement based replication is used along with transaction isolation level READ-COMMITTED (or weaker), even if the statement in question is filtered out according to the binlog-do-db rules set. In this case, an error should not be printed. This patch addresses this issue by extending the existing check in external_lock to take into account the filter rules before deciding to print an error. Furthermore, it also changes decide_logging_format to take into consideration whether the statement is filtered out from binlog before decision is made. --- sql/sql_class.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 3f568566c89..9269e97cc4c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -42,6 +42,7 @@ #include "sp_rcontext.h" #include "sp_cache.h" +#include "rpl_filter.h" /* The following is used to initialise Table_ident with a internal @@ -2980,6 +2981,11 @@ extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all) { mark_transaction_to_rollback(thd, all); } + +extern "C" bool thd_binlog_filter_ok(const MYSQL_THD thd) +{ + return binlog_filter->db_ok(thd->db); +} #endif // INNODB_COMPATIBILITY_HOOKS */ /**************************************************************************** -- cgit v1.2.1 From 8f6f3dba21272158d13cb49e99274167af1461ad Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 16 Oct 2009 13:29:42 +0300 Subject: Bug #40877: multi statement execution fails in 5.1.30 Implemented the server infrastructure for the fix: 1. Added a function LEX_STRING *thd_query_string(THD) to return a LEX_STRING structure instead of char *. This is the function that must be called in innodb instead of thd_query() 2. Did some encapsulation in THD : aggregated thd_query and thd_query_length into a LEX_STRING and made accessor and mutator methods for easy code updating. 3. Updated the server code to use the new methods where applicable. --- sql/sql_class.cc | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f75dc2cb88a..aa556810402 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -376,14 +376,14 @@ char *thd_security_context(THD *thd, char *buffer, unsigned int length, str.append(proc_info); } - if (thd->query) + if (thd->query()) { if (max_query_len < 1) - len= thd->query_length; + len= thd->query_length(); else - len= min(thd->query_length, max_query_len); + len= min(thd->query_length(), max_query_len); str.append('\n'); - str.append(thd->query, len); + str.append(thd->query(), len); } if (str.c_ptr_safe() == buffer) return buffer; @@ -2434,12 +2434,12 @@ Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg, id(id_arg), mark_used_columns(MARK_COLUMNS_READ), lex(lex_arg), - query(0), - query_length(0), cursor(0), db(NULL), db_length(0) { + query_string.length= 0; + query_string.str= NULL; name.str= NULL; } @@ -2455,8 +2455,7 @@ void Statement::set_statement(Statement *stmt) id= stmt->id; mark_used_columns= stmt->mark_used_columns; lex= stmt->lex; - query= stmt->query; - query_length= stmt->query_length; + query_string= stmt->query_string; cursor= stmt->cursor; } @@ -2480,6 +2479,15 @@ void Statement::restore_backup_statement(Statement *stmt, Statement *backup) } +/** Assign a new value to thd->query. */ + +void Statement::set_query_inner(char *query_arg, uint32 query_length_arg) +{ + query_string.str= query_arg; + query_string.length= query_length_arg; +} + + void THD::end_statement() { /* Cleanup SQL processing state to reuse this statement in next query. */ @@ -2993,9 +3001,24 @@ extern "C" struct charset_info_st *thd_charset(MYSQL_THD thd) return(thd->charset()); } +/** + OBSOLETE : there's no way to ensure the string is null terminated. + Use thd_query_string instead() +*/ extern "C" char **thd_query(MYSQL_THD thd) { - return(&thd->query); + return(&thd->query_string.str); +} + +/** + Get the current query string for the thread. + + @param The MySQL internal thread pointer + @return query string and length. May be non-null-terminated. +*/ +extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd) +{ + return(&thd->query_string); } extern "C" int thd_slave_thread(const MYSQL_THD thd) @@ -3174,8 +3197,7 @@ void THD::set_statement(Statement *stmt) void THD::set_query(char *query_arg, uint32 query_length_arg) { pthread_mutex_lock(&LOCK_thd_data); - query= query_arg; - query_length= query_length_arg; + set_query_inner(query_arg, query_length_arg); pthread_mutex_unlock(&LOCK_thd_data); } -- cgit v1.2.1 From fdcf0aff02942de969b3823b391273325b9d9bda Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Wed, 28 Oct 2009 17:49:56 +0300 Subject: A patch and a test case for Bug#46539 Various crashes on INSERT IGNORE SELECT + SELECT FOR UPDATE. If a transaction was rolled back inside InnoDB due to a deadlock or lock wait timeout, and the statement had IGNORE clause, the server could crash at the end of the statement or on shutdown. This was caused by the error handling infrastructure's attempt to ignore a non-ignorable error. When a transaction rollback request is raised, switch off current_select->no_error flag, so that the following error won't be ignored. Instead, we could add !thd->is_fatal_sub_stmt_error to my_message_sql(), but since in write_record() we switch off no_error, the same approach is used in thd_mark_transaction_to_rollback(). @todo: call thd_mark_transaction_to_rollback() from handler::print_error(), then we can easily make sure that the error reported by print_error is not ignored. --- sql/sql_class.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index aa556810402..080839e9b42 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3215,6 +3215,16 @@ void mark_transaction_to_rollback(THD *thd, bool all) { thd->is_fatal_sub_stmt_error= TRUE; thd->transaction_rollback_request= all; + /* + Aborted transactions can not be IGNOREd. + Switch off the IGNORE flag for the current + SELECT_LEX. This should allow my_error() + to report the error and abort the execution + flow, even in presence + of IGNORE clause. + */ + if (thd->lex->current_select) + thd->lex->current_select->no_error= FALSE; } } /*************************************************************************** -- cgit v1.2.1 From a0bea5eeb197beaa46bf80c5096d9cf934bf25df Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 30 Oct 2009 15:15:43 +0200 Subject: Bug #48291 : crash with row() operator,select into @var, and subquery returning multiple rows Error handling was missing when handling subqueires in WHERE and when assigning a SELECT result to a @variable. This caused crash(es). Fixed by adding error handling code to both the WHERE condition evaluation and to assignment to an @variable. --- sql/sql_class.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7d26759cb16..06f2229a050 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2068,9 +2068,11 @@ bool select_dumpvar::send_data(List &items) else { Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item); - suv->fix_fields(thd, 0); + if (suv->fix_fields(thd, 0)) + DBUG_RETURN (1); suv->save_item_result(item); - suv->update(); + if (suv->update()) + DBUG_RETURN (1); } } DBUG_RETURN(0); -- cgit v1.2.1