From: Jon Olav Hauglid Date: August 19 2010 9:33am Subject: bzr commit into mysql-5.5-bugfixing branch (jon.hauglid:3113) Bug#56085 List-Archive: http://lists.mysql.com/commits/116265 X-Bug: 56085 Message-Id: <201008190934.o7J8Itqg029881@acsinet15.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7623837708072569762==" --===============7623837708072569762== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///export/home/x/mysql-5.5-runtime-bug56085/ based on revid:jon.hauglid@stripped 3113 Jon Olav Hauglid 2010-08-19 Bug #56085 Embedded server tests fails with assert in check_if_table_exists() This assert was triggered when the server tried to load plugins while running in embedded server mode. In embedded server mode, check_if_table_exists() was used to check if mysql.plugin existed so that ER_NO_SUCH_TABLE could be silently ignored. The problem was that this check was done without acquiring a metadata lock on mysql.plugin first. This triggered the assert. This patch fixes the problem by removing the call to check_if_table_exists() from plugin_load(). Instead an error handler which traps ER_NO_SUCH_TABLE is installed before trying to open mysql.plugin when running in embedded server mode. No test coverage added since this assert was triggered by existing tests running in embedded server mode. @ sql/sql_base.cc Renamed Prelock_error_handler to No_such_table_error_handler and moved the declaration to sql_base.h to make it usable in plugin_load(). @ sql/sql_base.h Renamed Prelock_error_handler to No_such_table_error_handler and moved the declaration to sql_base.h to make it usable in plugin_load(). @ sql/sql_plugin.cc Removed call to check_if_table_exists() used to check for mysql.plugin in plugin_load() for embedded server. Instead install error handler which traps ER_NO_SUCH_TABLE during open_and_lock_tables(). modified: sql/sql_base.cc sql/sql_base.h sql/sql_plugin.cc === modified file 'sql/sql_base.cc' --- a/sql/sql_base.cc 2010-08-18 11:55:37 +0000 +++ b/sql/sql_base.cc 2010-08-19 09:33:37 +0000 @@ -59,42 +59,13 @@ #endif -/** - This internal handler is used to trap internally - errors that can occur when executing open table - during the prelocking phase. -*/ -class Prelock_error_handler : public Internal_error_handler -{ -public: - Prelock_error_handler() - : m_handled_errors(0), m_unhandled_errors(0) - {} - - virtual ~Prelock_error_handler() {} - - virtual bool handle_condition(THD *thd, - uint sql_errno, - const char* sqlstate, - MYSQL_ERROR::enum_warning_level level, - const char* msg, - MYSQL_ERROR ** cond_hdl); - - bool safely_trapped_errors(); - -private: - int m_handled_errors; - int m_unhandled_errors; -}; - - bool -Prelock_error_handler::handle_condition(THD *, - uint sql_errno, - const char*, - MYSQL_ERROR::enum_warning_level, - const char*, - MYSQL_ERROR ** cond_hdl) +No_such_table_error_handler::handle_condition(THD *, + uint sql_errno, + const char*, + MYSQL_ERROR::enum_warning_level, + const char*, + MYSQL_ERROR ** cond_hdl) { *cond_hdl= NULL; if (sql_errno == ER_NO_SUCH_TABLE) @@ -108,7 +79,7 @@ Prelock_error_handler::handle_condition( } -bool Prelock_error_handler::safely_trapped_errors() +bool No_such_table_error_handler::safely_trapped_errors() { /* If m_unhandled_errors != 0, something else, unanticipated, happened, @@ -4353,11 +4324,11 @@ open_and_process_table(THD *thd, LEX *le The real failure will occur when/if a statement attempts to use that table. */ - Prelock_error_handler prelock_handler; - thd->push_internal_handler(& prelock_handler); + No_such_table_error_handler no_such_table_handler; + thd->push_internal_handler(&no_such_table_handler); error= open_table(thd, tables, new_frm_mem, ot_ctx); thd->pop_internal_handler(); - safe_to_ignore_table= prelock_handler.safely_trapped_errors(); + safe_to_ignore_table= no_such_table_handler.safely_trapped_errors(); } else error= open_table(thd, tables, new_frm_mem, ot_ctx); === modified file 'sql/sql_base.h' --- a/sql/sql_base.h 2010-08-18 11:29:04 +0000 +++ b/sql/sql_base.h 2010-08-19 09:33:37 +0000 @@ -526,4 +526,34 @@ private: }; +/** + This internal handler is used to trap ER_NO_SUCH_TABLE. +*/ + +class No_such_table_error_handler : public Internal_error_handler +{ +public: + No_such_table_error_handler() + : m_handled_errors(0), m_unhandled_errors(0) + {} + + bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* msg, + MYSQL_ERROR ** cond_hdl); + + /** + Returns TRUE if one or more ER_NO_SUCH_TABLE errors have been + trapped and no other errors have been seen. FALSE otherwise. + */ + bool safely_trapped_errors(); + +private: + int m_handled_errors; + int m_unhandled_errors; +}; + + #endif /* SQL_BASE_INCLUDED */ === modified file 'sql/sql_plugin.cc' --- a/sql/sql_plugin.cc 2010-08-05 12:34:19 +0000 +++ b/sql/sql_plugin.cc 2010-08-19 09:33:37 +0000 @@ -1393,8 +1393,9 @@ static void plugin_load(MEM_ROOT *tmp_ro READ_RECORD read_record_info; int error; THD *new_thd= &thd; + bool result; #ifdef EMBEDDED_LIBRARY - bool table_exists; + No_such_table_error_handler error_handler; #endif /* EMBEDDED_LIBRARY */ DBUG_ENTER("plugin_load"); @@ -1410,13 +1411,18 @@ static void plugin_load(MEM_ROOT *tmp_ro When building an embedded library, if the mysql.plugin table does not exist, we silently ignore the missing table */ - if (check_if_table_exists(new_thd, &tables, &table_exists)) - table_exists= FALSE; - if (!table_exists) + new_thd->push_internal_handler(&error_handler); +#endif /* EMBEDDED_LIBRARY */ + + result= open_and_lock_tables(new_thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT); + +#ifdef EMBEDDED_LIBRARY + new_thd->pop_internal_handler(); + if (error_handler.safely_trapped_errors()) goto end; #endif /* EMBEDDED_LIBRARY */ - if (open_and_lock_tables(new_thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) + if (result) { DBUG_PRINT("error",("Can't open plugin table")); sql_print_error("Can't open the mysql.plugin table. Please " --===============7623837708072569762== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/jon.hauglid@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: jon.hauglid@stripped # target_branch: file:///export/home/x/mysql-5.5-runtime-bug56085/ # testament_sha1: 1d7433d2f47c1973c0d44ccbc538d8d028936cc4 # timestamp: 2010-08-19 11:33:40 +0200 # source_branch: file:///export/home/x/mys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g8JsPIFWezYm ku9TnltkSdji4LUVDR6U5nWJNzmK9LdIzcrgy6WgmO9xwRxpxSkZ+1mGxnqdSbWWhsEyCpw73M7h OHh+Uv/F3JFOFCQfqGMJQA== --===============7623837708072569762==--