Bug #69826 mysql_upgrade could return 0 when it succeeds
Submitted: 23 Jul 2013 12:50 Modified: 18 Dec 2013 10:55
Reporter: Michal Hrusecky Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:5.6.12 OS:Any
Assigned to: Georgi Kodinov CPU Architecture:Any

[23 Jul 2013 12:50] Michal Hrusecky
Description:
mysql_upgrade currently returns 1 (aka error) if trying to upgrade table that is already upgraded. Better idea would be to return 0 (aka success) as mostly people running it are interested into whether they need to fix their table, not whether it was upgraded.

How to repeat:
Run mysql_upgrade on already upgraded server.

Suggested fix:
Change exit code from 1 to 0 if database is already upgraded.
[18 Nov 2013 10:55] Georgi Kodinov
Michal,

I did some reading on this one. And I have a question (below).

All programs should return non-zero if the was an error in their operation. And 0 if they've succeeded. That's what the unix guidelines say (iirc).

Now what is an mysql_upgrade error and what isn't ?
http://dev.mysql.com/doc/refman/5.6/en/mysql-upgrade.html says :
"mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MySQL Server. mysql_upgrade also upgrades the system tables so that you can take advantage of new privileges or capabilities that might have been added.

mysql_upgrade should be executed each time you upgrade MySQL.

If mysql_upgrade finds that a table has a possible incompatibility, it performs a table check and, if problems are found, attempts a table repair. If the table cannot be repaired, see Section 2.11.4, “Rebuilding or Repairing Tables or Indexes” for manual table repair strategies."
...
"All checked and repaired tables are marked with the current MySQL version number. This ensures that next time you run mysql_upgrade with the same version of the server, it can tell whether there is any need to check or repair the table again."

From the above I deduce that mysql_upgrade should *NOT* consider performing no upgrade an error (as it's expected and defined what shall it do when run against a server that's already upgraded). Thus the direct request in this bug has a point.

However there's one thing that the unix specification is missing: that programs can end up in a 3d category, and not only success or failure. It's success with warnings. And the fact that this program is run but didn't do anything is IMHO worthy of a warning. And this need was apparently considered so high that mysql_upgrade was coded to promote this warning to an error.

And hence my question to you. Would it be enough for your purposes if mysql_upgrade returns a very specific error code in this (and no other) condition ? 
As I would really love to keep this promotion in effect and signify that it's not really a promoted use case.
[19 Dec 2013 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".