Bug #31605 mysql_upgrade relies on Linux /proc filesystem when not running on Windows
Submitted: 15 Oct 2007 12:40 Modified: 14 Aug 2008 3:23
Reporter: Daniel Fischer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:5.0-bk, 5.0.45 OS:Any (!(Windows | Linux))
Assigned to: Chad MILLER CPU Architecture:Any
Triage: D1 (Critical) / R1 (None/Negligible) / E3 (Medium)

[15 Oct 2007 12:40] Daniel Fischer
Description:
mysql_upgrade fails on OS that satisfy !(Linux | Windows) with output similar to:

xserve-e:~ mysqldev$ mysql_upgrade
Looking for 'mysql' in: mysql
FATAL ERROR: Can't find 'mysql'

This is because of the following lines in get_full_path_to_executable():

  ret= (my_readlink(path, "/proc/self/exe", MYF(0)) != 0);
  /* Might also want to try with /proc/$$/exe if the above fails */

The /proc filesystem is specific to Linux. It is either not present on other OS or does not contain the same information.

How to repeat:
Install MySQL 5.0.45 on Mac OS X or other UNIX and run "mysql_upgrade", NOT specifying the full path.

Suggested fix:
There's a trivial workaround, just specify the full path to the executable when running it, e.g. '/usr/bin/mysql_upgrade' instead of 'mysql_upgrade'.

Suggested fix is asking the user to run the program again, specifying the full path, if it can't be determined in any other way. Of course we should not even try /proc on !Linux.

We can't just run any mysql executable in PATH since it might be the wrong one.
[15 Oct 2007 17:30] Sveta Smirnova
Thank you for the report.

Verified as described.
[28 Nov 2007 7:02] Sveta Smirnova
Bug #32689 was marked as duplicate of this one.
[27 Mar 2008 22:44] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44542

ChangeSet@1.2598, 2008-03-27 18:44:42-04:00, cmiller@zippy.cornsilk.net +1 -0
  Bug#31605: mysql_upgrade relies on Linux /proc filesystem when not \
  	running on Windows
  
  We used two OS-specific methods of looking up the executable 
  name, which don't work outside of those two kinds of OSes 
  (Linux+Solaris and Windows).
  
  We assume that if the user ran this program with a certain 
  name, we can run the other sibling programs with a similar name.
[7 Aug 2008 16:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51127

2655 Chad MILLER	2008-08-07
      Bug#31605: mysql_upgrade relies on Linux /proc filesystem when not \
      	running on Windows
      
      We used two OS-specific methods of looking up the executable 
      name, which don't work outside of those two kinds of OSes 
      (Linux+Solaris and Windows).
      
      We assume that if the user ran this program with a certain 
      name, we can run the other sibling programs with a similar name.
      
      (re-patch in bzr)
[7 Aug 2008 20:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51141

2686 Chad MILLER	2008-08-07 [merge]
      merge from local 5.0 fix tree.
[7 Aug 2008 21:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51150

2749 Chad MILLER	2008-08-07 [merge]
      Merge from local 5.1-bugteam.
[11 Aug 2008 11:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51276

2656 Kristofer Pettersson	2008-08-11 [merge]
      Automerge
[12 Aug 2008 14:37] Bugs System
Pushed into 6.0.7-alpha  (revid:chad@mysql.com-20080807162439-r1t9n6z7habzif9d) (version source revid:davi.arnaut@sun.com-20080812141852-8e6knbqclpfd8irn) (pib:3)
[12 Aug 2008 15:09] Bugs System
Pushed into 5.1.28  (revid:chad@mysql.com-20080807162439-r1t9n6z7habzif9d) (version source revid:davi.arnaut@sun.com-20080812142843-he05ncsggstbn57z) (pib:3)
[12 Aug 2008 18:51] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51449

2647 Davi Arnaut	2008-08-12 [merge]
      Merge mysql-5.0-bugteam into mysql-5.0
[12 Aug 2008 19:09] Bugs System
Pushed into 5.0.68  (revid:chad@mysql.com-20080807162439-r1t9n6z7habzif9d) (version source revid:davi.arnaut@sun.com-20080812185100-d47qb8mz2ye6pe6b) (pib:3)
[14 Aug 2008 3:23] Paul Dubois
Noted in 5.0.68, 5.1.28, 6.0.7 changelogs.

mysql_upgrade attempted to use the /proc filesystem even on systems
that do not have it.
[14 Aug 2008 7:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51602

2684 He Zhenxing	2008-08-14 [merge]
      Merge 6.0 -> 6.0-rpl-testfixes
[14 Aug 2008 7:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51603

2684 He Zhenxing	2008-08-14 [merge]
      Merge 6.0 -> 6.0-rpl-testfixes
[28 Aug 2008 20:14] Bugs System
Pushed into 6.0.7-alpha  (revid:cbell@mysql.com-20080822132131-uveo6wiuecy6m2b8) (version source revid:cbell@mysql.com-20080822132131-uveo6wiuecy6m2b8) (pib:3)
[14 Sep 2008 3:20] Bugs System
Pushed into 6.0.7-alpha  (revid:chad@mysql.com-20080807162439-r1t9n6z7habzif9d) (version source revid:sven@mysql.com-20080818175803-c1nutd5773r6b4gd) (pib:3)