Bug #26639 mysql_upgrade exits successfully even if external command failed
Submitted: 26 Feb 2007 15:12 Modified: 8 May 2007 0:57
Reporter: Michal Marek Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0.33, 5.1, 5.2 OS:Linux (Linux)
Assigned to: Magnus BlÄudd
Tags: Contribution

[26 Feb 2007 15:12] Michal Marek
Description:
See subject.

How to repeat:
shell> mysql_upgrade   --basedir=/usr; echo $?
/usr/bin/mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) when trying to connect
Error executing '/usr/bin/mysqlcheck --check-upgrade --all-databases --auto-repair --user=root'
0

Suggested fix:
The problem is that system() doesn't return the exit status of the command, but the status that wait() returns, which has to be passed to the W* macros to get a meaningfull value.

The second problem is that after fixing the system() handling, mysql_upgrade will start failing ;-), because the fix_privilege_tables.sql script will often cause "Duplicate column" errors that aren't real errors. So in this case it would be IMO better to set ret= 0 and exist sucessfully.

I'll attach a patch.
[26 Feb 2007 15:14] Michal Marek
suggested patch

Attachment: mysql-5.0.33-mysql_upgrade.patch (text/x-patch), 950 bytes.

[28 Feb 2007 10:49] Sveta Smirnova
Thank you for the report.

Verified as described. All versions are affected.
[26 Apr 2007 11:35] Bugs System
Pushed into 5.0.42
[26 Apr 2007 11:36] Bugs System
Pushed into 5.1.18-beta
[8 May 2007 0:57] Paul Dubois
Noted in 5.0.42, 5.1.18 changelogs.

mysql_upgrade did not detect failure of external commands that it 
runs.