List:Commits« Previous MessageNext Message »
From:antony Date:May 9 2007 2:08am
Subject:bk commit into 5.1 tree (acurtis:1.2511) BUG#27836
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of antony. When antony does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-05-08 17:08:30-07:00, acurtis@stripped +2 -0
  Bug#27836
    "sql_plugin.cc, dynamic_array is not dynamic"
    When dynamic array resized, existing pointers to array elements became invalid.
    Change plugin_array to store pointers to instances of st_plugin_int.
    Allocate st_plugin_int from plugin_mem_root
    st_plugin_int now stores index within plugin_dl_array instead of pointer.
    

  sql/sql_plugin.cc@stripped, 2007-05-08 17:08:24-07:00, acurtis@stripped +38 -24
    bug27836
      new dlib accessor function plugin_dlib_by_index
      changed plugin_int member from plugin_dl to plugin_dl_idx
      plugin_array now stores pointers to st_plugin_int
      st_plugin_int are allocated in plugin_mem_root

  sql/sql_plugin.h@stripped, 2007-05-08 17:08:24-07:00, acurtis@stripped +4 -3
    bug27836
      changed plugin_int member from plugin_dl to plugin_dl_idx
      new function declaration plugin_dlib_by_index()
      altered plugin_dlib macro to use new function

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	acurtis
# Host:	ltamd64.xiphis.org
# Root:	/home/antony/work2/p2-bug27836.1

--- 1.63/sql/sql_plugin.cc	2007-05-08 17:08:44 -07:00
+++ 1.64/sql/sql_plugin.cc	2007-05-08 17:08:44 -07:00
@@ -537,6 +537,14 @@
 }
 
 
+struct st_plugin_dl *plugin_dlib_by_index(uint idx)
+{
+  if (idx < 1 || idx > plugin_dl_array.elements)
+    return 0;
+  return dynamic_element(&plugin_dl_array, idx - 1, struct st_plugin_dl *);
+}
+
+
 static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int type)
 {
   uint i;
@@ -608,7 +616,7 @@
     plugin_ref plugin;
 #ifdef DBUG_OFF
     /* built-in plugins don't need ref counting */
-    if (!pi->plugin_dl)
+    if (!pi->plugin_dl_idx)
       DBUG_RETURN(pi);
 
     plugin= pi;
@@ -665,21 +673,23 @@
 static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
 {
   uint i;
+  struct st_plugin_int *tmp;
   DBUG_ENTER("plugin_insert_or_reuse");
   for (i= 0; i < plugin_array.elements; i++)
   {
-    struct st_plugin_int *tmp= dynamic_element(&plugin_array, i,
-                                               struct st_plugin_int *);
+    tmp= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
     if (tmp->state == PLUGIN_IS_FREED)
     {
       memcpy(tmp, plugin, sizeof(struct st_plugin_int));
       DBUG_RETURN(tmp);
     }
   }
-  if (insert_dynamic(&plugin_array, (gptr)plugin))
+  if (!(tmp= (struct st_plugin_int*) 
+             memdup_root(&plugin_mem_root, (char *)plugin, 
+                         sizeof(struct st_plugin_int))) ||
+      insert_dynamic(&plugin_array, (gptr)&tmp))
     DBUG_RETURN(0);
-  DBUG_RETURN(dynamic_element(&plugin_array, plugin_array.elements - 1,
-                              struct st_plugin_int *));
+  DBUG_RETURN(tmp);
 }
 
 
@@ -692,6 +702,7 @@
                        int *argc, char **argv, int report)
 {
   struct st_plugin_int tmp;
+  struct st_plugin_dl *plugin_dl;
   struct st_mysql_plugin *plugin;
   DBUG_ENTER("plugin_add");
   if (plugin_find_internal(name, MYSQL_ANY_PLUGIN))
@@ -704,10 +715,12 @@
   }
   /* Clear the whole struct to catch future extensions. */
   bzero((char*) &tmp, sizeof(tmp));
-  if (! (tmp.plugin_dl= plugin_dl_add(dl, report)))
+  if (!(plugin_dl= plugin_dl_add(dl, report)) ||
+      !(tmp.plugin_dl_idx= get_index_dynamic(&plugin_dl_array, 
+                                             (gptr)plugin_dl) + 1))
     DBUG_RETURN(TRUE);
   /* Find plugin by name */
-  for (plugin= tmp.plugin_dl->plugins; plugin->info; plugin++)
+  for (plugin= plugin_dl->plugins; plugin->info; plugin++)
   {
     uint name_len= strlen(plugin->name);
     if (plugin->type >= 0 && plugin->type < MYSQL_MAX_PLUGIN_TYPE_NUM
&&
@@ -833,8 +846,9 @@
   /* Free allocated strings before deleting the plugin. */
   plugin_vars_free_values(plugin->system_vars);
   hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin);
-  if (plugin->plugin_dl)
-    plugin_dl_del(&plugin->plugin_dl->dl);
+  if (plugin->plugin_dl_idx)
+    plugin_dl_del(&dynamic_element(&plugin_dl_array, plugin->plugin_dl_idx -
1, 
+                                   struct st_plugin_dl *)->dl);
   plugin->state= PLUGIN_IS_FREED;
   plugin_array_version++;
   rw_wrlock(&LOCK_system_variables_hash);
@@ -874,7 +888,7 @@
 
   for (idx= 0; idx < count; idx++)
   {
-    plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *);
+    plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
     if (plugin->state == PLUGIN_IS_DELETED && !plugin->ref_count)
     {
       /* change the status flag to prevent reaping by another thread */
@@ -911,7 +925,7 @@
   pi= plugin_ref_to_int(plugin);
 
 #ifdef DBUG_OFF
-  if (!pi->plugin_dl)
+  if (!pi->plugin_dl_idx)
     DBUG_VOID_RETURN;
 #else
   my_free((gptr) plugin, MYF(MY_WME));
@@ -1099,7 +1113,7 @@
   if (my_init_dynamic_array(&plugin_dl_array,
                             sizeof(struct st_plugin_dl),16,16) ||
       my_init_dynamic_array(&plugin_array,
-                            sizeof(struct st_plugin_int),16,16))
+                            sizeof(struct st_plugin_int *),16,16))
     goto err;
 
   for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
