List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:October 14 2008 12:53pm
Subject:bzr commit into mysql-5.1 branch (Sergey.Glukhov:2759) Bug#29263
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1-bug-29263/

 2759 Sergey Glukhov	2008-10-14
      Bug#29263 disabled storage engines omitted in SHOW ENGINES
      Static disabled plugins|engines and dynamic plugins which installed but disabled
      are not visible in I_S PLUGINS|ENGINES tables because they are not stored into
      global plugin array.
      The fix: add such plugins|engines to plugin array with PLUGIN_IS_DISABLED status.
      I_S.ENGINES 'Transactions', 'XA', 'Savepoints' fields have NULL value in this case.
modified:
  sql/sql_plugin.cc
  sql/sql_plugin.h
  sql/sql_show.cc

per-file messages:
  sql/sql_plugin.cc
    store disabled plugins|engines into plugin array
  sql/sql_plugin.h
    added PLUGIN_IS_DISABLED flag
  sql/sql_show.cc
    added filling of 'engines'&'plugins' tables with disabled engines|plugins
=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2008-08-19 15:35:56 +0000
+++ b/sql/sql_plugin.cc	2008-10-14 12:52:41 +0000
@@ -751,21 +751,22 @@ static bool plugin_add(MEM_ROOT *tmp_roo
       tmp.name.length= name_len;
       tmp.ref_count= 0;
       tmp.state= PLUGIN_IS_UNINITIALIZED;
-      if (!test_plugin_options(tmp_root, &tmp, argc, argv, true))
+      if (test_plugin_options(tmp_root, &tmp, argc, argv, true))
+        tmp.state= PLUGIN_IS_DISABLED;
+
+      if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp)))
       {
-        if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp)))
+        plugin_array_version++;
+        if (!my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr))
         {
-          plugin_array_version++;
-          if (!my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr))
-          {
-            init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096);
-            DBUG_RETURN(FALSE);
-          }
-          tmp_plugin_ptr->state= PLUGIN_IS_FREED;
+          init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096);
+          DBUG_RETURN(FALSE);
         }
-        mysql_del_sys_var_chain(tmp.system_vars);
-        goto err;
+        tmp_plugin_ptr->state= PLUGIN_IS_FREED;
       }
+      mysql_del_sys_var_chain(tmp.system_vars);
+      goto err;
+
       /* plugin was disabled */
       plugin_dl_del(dl);
       DBUG_RETURN(FALSE);
@@ -1145,10 +1146,10 @@ int plugin_init(int *argc, char **argv, 
       tmp.plugin= plugin;
       tmp.name.str= (char *)plugin->name;
       tmp.name.length= strlen(plugin->name);
-
+      tmp.state= 0;
       free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE));
       if (test_plugin_options(&tmp_root, &tmp, argc, argv, def_enabled))
-        continue;
+        tmp.state= PLUGIN_IS_DISABLED;
 
       if (register_builtin(plugin, &tmp, &plugin_ptr))
         goto err_unlock;
@@ -1159,7 +1160,8 @@ int plugin_init(int *argc, char **argv, 
           my_strcasecmp(&my_charset_latin1, plugin->name, "CSV"))
         continue;
 
-      if (plugin_initialize(plugin_ptr))
+      if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED &&
+          plugin_initialize(plugin_ptr))
         goto err_unlock;
 
       /*
@@ -1247,7 +1249,8 @@ static bool register_builtin(struct st_m
 {
   DBUG_ENTER("register_builtin");
 
-  tmp->state= PLUGIN_IS_UNINITIALIZED;
+  if (tmp->state != PLUGIN_IS_DISABLED)
+    tmp->state= PLUGIN_IS_UNINITIALIZED;
   tmp->ref_count= 0;
   tmp->plugin_dl= 0;
 
@@ -1555,7 +1558,8 @@ void plugin_shutdown(void)
       We loop through all plugins and call deinit() if they have one.
     */
     for (i= 0; i < count; i++)
