List:Internals« Previous MessageNext Message »
From:svoj Date:September 27 2005 11:14am
Subject:bk commit into 5.0 tree (svoj:1.1913)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of svoj. When svoj 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
  1.1913 05/09/27 16:14:15 svoj@stripped +4 -0
  WL#2575 - Fulltext: Parser plugin for FTS
  - Plugin reference counter added.
  - Plugin state (FREED/DELETED/UNINITIALIZED/READY) added.

  sql/table.cc
    1.181 05/09/27 16:14:11 svoj@stripped +9 -1
    Add a reference to parser plugin when table is opened.
    Remove a reference when table is closed.

  sql/sql_yacc.yy
    1.417 05/09/27 16:14:11 svoj@stripped +1 -1
    Add a reference to plugin.

  sql/sql_plugin.h
    1.7 05/09/27 16:14:11 svoj@stripped +5 -1
    Plugin reference counter added.
    plugin_find can now add reference to plugin.
    plugin_release removes reference added by plugin_find.
    Added plugin state (FREED/DELETED/UNINITIALIZED/READY).

  sql/sql_plugin.cc
    1.11 05/09/27 16:14:11 svoj@stripped +50 -12
    Plugin reference counter added.
    plugin_find can now add reference to plugin.
    plugin_release removes reference added by plugin_find.
    Added plugin state (FREED/DELETED/UNINITIALIZED/READY).

# 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:	svoj
# Host:	svoj-laptop.mysql.com
# Root:	/home/svoj/devel/mysql/CNET/mysql-5.0

