List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:August 18 2010 1:11pm
Subject:bzr commit into mysql-5.5-bugfixing branch (jon.hauglid:3113) Bug#56085
View as plain text  
#At file:///export/home/x/mysql-5.5-runtime-bug56085/ based on revid:jon.hauglid@stripped

 3113 Jon Olav Hauglid	2010-08-18
      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.

    modified:
      sql/sql_plugin.cc
=== 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-18 13:11:30 +0000
@@ -1382,6 +1382,60 @@ static bool register_builtin(struct st_m
 }
 
 
+#ifdef EMBEDDED_LIBRARY
+/**
+  This internal handler is used to trap ER_NO_SUCH_TABLE.
+  During loading of plugins using an embedded library,
+  we wish to ignore ER_NO_SUCH_TABLE when opening mysql.plugin.
+*/
+class Plugin_load_error_handler : public Internal_error_handler
+{
+public:
+  Plugin_load_error_handler()
+    : m_no_such_table(FALSE)
+  {}
+
+  virtual ~Plugin_load_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 no_such_table();
+
+private:
+  bool m_no_such_table;
+};
+
+
+bool
+Plugin_load_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)
+  {
+    m_no_such_table= TRUE;
+    return TRUE;
+  }
+  return FALSE;
+}
+
+
+bool Plugin_load_error_handler::no_such_table()
+{
+  return m_no_such_table;
+}
+#endif /* EMBEDDED_LIBRARY */
+
+
 /*
   called only by plugin_init()
 */
@@ -1393,9 +1447,7 @@ static void plugin_load(MEM_ROOT *tmp_ro
   READ_RECORD read_record_info;
   int error;
   THD *new_thd= &thd;
-#ifdef EMBEDDED_LIBRARY
-  bool table_exists;
-#endif /* EMBEDDED_LIBRARY */
+  bool result;
   DBUG_ENTER("plugin_load");
 
   new_thd->thread_stack= (char*) &tables;
@@ -1410,13 +1462,19 @@ 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)
+  Plugin_load_error_handler error_handler;
+  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.no_such_table())
     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 "


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20100818131130-lp10bkfkmlyvder7.bundle
Thread
bzr commit into mysql-5.5-bugfixing branch (jon.hauglid:3113) Bug#56085Jon Olav Hauglid18 Aug
  • Re: bzr commit into mysql-5.5-bugfixing branch (jon.hauglid:3113)Bug#56085Dmitry Lenev18 Aug