@@ -1185,7 +1199,7 @@
 
   for (i= 0; i < plugin_array.elements; i++)
   {
-    plugin_ptr= dynamic_element(&plugin_array, i, struct st_plugin_int *);
+    plugin_ptr= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
     if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED)
     {
       if (plugin_initialize(plugin_ptr))
@@ -1230,14 +1244,14 @@
 
   tmp->state= PLUGIN_IS_UNINITIALIZED;
   tmp->ref_count= 0;
-  tmp->plugin_dl= 0;
+  tmp->plugin_dl_idx= 0;
 
-  if (insert_dynamic(&plugin_array, (gptr)tmp))
+  if (!(*ptr= (struct st_plugin_int *)
+              memdup_root(&plugin_mem_root, (char *)tmp, 
+                          sizeof(struct st_plugin_int))) ||
+      insert_dynamic(&plugin_array, (gptr)ptr))
     DBUG_RETURN(1);
 
-  *ptr= dynamic_element(&plugin_array, plugin_array.elements - 1,
-                        struct st_plugin_int *);
-
   if (my_hash_insert(&plugin_hash[plugin->type],(byte*) *ptr))
     DBUG_RETURN(1);
 
@@ -1458,7 +1472,7 @@
       reap_plugins();
       for (i= free_slots= 0; i < count; i++)
       {
-        plugin= dynamic_element(&plugin_array, i, struct st_plugin_int *);
+        plugin= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
         switch (plugin->state) {
         case PLUGIN_IS_READY:
           plugin->state= PLUGIN_IS_DELETED;
@@ -1490,7 +1504,7 @@
     */
     for (i= 0; i < count; i++)
     {
-      plugins[i]= dynamic_element(&plugin_array, i, struct st_plugin_int *);
+      plugins[i]= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
       /* change the state to ensure no reaping races */
       if (plugins[i]->state == PLUGIN_IS_DELETED)
         plugins[i]->state= PLUGIN_IS_DYING;
@@ -1652,7 +1666,7 @@
     my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
     goto err;
   }
-  if (!plugin->plugin_dl)
+  if (!plugin->plugin_dl_idx)
   {
     push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
                  "Built-in plugins cannot be deleted,.");
@@ -1714,7 +1728,7 @@
   {
     for (idx= 0; idx < total; idx++)
     {
-      plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *);
+      plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
       plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
     }
   }
@@ -3138,7 +3152,7 @@
   if (initialized)
     for (uint idx= 0; idx < plugin_array.elements; idx++)
     {
-      p= dynamic_element(&plugin_array, idx, struct st_plugin_int *);
+      p= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
 
       if (!p->plugin->system_vars ||
           !(opt= construct_help_options(&mem_root, p)))

--- 1.16/sql/sql_plugin.h	2007-05-08 17:08:44 -07:00
+++ 1.17/sql/sql_plugin.h	2007-05-08 17:08:44 -07:00
@@ -71,7 +71,7 @@
 {
   LEX_STRING name;
   struct st_mysql_plugin *plugin;
-  struct st_plugin_dl *plugin_dl;
+  uint plugin_dl_idx;
   uint state;
   uint ref_count;               /* number of threads using the plugin */
   void *data;                   /* plugin type specific, e.g. handlerton */
@@ -87,7 +87,7 @@
 #ifdef DBUG_OFF
 typedef struct st_plugin_int *plugin_ref;
 #define plugin_decl(pi) ((pi)->plugin)
-#define plugin_dlib(pi) ((pi)->plugin_dl)
+#define plugin_dlib(pi) (plugin_dlib_by_index((pi)->plugin_dl_idx))
 #define plugin_data(pi,cast) ((cast)((pi)->data))
 #define plugin_name(pi) (&((pi)->name))
 #define plugin_state(pi) ((pi)->state)
@@ -95,7 +95,7 @@
 #else
 typedef struct st_plugin_int **plugin_ref;
 #define plugin_decl(pi) ((pi)[0]->plugin)
-#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
+#define plugin_dlib(pi) (plugin_dlib_by_index((pi)[0]->plugin_dl_idx))
 #define plugin_data(pi,cast) ((cast)((pi)[0]->data))
 #define plugin_name(pi) (&((pi)[0]->name))
 #define plugin_state(pi) ((pi)[0]->state)
@@ -128,6 +128,7 @@
 extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
 extern void plugin_thdvar_init(THD *thd);
 extern void plugin_thdvar_cleanup(THD *thd);
+extern struct st_plugin_dl *plugin_dlib_by_index(uint index);
 
 typedef my_bool (plugin_foreach_func)(THD *thd,
                                       plugin_ref plugin,
Thread
bk commit into 5.1 tree (acurtis:1.2511) BUG#27836antony9 May