--- 1.416/sql/sql_yacc.yy	2005-09-23 20:43:31 +05:00
+++ 1.417/sql/sql_yacc.yy	2005-09-27 16:14:11 +05:00
@@ -2836,7 +2836,7 @@
 	| WITH PARSER_SYM IDENT_sys
           {
             struct st_plugin_int *plugin;
-            if ((plugin= plugin_find(&$3, MYSQL_FTPARSER_PLUGIN)))
+            if ((plugin= plugin_find(&$3, MYSQL_FTPARSER_PLUGIN, TRUE)))
               $$= plugin;
             else
             {

--- 1.180/sql/table.cc	2005-09-22 19:56:27 +05:00
+++ 1.181/sql/table.cc	2005-09-27 16:14:11 +05:00
@@ -368,7 +368,7 @@
         }
         parser_name.str= next_chunk;
         parser_name.length= strlen(next_chunk);
-        keyinfo->parser= plugin_find(&parser_name, MYSQL_FTPARSER_PLUGIN);
+        keyinfo->parser= plugin_find(&parser_name, MYSQL_FTPARSER_PLUGIN, TRUE);
         if (! keyinfo->parser)
         {
           my_free(buff, MYF(0));
@@ -966,7 +966,15 @@
 int closefrm(register TABLE *table)
 {
   int error=0;
+  uint idx;
+  KEY *key_info;
   DBUG_ENTER("closefrm");
+  key_info= table->key_info;
+  for (idx= table->s->keys; idx; idx--, key_info++)
+  {
+    if (key_info->flags & HA_USES_PARSER)
+      plugin_release(&key_info->parser->name);
+  }
   if (table->db_stat)
     error=table->file->close();
   my_free((char*) table->alias, MYF(MY_ALLOW_ZERO_PTR));

--- 1.10/sql/sql_plugin.cc	2005-09-23 19:49:37 +05:00
+++ 1.11/sql/sql_plugin.cc	2005-09-27 16:14:11 +05:00
@@ -19,6 +19,11 @@
 #define REPORT_TO_LOG  1
 #define REPORT_TO_USER 2
 
+#define PLUGIN_IS_FREED         0
+#define PLUGIN_IS_DELETED       1
+#define PLUGIN_IS_UNINITIALIZED 2
+#define PLUGIN_IS_READY         3
+
 char *opt_plugin_dir;
 static const char *plugin_interface_version_sym=
                    "_mysql_plugin_interface_version_";
@@ -206,7 +211,8 @@
   {
     struct st_plugin_int *tmp= dynamic_element(&plugin_array, i,
                                                struct st_plugin_int *);
-    if ((type < 0 || type == tmp->plugin->type) &&
+    if (tmp->state == PLUGIN_IS_READY &&
+        (type < 0 || type == tmp->plugin->type) &&
         ! my_strnncoll(system_charset_info,
                        (const uchar *)name->str, name->length,
                        (const uchar *)tmp->name.str, tmp->name.length))
@@ -216,17 +222,39 @@
 }
 
 
-struct st_plugin_int *plugin_find(LEX_STRING *name, int type)
+struct st_plugin_int *plugin_find(LEX_STRING *name, int type, my_bool mark_used)
 {
   struct st_plugin_int *rc;
   DBUG_ENTER("plugin_find");
-  rw_rdlock(&THR_LOCK_plugin);
-  rc= plugin_find_internal(name, type);
+  if (mark_used)
+  {
+    rw_wrlock(&THR_LOCK_plugin);
+    if ((rc= plugin_find_internal(name, type)))
+      rc->ref_count++;
+  }
+  else
+  {
+    rw_rdlock(&THR_LOCK_plugin);
+    rc= plugin_find_internal(name, type);
+  }
   rw_unlock(&THR_LOCK_plugin);
   DBUG_RETURN(rc);
 }
 
 
+void plugin_release(LEX_STRING *name)
+{
+  struct st_plugin_int *plugin;
+  DBUG_ENTER("plugin_release");
+  rw_wrlock(&THR_LOCK_plugin);
+  plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN);
+  DBUG_ASSERT(plugin && plugin->ref_count);
+  plugin->ref_count--;
+  rw_unlock(&THR_LOCK_plugin);
+  DBUG_VOID_RETURN;
+}
+
+
 static my_bool plugin_add(LEX_STRING *name, LEX_STRING *dl, int report)
 {
   struct st_plugin_int tmp;
@@ -254,6 +282,8 @@
       tmp.plugin= plugin;
       tmp.name.str= (char *)plugin->name;
       tmp.name.length= name_len;
+      tmp.ref_count= 0;
+      tmp.state= PLUGIN_IS_UNINITIALIZED;
       if (insert_dynamic(&plugin_array, (gptr)&tmp))
       {
         if (report & REPORT_TO_USER)
@@ -282,12 +312,13 @@
   {
     struct st_plugin_int *tmp= dynamic_element(&plugin_array, i,
                                                struct st_plugin_int *);
-    if (! my_strnncoll(system_charset_info,
+    if (tmp->state != PLUGIN_IS_FREED &&
+        ! my_strnncoll(system_charset_info,
                        (const uchar *)name->str, name->length,
                        (const uchar *)tmp->name.str, tmp->name.length))
     {
       plugin_dl_del(&tmp->plugin_dl->dl);
-      bzero(tmp, sizeof(struct st_plugin_int));
+      tmp->state= PLUGIN_IS_FREED;
       break;
     }
   }
@@ -303,7 +334,7 @@
   {
     struct st_plugin_int *tmp= dynamic_element(&plugin_array, i,
                                                struct st_plugin_int *);
-    if (tmp->plugin->init)
+    if (tmp->state == PLUGIN_IS_UNINITIALIZED && tmp->plugin->init)
     {
       DBUG_PRINT("info", ("Initializing plugin: '%s'", tmp->name.str));
       if (tmp->plugin->init())
@@ -315,6 +346,8 @@
         plugin_del(&tmp->name);
       }
     }
+    if (tmp->state == PLUGIN_IS_UNINITIALIZED)
+      tmp->state= PLUGIN_IS_READY;
   }
   DBUG_VOID_RETURN;
 }
@@ -328,14 +361,18 @@
   {
     struct st_plugin_int *tmp= dynamic_element(&plugin_array, i,
                                                struct st_plugin_int *);
-    if (tmp->plugin && tmp->plugin->deinit)
+    if (tmp->state == PLUGIN_IS_READY)
     {
-      DBUG_PRINT("info", ("Deinitializing plugin: '%s'", tmp->name.str));
-      if (tmp->plugin->deinit())
+      if (tmp->plugin->deinit)
       {
-        DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
-                               tmp->name.str))
+        DBUG_PRINT("info", ("Deinitializing plugin: '%s'", tmp->name.str));
+        if (tmp->plugin->deinit())
+        {
+          DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
+                                 tmp->name.str))
+        }
       }
+      tmp->state= PLUGIN_IS_UNINITIALIZED;
     }
   }
   DBUG_VOID_RETURN;
@@ -461,6 +498,7 @@
       my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, ER(ER_UNKNOWN_ERROR));
       goto err;
     }
+    tmp->state= PLUGIN_IS_READY;
   }
   if (! (table = open_ltable(thd, &tables, TL_WRITE)))
     goto deinit;

--- 1.6/sql/sql_plugin.h	2005-09-22 19:56:27 +05:00
+++ 1.7/sql/sql_plugin.h	2005-09-27 16:14:11 +05:00
@@ -31,12 +31,16 @@
   LEX_STRING name;
   struct st_mysql_plugin *plugin;
   struct st_plugin_dl *plugin_dl;
+  int state;
+  uint ref_count;
 };
 
 extern char *opt_plugin_dir;
 extern void plugin_init(void);
 extern void plugin_free(void);
-extern st_plugin_int *plugin_find(LEX_STRING *name, int type);
+extern st_plugin_int *plugin_find(LEX_STRING *name, int type,
+                                  my_bool mark_used);
+extern void plugin_release(LEX_STRING *name);
 extern my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl);
 extern my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name);
 #endif
Thread
bk commit into 5.0 tree (svoj:1.1913)svoj27 Sep