List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:March 16 2009 11:43am
Subject:bzr commit into mysql-6.0-bugteam branch (Alexey.Kopytov:3116)
View as plain text  
#At file:///Users/kaa/src/bzr/bugteam/mysql-6.0-bugteam/ based on
revid:ramil@stripped

 3116 Alexey Kopytov	2009-03-16 [merge]
      Manual merge mysql-5.1-bugteam -> mysql-6.0-bugteam.
      Reverted all instance manager changes since it was 
      removed from 6.0.
      modified:
        include/my_sys.h
        mysys/default.c
        sql-common/client.c
        sql/sql_plugin.cc

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2009-03-09 12:17:41 +0000
+++ b/include/my_sys.h	2009-03-16 10:42:04 +0000
@@ -895,14 +895,17 @@ extern void *memdup_root(MEM_ROOT *root,
 extern int get_defaults_options(int argc, char **argv,
                                 char **defaults, char **extra_defaults,
                                 char **group_suffix);
+extern int my_load_defaults(const char *conf_file, const char **groups,
+                            int *argc, char ***argv, const char ***);
 extern int load_defaults(const char *conf_file, const char **groups,
-			 int *argc, char ***argv);
+                         int *argc, char ***argv);
 extern int modify_defaults_file(const char *file_location, const char *option,
                                 const char *option_value,
                                 const char *section_name, int remove_option);
 extern int my_search_option_files(const char *conf_file, int *argc,
                                   char ***argv, uint *args_used,
-                                  Process_option_func func, void *func_ctx);
+                                  Process_option_func func, void *func_ctx,
+                                  const char **default_directories);
 extern void free_defaults(char **argv);
 extern void my_print_default_files(const char *conf_file);
 extern void print_defaults(const char *conf_file, const char **groups);

