Bug #25060 universal binary compilation under MacOS X leads to non working PASSWORD() funct
Submitted: 14 Dec 2006 9:48 Modified: 25 Dec 2006 18:56
Reporter: Andreas Fink Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.0.27 OS:MacOS (MacOS X 10.4.8)
Assigned to: CPU Architecture:Any

[14 Dec 2006 9:48] Andreas Fink
Description:
compiling MySQL for MacOS X dual architecture on intel and then running it on power pc and accessing it from intel shows that passwords are not working. connection with empty password looks ok though.

on intel where it has been compiled:

mysql> select password('test');
+-------------------------------------------+
| password('test')                          |
+-------------------------------------------+
| *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 | 
+-------------------------------------------+
1 row in set (0.27 sec)

on power pc (but compiled on intel)

mysql> select password('test');
+-------------------------------------------+
| password('test')                          |
+-------------------------------------------+
| *DD698F19E61BBCC9249BD16C76A994B71E92E6F1 | 
+-------------------------------------------+
1 row in set (0.20 sec)

mysql> 

How to repeat:
Compile MySQL 5.0.27 like this on a intel host creating 4 architectures at once.

export PATH="/usr/X11R6/bin:/usr/bin:/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"
export LDFLAGS="-lz" 
export CC=gcc
export CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -fno-omit-frame-pointer -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" 
export CPPFLAGS="" 
export CXX=gcc
export CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -fno-omit-frame-pointer -fno-exceptions -fno-rtti -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" 

./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-local-infile --disable-shared --disable-dependency-tracking --enable-thread-safe-client  --enable-largefile --with-innodb --with-berkeley-db --with-big-tables --with-unix-socket-path=/tmp/mysql.sock --with-ndb-shm --with-ndb-port --with-ndb-port-base --with-comment --with-gnu-ld 

then run the server on a power PC (or probably under rosetta on intel) and try to connect from a intel client. your passwords will never match.

Suggested fix:
I suspect the define WORDS_BIGENDIAN is not set correctly when crosscompiling ppc code variant under intel. Its being set in config.h by the configure script.

The following code snipped can be used to work around this.

#if defined(__MACH__) && defined(__APPLE__)
#include <machine/endian.h>
#if( BYTE_ORDER == __DARWIN_BIG_ENDIAN)
#define WORDS_BIGENDIAN 1
#else
#undef WORDS_BIGENDIAN
#endif

#else
    /* whatever other platforms want WORDS_BIGENDIAN to be set here */
#endif
[14 Dec 2006 10:35] Andreas Fink
on powerpc built on powerpc

mysql> select password('test');
+-------------------------------------------+
| password('test')                          |
+-------------------------------------------+
| *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 | 
+-------------------------------------------+
1 row in set (0.04 sec)
[25 Dec 2006 18:56] Sveta Smirnova
Thank you for the report.

I can not repeat it using current BK sources.