List:Commits« Previous MessageNext Message »
From:Ian Greenhoe Date:August 24 2006 11:02am
Subject:bk commit into 5.0 tree (igreenhoe:1.2251) BUG#20455
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of greenman. When greenman 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, 2006-08-24 04:02:46-07:00, igreenhoe@stripped +4 -0
  Fix for bug #20455 "mysqldumpslow gives strong error message when
  file parameter is missing"
  
  Problem:  mysqldumpslow was returning a confusing error message when
  no configuration file was found.  This was due to a lack of an error
  result from mysql_print_defaults on that error.  mysql_print_defaults
  in turn needed this error from load_defaults(), which needed the
  error from my_search_option_files().
  
  Solution: Add extra error return to my_print_defaults,
  load_defaults(), and my_search_option_files().  Add better error
  message to mysqldumpslow on this error.

  extra/my_print_defaults.c@stripped, 2006-08-24 04:02:42-07:00, igreenhoe@stripped +4 -5
    Updated to use new error return from load_defaults().

  mysys/default.c@stripped, 2006-08-24 04:02:42-07:00, igreenhoe@stripped +22 -8
    Added additional warning to load_defaults() and
    my_search_option_files().
    
    Warning (#2) is generated if another error hasn't been generated
    (such as a specified file being missing -- #1), and if
    my_search_option_files does not find *any* of the default config
    files (such as /etc/my.cnf ~/.my.cnf and /usr/local/mysql/my.cnf).

  ndb/src/mgmsrv/InitConfigFileParser.cpp@stripped, 2006-08-24 04:02:42-07:00, igreenhoe@stripped +1 -1
    Changed to ignore the "no defaults files" error from load_defaults().

  scripts/mysqldumpslow.sh@stripped, 2006-08-24 04:02:42-07:00, igreenhoe@stripped +1 -0
    Updated to use new error return from my_print_defaults.

# 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:	igreenhoe
# Host:	anubis.greendragongames.com
# Root:	/home/greenman/workspace-mysql/mysql/bug-5.0-20455

--- 1.23/extra/my_print_defaults.c	2006-08-24 04:02:54 -07:00
+++ 1.24/extra/my_print_defaults.c	2006-08-24 04:02:54 -07:00
@@ -165,15 +165,14 @@
   if ((error= load_defaults(config_file, (const char **) load_default_groups,
 			   &count, &arguments)))
   {
-    if (verbose && opt_defaults_file_used)
+    if (verbose)
     {
-      if (error == 1)
+      if (opt_defaults_file_used && error == 1)
 	fprintf(stderr, "WARNING: Defaults file '%s' not found!\n",
 		config_file);
-      /* This error is not available now. For the future */
       if (error == 2)
-	fprintf(stderr, "WARNING: Defaults file '%s' is not a regular file!\n",
-		config_file);
+        fprintf(stderr, "WARNING: No default configuration files found, and "
+                "none were specified!\n");
     }
     error= 2;
   }

--- 1.82/mysys/default.c	2006-08-24 04:02:54 -07:00
+++ 1.83/mysys/default.c	2006-08-24 04:02:54 -07:00
@@ -115,7 +115,8 @@
 
   RETURN
     0  ok
-    1  given cinf_file doesn't exist
+    1  given conf_file doesn't exist
+    2  no specific conf_file given, and default files don't exist.
 
     The global variable 'defaults_group_suffix' is updated with value for
     --defaults_group_suffix
@@ -127,6 +128,7 @@
 {
   const char **dirs, *forced_default_file, *forced_extra_defaults;
   int error= 0;
+  my_bool conf_files_exist= 1;
   DBUG_ENTER("my_search_option_files");
 
   /* Check if we want to force the use a specific default file */
@@ -204,12 +206,19 @@
   }
   else
   {
+    conf_files_exist= 0;
+
     for (dirs= default_directories ; *dirs; dirs++)
     {
       if (**dirs)
       {
-	if (search_default_file(func, func_ctx, *dirs, conf_file) < 0)
-	  goto err;
+        int temp;
+        if ((temp= search_default_file(func, func_ctx, *dirs,
+                                       conf_file)) < 0)
+          goto err;
+
+        if (temp == 0)
+          conf_files_exist= 1;
       }
       else if (defaults_extra_file)
       {
@@ -222,10 +231,15 @@
                   defaults_extra_file);
           goto err;
         }
+
+        conf_files_exist= 1;
       }
     }
   }
 
+  if ((error == 0) && !conf_files_exist)
+    error= 2;
+
   DBUG_RETURN(error);
 
 err:
@@ -356,6 +370,7 @@
    RETURN
      0	ok
      1	The given conf_file didn't exists
+     2  no specific conf_file given, and default files don't exist.
 */
 
 
@@ -414,7 +429,7 @@
                                 handle_default_option, (void *) &ctx);
   /*
     Here error contains <> 0 only if we have a fully specified conf_file
-    or a forced default file
+    or a forced default file, or no default files found.
   */
   if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+
 			       (args.elements + *argc +1) *sizeof(char*))))
@@ -487,10 +502,9 @@
   for (ext= (char**) exts_to_use; *ext; *ext++)
   {
     int error;
-    if ((error= search_default_file_with_ext(opt_handler, handler_ctx,
-                                             dir, *ext,
-					     config_file, 0)) < 0)
-      return error;
+    error= search_default_file_with_ext(opt_handler, handler_ctx, dir,
+                                        *ext, config_file, 0);
+    return error;
   }
   return 0;
 }

--- 1.26/ndb/src/mgmsrv/InitConfigFileParser.cpp	2006-08-24 04:02:54 -07:00
+++ 1.27/ndb/src/mgmsrv/InitConfigFileParser.cpp	2006-08-24 04:02:54 -07:00
@@ -719,7 +719,7 @@
   defaults_extra_file = save_extra_file;
   defaults_group_suffix = save_group_suffix;
   
-  if (ret == 0)
+  if (ret != 1)
   {
     return handle_options(&argc, &tmp, options.getBase(), parse_mycnf_opt);
   }

--- 1.8/scripts/mysqldumpslow.sh	2006-08-24 04:02:54 -07:00
+++ 1.9/scripts/mysqldumpslow.sh	2006-08-24 04:02:54 -07:00
@@ -35,6 +35,7 @@
 
 unless (@ARGV) {
     my $defaults   = `my_print_defaults mysqld`;
+    die "No default configuration files found.\n" if 2 == ($? >> 8);
     my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
 	or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
     warn "basedir=$basedir\n" if $opt{v};
Thread
bk commit into 5.0 tree (igreenhoe:1.2251) BUG#20455Ian Greenhoe24 Aug