From a64555543285881b3183f63913fa00b296479715 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Fri, 29 May 2009 15:37:54 +0200 Subject: Bug#44658 Create procedure makes server crash when user does not have ALL privilege MySQL crashes if a user without proper privileges attempts to create a procedure. The crash happens because more than one error state is pushed onto the Diagnostic area. In this particular case the user is denied to implicitly create a new user account with the implicitly granted privileges ALTER- and EXECUTE ROUTINE. The new account is needed if the original user account contained a host mask. A user account with a host mask is a distinct user account in this context. An alternative would be to first get the most permissive user account which include the current user connection and then assign privileges to that account. This behavior change is considered out of scope for this bug patch. The implicit assignment of privileges when a user creates a stored routine is a considered to be a feature for user convenience and as such it is not a critical operation. Any failure to complete this operation is thus considered non-fatal (an error becomes a warning). The patch back ports a stack implementation of the internal error handler interface. This enables the use of multiple error handlers so that it is possible to intercept and cancel errors thrown by lower layers. This is needed as a error handler already is used in the call stack emitting the errors which needs to be converted. --- sql/sql_class.cc | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index cf5fdcf27a7..a853ad103ea 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -674,31 +674,40 @@ THD::THD() void THD::push_internal_handler(Internal_error_handler *handler) { - /* - TODO: The current implementation is limited to 1 handler at a time only. - THD and sp_rcontext need to be modified to use a common handler stack. - */ - DBUG_ASSERT(m_internal_handler == NULL); - m_internal_handler= handler; + if (m_internal_handler) + { + handler->m_prev_internal_handler= m_internal_handler; + m_internal_handler= handler; + } + else + { + m_internal_handler= handler; + } } bool THD::handle_error(uint sql_errno, const char *message, MYSQL_ERROR::enum_warning_level level) { - if (m_internal_handler) + if (!m_internal_handler) + return FALSE; + + for (Internal_error_handler *error_handler= m_internal_handler; + error_handler; + error_handler= m_internal_handler->m_prev_internal_handler) { - return m_internal_handler->handle_error(sql_errno, message, level, this); + if (error_handler->handle_error(sql_errno, message, level, this)) + return TRUE; } - return FALSE; // 'FALSE', as per coding style + return FALSE; } void THD::pop_internal_handler() { DBUG_ASSERT(m_internal_handler != NULL); - m_internal_handler= NULL; + m_internal_handler= m_internal_handler->m_prev_internal_handler; } extern "C" -- cgit v1.2.1 From 0793eec018214cab504210ff0a40993ac0b319a9 Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Sat, 30 May 2009 21:32:28 +0800 Subject: BUG#41948 Query_log_event constructor needlessly contorted Make the caller of Query_log_event, Execute_load_log_event constructors and THD::binlog_query to provide the error code instead of having the constructors to figure out the error code. --- sql/sql_class.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index a853ad103ea..f881f0a792b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3658,7 +3658,7 @@ show_query_type(THD::enum_binlog_query_type qtype) */ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, ulong query_len, bool is_trans, bool suppress_use, - THD::killed_state killed_status_arg) + int errcode) { DBUG_ENTER("THD::binlog_query"); DBUG_PRINT("enter", ("qtype: %s query: '%s'", @@ -3725,7 +3725,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, */ { Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use, - killed_status_arg); + errcode); qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; /* Binlog table maps will be irrelevant after a Query_log_event -- cgit v1.2.1 From a561a95e6c78c9edb7dd0d52c7be30f45f97efa0 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Mon, 8 Jun 2009 19:05:24 -0300 Subject: Fix for a valgrind warning due to use of a uninitialized variable. The problem was that THD::connect_utime could be used without being initialized when the main thread is used to handle connections (--thread-handling=no-threads). --- 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 f881f0a792b..f1ad410b877 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -590,7 +590,7 @@ THD::THD() // Must be reset to handle error with THD's created for init of mysqld lex->current_select= 0; start_time=(time_t) 0; - start_utime= 0L; + start_utime= prior_thr_create_utime= 0L; utime_after_lock= 0L; current_linfo = 0; slave_thread = 0; -- cgit v1.2.1 From 498ac0f598f998999ac3d675466912f16d2d4e9e Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Thu, 25 Jun 2009 17:41:05 +0200 Subject: Bug #34002 uninitialized Rows_examined for some admin queries such as quit and shutdown Logging to slow log can produce an undetermined value for Rows_examined in special cases. In debug mode this manifests itself as any of the various marker values used to mark uninitialized memory on various platforms. If logging happens on a THD object that hasn't performed any row reads (on this or any previous connections), the THD::examined_row_count may be uninitialized. This patch adds initialization for this attribute. No automated test cases are added, as for this to be meaningful, we need to ensure that we're using a THD fulfilling the above conditions. This is hard to do in the mysql-test-run framework. The patch has been verified manually, however, by restarting mysqld and running the test included with the bug report. --- 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 f1ad410b877..409e4dc4b8b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -546,6 +546,7 @@ THD::THD() first_successful_insert_id_in_prev_stmt_for_binlog(0), first_successful_insert_id_in_cur_stmt(0), stmt_depends_on_first_successful_insert_id_in_prev_stmt(FALSE), + examined_row_count(0), global_read_lock(0), is_fatal_error(0), transaction_rollback_request(0), -- cgit v1.2.1 From 92536e421321f49abad66f0bd53aa0315fd20ec6 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Sat, 27 Jun 2009 14:18:47 +0100 Subject: BUG#42851: Spurious "Statement is not safe to log in statement format." warnings Despite the fact that a statement would be filtered out from binlog, a warning would still be thrown if it was issued with the LIMIT. This patch addresses this issue by checking the filtering rules before printing out the warning. --- sql/sql_class.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/sql_class.cc') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 409e4dc4b8b..48ddb42f0d8 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -27,6 +27,7 @@ #include "mysql_priv.h" #include "rpl_rli.h" +#include "rpl_filter.h" #include "rpl_record.h" #include "slave.h" #include @@ -3684,7 +3685,8 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, we should print a warning. */ if (sql_log_bin_toplevel && lex->is_stmt_unsafe() && - variables.binlog_format == BINLOG_FORMAT_STMT) + variables.binlog_format == BINLOG_FORMAT_STMT && + binlog_filter->db_ok(this->db)) { /* A warning can be elevated a error when STRICT sql mode. -- cgit v1.2.1