[Commits] Rev 4005: MDEV-5364 mysql_upgrade should be more verbose. in file:///home/hf/wmar/mdev-5364/

holyfoot at askmonty.org holyfoot at askmonty.org
Sun Dec 15 13:59:39 EET 2013


At file:///home/hf/wmar/mdev-5364/

------------------------------------------------------------
revno: 4005
revision-id: holyfoot at askmonty.org-20131215104419-ks2enrs2tds0z4ti
parent: sergii at pisem.net-20131213120038-hjea4r5zp7sjuq8l
committer: Alexey Botchkov <holyfoot at askmonty.org>
branch nick: mdev-5364
timestamp: Sun 2013-12-15 14:44:19 +0400
message:
  MDEV-5364 mysql_upgrade should be more verbose.
          If the check_version_match() fails during the mysql_upgrade
          execution, it doesn't print the 'mysql' output.
          So the printing of the output added to the check_version_match()
          and also to the get_upgrade_info_file_name() functions.
-------------- next part --------------
=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2013-11-11 08:31:20 +0000
+++ b/client/mysql_upgrade.c	2013-12-15 10:44:19 +0000
@@ -163,6 +163,8 @@ static struct my_option my_long_options[
   {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 
+static int print_errors(DYNAMIC_STRING *ds_res);
+
 
 static void free_used_memory(void)
 {
@@ -603,6 +605,7 @@ static int get_upgrade_info_file_name(ch
                 &ds_datadir, FALSE) ||
       extract_variable_from_show(&ds_datadir, name))
   {
+    (void) print_errors(&ds_datadir);
     dynstr_free(&ds_datadir);
     DBUG_RETURN(1); /* Query failed */
   }
@@ -808,6 +811,40 @@ static void print_line(char* line)
 
 
 /*
+  Print errors returned from the mysql tool.
+  Don't show the expected error.
+  Counts the number of 'real' errors in the program output.
+*/
+
+static int print_errors(DYNAMIC_STRING *ds_res)
+{
+  int found_real_errors= 0;
+  /*
+     Scan each line of the result for real errors
+     and ignore the expected one(s) like "Duplicate column name",
+     "Unknown column" and "Duplicate key name" since they just
+     indicate the system tables are already up to date
+  */
+  char *line= ds_res->str;
+  do
+  {
+    if (!is_expected_error(line))
+    {
+      /* Something unexpected failed, dump error line to screen */
+      found_real_errors++;
+      print_line(line);
+    }
+    else if (strncmp(line, "WARNING", 7) == 0)
+    {
+      print_line(line);
+    }
+  } while ((line= get_line(line)) && *line);
+
+  return found_real_errors;
+}
+
+
+/*
   Update all system tables in MySQL Server to current
   version using "mysql" to execute all the SQL commands
   compiled into the mysql_fix_privilege_tables array
@@ -815,7 +852,7 @@ static void print_line(char* line)
 
 static int run_sql_fix_privilege_tables(void)
 {
-  int found_real_errors= 0;
+  int found_real_errors;
   DYNAMIC_STRING ds_result;
   DBUG_ENTER("run_sql_fix_privilege_tables");
 
@@ -826,29 +863,7 @@ static int run_sql_fix_privilege_tables(
   run_query(mysql_fix_privilege_tables,
             &ds_result, /* Collect result */
             TRUE);
-
-  {
-    /*
-      Scan each line of the result for real errors
-      and ignore the expected one(s) like "Duplicate column name",
-      "Unknown column" and "Duplicate key name" since they just
-      indicate the system tables are already up to date
-    */
-    char *line= ds_result.str;
-    do
-    {
-      if (!is_expected_error(line))
-      {
-        /* Something unexpected failed, dump error line to screen */
-        found_real_errors++;
-        print_line(line);
-      }
-      else if (strncmp(line, "WARNING", 7) == 0)
-      {
-        print_line(line);
-      }
-    } while ((line= get_line(line)) && *line);
-  }
+  found_real_errors= print_errors(&ds_result);
 
   dynstr_free(&ds_result);
   DBUG_RETURN(found_real_errors);
@@ -895,6 +910,7 @@ static int check_version_match(void)
                 &ds_version, FALSE) ||
       extract_variable_from_show(&ds_version, version_str))
   {
+    (void) print_errors(&ds_version);
     dynstr_free(&ds_version);
     return 1;                                   /* Query failed */
   }



More information about the commits mailing list