Bug #3201 Conflicts when linking libmysqlclient
Submitted: 17 Mar 2004 6:42 Modified: 17 Mar 2004 10:51
Reporter: Wayne Price Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.18 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[17 Mar 2004 6:42] Wayne Price
Description:
We are doing some experimentation on the viability of using MySQL as part of a plugin for some applications. We have hit a problem which (it could be argued) requires a bug-fix on either side. From our point of view, a fix in MySQL will make more sense, and would (I think) be an internal change and nothing else.

Basically, the problem boils down to a conflict with the function 'rnd()'. The host application we are trying to interface to, defines it's own version of rnd() within that application. This function is exposed and is available to all plugins as a C function.

As a result, when I link our test plugins with MySQL, it will consistently fail to establish a connection to a MySQL database server. The reason is that MySQL internally uses a C function, rnd(), to do the password hashing. This is where the conflict lies. If I remove the password from the database account, the connection succeeds.

How to repeat:
Link mysql routines with an application which defines an rnd() function of it's own, which is used internally.

Suggested fix:
One of two possible fixes:

- Assuming rnd() is used exclusively within password.c, and nowhere else within the code, then it should be made 'static'. This should force the compiler to use the rnd() function in that file to be available only to that file. The compiler should then link this function when building the client library.

- Alternatively, rename rnd() within password.c (and any other references to it) to something like mysql_rnd() to be sure of no conflicts.

I think that this will resolve the problem and have an extremely minimal impact on any applications which use MySQL. I don't think that the rnd() function is exposed as a publically accessible symbol available as part of the mysql client library, so it's (hopefully) unlikely that any applications are using rnd() from the mysql client library.
[17 Mar 2004 10:51] Sergei Golubchik
Thank you for your bug report. This issue has already been fixed
in the latest released version of that product, which you can download at 
http://www.mysql.com/downloads/

Additional info:

Are you sure you use 4.0.18 ?
rnd() was renamed to my_rnd() on 2003-03-18 - exactly one year ago.
So it is renamed in 4.0.13 at least.

http://mysql.bkbits.net:8080/mysql-4.0/search/?expr=my_rnd&search=ChangeSet+comments