-      if (!(plugins[i]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED)))
+      if (!(plugins[i]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED |
+                                 PLUGIN_IS_DISABLED)))
       {
         sql_print_information("Plugin '%s' will be forced to shutdown",
                               plugins[i]->name.str);

=== modified file 'sql/sql_plugin.h'
--- a/sql/sql_plugin.h	2007-06-12 15:41:56 +0000
+++ b/sql/sql_plugin.h	2008-10-14 12:52:41 +0000
@@ -54,6 +54,7 @@ typedef struct st_mysql_show_var SHOW_VA
 #define PLUGIN_IS_UNINITIALIZED 4
 #define PLUGIN_IS_READY         8
 #define PLUGIN_IS_DYING         16
+#define PLUGIN_IS_DISABLED      32
 
 /* A handle for the dynamic library containing a plugin or plugins. */
 

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2008-10-02 10:08:15 +0000
+++ b/sql/sql_show.cc	2008-10-14 12:52:41 +0000
@@ -123,6 +123,9 @@ static my_bool show_plugins(THD *thd, pl
   case PLUGIN_IS_READY:
     table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs);
     break;
+  case PLUGIN_IS_DISABLED:
+    table->field[2]->store(STRING_WITH_LEN("DISABLED"), cs);
+    break;
   default:
     DBUG_ASSERT(0);
   }
@@ -3865,6 +3868,20 @@ static my_bool iter_schema_engines(THD *
   handlerton *default_type= ha_default_handlerton(thd);
   DBUG_ENTER("iter_schema_engines");
 
+
+  /* Disabled plugins */
+  if (!hton)
+  {
+    struct st_mysql_plugin *plug= plugin_decl(plugin);
+    restore_record(table, s->default_values);
+    table->field[0]->store(plug->name, strlen(plug->name), scs);
+    table->field[1]->store(C_STRING_WITH_LEN("NO"), scs);
+    table->field[2]->store(plug->descr, strlen(plug->descr), scs);
+    if (schema_table_store_record(thd, table))
+      DBUG_RETURN(1);
+    DBUG_RETURN(0);
+  }
+
   if (!(hton->flags & HTON_HIDDEN))
   {
     LEX_STRING *name= plugin_name(plugin);
@@ -3885,10 +3902,13 @@ static my_bool iter_schema_engines(THD *
                              strlen(plugin_decl(plugin)->descr), scs);
       tmp= &yesno[test(hton->commit)];
       table->field[3]->store(tmp->str, tmp->length, scs);
+      table->field[3]->set_notnull();
       tmp= &yesno[test(hton->prepare)];
       table->field[4]->store(tmp->str, tmp->length, scs);
+      table->field[4]->set_notnull();
       tmp= &yesno[test(hton->savepoint_set)];
       table->field[5]->store(tmp->str, tmp->length, scs);
+      table->field[5]->set_notnull();
 
       if (schema_table_store_record(thd, table))
         DBUG_RETURN(1);
@@ -3899,8 +3919,12 @@ static my_bool iter_schema_engines(THD *
 
 int fill_schema_engines(THD *thd, TABLE_LIST *tables, COND *cond)
 {
-  return plugin_foreach(thd, iter_schema_engines,
-                        MYSQL_STORAGE_ENGINE_PLUGIN, tables->table);
+  DBUG_ENTER("fill_schema_engines");
+  if (plugin_foreach_with_mask(thd, iter_schema_engines,
+                               MYSQL_STORAGE_ENGINE_PLUGIN,
+                               ~PLUGIN_IS_FREED, tables->table))
+    DBUG_RETURN(1);
+  DBUG_RETURN(0);
 }
 
 
@@ -6092,9 +6116,9 @@ ST_FIELD_INFO engines_fields_info[]=
   {"ENGINE", 64, MYSQL_TYPE_STRING, 0, 0, "Engine", SKIP_OPEN_TABLE},
   {"SUPPORT", 8, MYSQL_TYPE_STRING, 0, 0, "Support", SKIP_OPEN_TABLE},
   {"COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment", SKIP_OPEN_TABLE},
-  {"TRANSACTIONS", 3, MYSQL_TYPE_STRING, 0, 0, "Transactions", SKIP_OPEN_TABLE},
-  {"XA", 3, MYSQL_TYPE_STRING, 0, 0, "XA", SKIP_OPEN_TABLE},
-  {"SAVEPOINTS", 3 ,MYSQL_TYPE_STRING, 0, 0, "Savepoints", SKIP_OPEN_TABLE},
+  {"TRANSACTIONS", 3, MYSQL_TYPE_STRING, 0, 1, "Transactions", SKIP_OPEN_TABLE},
+  {"XA", 3, MYSQL_TYPE_STRING, 0, 1, "XA", SKIP_OPEN_TABLE},
+  {"SAVEPOINTS", 3 ,MYSQL_TYPE_STRING, 0, 1, "Savepoints", SKIP_OPEN_TABLE},
   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 };
 

Thread
bzr commit into mysql-5.1 branch (Sergey.Glukhov:2759) Bug#29263Sergey Glukhov14 Oct