Bug #54439 Unable to identify failure cases of mysql_upgrade
Submitted: 11 Jun 2010 17:49 Modified: 15 Jun 2010 14:37
Reporter: Matthew Montgomery Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Installing Severity:S4 (Feature request)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any

[11 Jun 2010 17:49] Matthew Montgomery
Description:
The exist status of mysql_upgrade does not give a distinct codes to programmatically identify failure causes.

How to repeat:
Run mysql_upgrade twice in a row

matt@silo:/data/mysql/sandbox/7.0.13$ mysql_upgrade
[...]
Running 'mysql_fix_privilege_tables'...
OK
matt@silo:/data/mysql/sandbox/7.0.13$ echo $?
0
matt@silo:/data/mysql/sandbox/7.0.13$ mysql_upgrade 
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
This installation of MySQL is already upgraded to 5.1.41-ndb-7.0.13, use --force if you still need to run mysql_upgrade
matt@silo:/data/mysql/sandbox/7.0.13$ echo $?
1

Suggested fix:
Change the exit status of mysql_upgrade from re-attempt after successful completed upgrade to 2.

Patch to follow.
[11 Jun 2010 18:14] MySQL Verification Team
--- mysql-5.1-telco-6.3/client/mysql_upgrade.c	2010-06-10 11:12:00.768745000 -0500
+++ mysql-5.1-telco-6.3-upgrade/client/mysql_upgrade.c	2010-06-11 13:14:15.704904398 -0500
@@ -857,7 +857,9 @@
     printf("This installation of MySQL is already upgraded to %s, "
            "use --force if you still need to run mysql_upgrade\n",
            MYSQL_SERVER_VERSION);
-    die(NULL);
+    free_used_memory();
+    my_end(my_end_arg);
+    exit(2);
   }
 
   /*