=== modified file 'mysys/default.c'
--- a/mysys/default.c	2009-02-24 11:56:59 +0000
+++ b/mysys/default.c	2009-03-16 10:42:04 +0000
@@ -152,7 +152,7 @@ static char *remove_end_comment(char *pt
 
 int my_search_option_files(const char *conf_file, int *argc, char ***argv,
                            uint *args_used, Process_option_func func,
-                           void *func_ctx)
+                           void *func_ctx, const char **default_directories)
 {
   const char **dirs, *forced_default_file, *forced_extra_defaults;
   int error= 0;
@@ -359,18 +359,46 @@ int get_defaults_options(int argc, char 
   return org_argc - argc;
 }
 
+/*
+  Wrapper around my_load_defaults() for interface compatibility.
+
+  SYNOPSIS
+    load_defaults()
+    conf_file			Basename for configuration file to search for.
+    				If this is a path, then only this file is read.
+    groups			Which [group] entrys to read.
+				Points to an null terminated array of pointers
+    argc			Pointer to argc of original program
+    argv			Pointer to argv of original program
+
+  NOTES
+
+    This function is NOT thread-safe as it uses a global pointer internally.
+    See also notes for my_load_defaults().
+
+  RETURN
+    0 ok
+    1 The given conf_file didn't exists
+*/
+int load_defaults(const char *conf_file, const char **groups,
+                  int *argc, char ***argv)
+{
+  return my_load_defaults(conf_file, groups, argc, argv, &default_directories);
+}
 
 /*
   Read options from configurations files
 
   SYNOPSIS
-    load_defaults()
+    my_load_defaults()
     conf_file			Basename for configuration file to search for.
     				If this is a path, then only this file is read.
     groups			Which [group] entrys to read.
 				Points to an null terminated array of pointers
     argc			Pointer to argc of original program
     argv			Pointer to argv of original program
+    default_directories         Pointer to a location where a pointer to the list
+                                of default directories will be stored
 
   IMPLEMENTATION
 
@@ -386,13 +414,18 @@ int get_defaults_options(int argc, char 
     that was put in *argv
 
    RETURN
-     0	ok
-     1	The given conf_file didn't exists
+     - If successful, 0 is returned. If 'default_directories' is not NULL,
+     a pointer to the array of default directory paths is stored to a location
+     it points to. That stored value must be passed to my_search_option_files()
+     later.
+     
+     - 1 is returned if the given conf_file didn't exist. In this case, the
+     value pointed to by default_directories is undefined.
 */
 
 
-int load_defaults(const char *conf_file, const char **groups,
-                  int *argc, char ***argv)
+int my_load_defaults(const char *conf_file, const char **groups,
+                  int *argc, char ***argv, const char ***default_directories)
 {
   DYNAMIC_ARRAY args;
   TYPELIB group;
@@ -402,10 +435,11 @@ int load_defaults(const char *conf_file,
   MEM_ROOT alloc;
   char *ptr,**res;
   struct handle_option_ctx ctx;
+  const char **dirs;
   DBUG_ENTER("load_defaults");
 
   init_alloc_root(&alloc,512,0);
-  if ((default_directories= init_default_directories(&alloc)) == NULL)
+  if ((dirs= init_default_directories(&alloc)) == NULL)
     goto err;
   /*
     Check if the user doesn't want any default option processing
@@ -426,6 +460,8 @@ int load_defaults(const char *conf_file,
     (*argc)--;
     *argv=res;
     *(MEM_ROOT*) ptr= alloc;			/* Save alloc root for free */
+    if (default_directories)
+      *default_directories= dirs;
     DBUG_RETURN(0);
   }
 
@@ -444,7 +480,8 @@ int load_defaults(const char *conf_file,
   ctx.group= &group;
 
   error= my_search_option_files(conf_file, argc, argv, &args_used,
-                                handle_default_option, (void *) &ctx);
+                                handle_default_option, (void *) &ctx,
+                                dirs);
   /*
     Here error contains <> 0 only if we have a fully specified conf_file
     or a forced default file
@@ -490,6 +527,10 @@ int load_defaults(const char *conf_file,
     puts("");
     exit(0);
   }
+
+  if (error == 0 && default_directories)
+    *default_directories= dirs;
+
   DBUG_RETURN(error);
 
  err:
@@ -895,15 +936,11 @@ void my_print_default_files(const char *
     fputs(conf_file,stdout);
   else
   {
-    /*
-      If default_directories is already initialized, use it.  Otherwise,
-      use a private MEM_ROOT.
-    */
-    const char **dirs = default_directories;
+    const char **dirs;
     MEM_ROOT alloc;
     init_alloc_root(&alloc,512,0);
 
-    if (!dirs && (dirs= init_default_directories(&alloc)) == NULL)
+    if ((dirs= init_default_directories(&alloc)) == NULL)
     {
       fputs("Internal error initializing default directories list", stdout);
     }

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2009-02-25 10:03:18 +0000
+++ b/sql-common/client.c	2009-03-16 10:42:04 +0000
@@ -1129,7 +1129,7 @@ void mysql_read_default_options(struct s
   argc=1; argv=argv_buff; argv_buff[0]= (char*) "client";
   groups[0]= (char*) "client"; groups[1]= (char*) group; groups[2]=0;
 
-  load_defaults(filename, groups, &argc, &argv);
+  my_load_defaults(filename, groups, &argc, &argv, NULL);
   if (argc != 1)				/* If some default option */
   {
     char **option=argv;

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2009-03-13 09:42:54 +0000
+++ b/sql/sql_plugin.cc	2009-03-16 10:42:04 +0000
@@ -1654,7 +1654,7 @@ bool mysql_install_plugin(THD *thd, cons
   pthread_mutex_lock(&LOCK_plugin);
   rw_wrlock(&LOCK_system_variables_hash);
 
-  load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv);
+  my_load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, NULL);
   error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER);
   if (argv)
     free_defaults(argv);

Thread
bzr commit into mysql-6.0-bugteam branch (Alexey.Kopytov:3116)Alexey Kopytov16 Mar 2009