From: Jon Olav Hauglid Date: August 19 2010 9:13am Subject: bzr commit into mysql-5.5-bugfixing branch (jon.hauglid:3113) Bug#56085 List-Archive: http://lists.mysql.com/commits/116210 X-Bug: 56085 Message-Id: <201008190915.o7INuUN1000628@acsinet15.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8645356292287053429==" --===============8645356292287053429== 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 installs 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:13:51 +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:13:51 +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:13:51 +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 " --===============8645356292287053429== 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: 044773a33318cb57ccb6cbd6b0663b4c45ec1bc9 # timestamp: 2010-08-19 11:13:55 +0200 # source_branch: file:///export/home/x/mysql-5.5-bugfixing/ # base_revision_id: jon.hauglid@stripped\ # ks8jtogq0mw4b7cc # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWZc+3bsABDd/gECQBABZd/// f//+IL////pgCluq33re27E9mKHsxSKNdPvYSHqjQ0ccNFMqflT8kxJpkeQ9RPSekNoQBgmhhBia aaBJIjQ0A0JoSTbRlMKHlAxqaMh6hpoA9INCAQmjUaeNU9T1NAAGgAaaAANA0GEimyCU3pMpptQ0 2oeoAMnqeoDQD1BoADaoVP1TaT8pD1MR4SaPUepoNAADIAAABJECaJphBNMjITJT9U/U/VJ5NTNT T9I01GR6jTyjyiyViQBCsGWhKJzqGdgWwGDCBG+jMgxI+uD10xX6iIIy709VkR0KOb9WrJfJ1wwr mQ60UVnHRjnFjIKWjFksqffMOTTnclw7zWviJ5IVVJlf35gyHTMAX9BCBFAgAiEiESd2jdivaOXq UIaktZ3HSUEgUkgL/oDwnXN9uQ2GKT3zCYVvBqY1dinEuCBzUDGMUo1rQVRvW4Krj2xSybniqI5w uMbY4glPC6GFQ2LCEGDWR/iHlAPibZHnGZKGgNcHeDPCKe7x+Z3vlYNYYE7aXacVR6DwqtI3/NHJ nnZQisk7dl0q8h4QyojKfB+NEVKzYxZSSz141ClaShYiDM2g1Gb342ihbSLD1rW2pMdtpZQQxIUw mMHIgU+JIS1qlxXbtqOYRVxaKXrJ9yHAkmCKCcbQ+AYhZmAii0N8SDUxn0aYv7bIaAjntgriHIw4 5aOMaWS46q8cqkIPGOPdl1LcvJlvXIA0BVNsk4pJEzgM6pmFZBQk/OCDGnSW9QOlIpyCgYtYBkZs khgBuiQVGq3nMyolSugpZjcWUIXFkZsFxyH3KC6QYAZCNSdFWgwVHUV27h7ZumUfTI+UJkwC8tgI q6YoEmqmIEIf9C8CxkzSo8tAiHi9gkXv+cFHqosx98KK1ljcDBOl55lio9r7Kdjud1JZDIQymHot O1DjFMNI78OmfZELpuQ3dijfvOioyJx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hW94TFFRukDig0RVcKxxkuLBbErppJF 6ALhH9evMguCSedU+44pKNaJdUy0EnZtiYWcrOEzGztTSYiQBych5WKocZagFZI1Wr5lDay+hRqI xRQhMDAhNjS1qlwmQlOps1mjeqxD5K4HK31q9aafF3/i7kinChIS59u3YA== --===============8645356292287053429==--