Bug #57511 documented return type for mysql_change_user is wrong
Submitted: 18 Oct 2010 9:23 Modified: 28 Oct 2010 18:40
Reporter: Michael Schuster Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.1, 5.6.99 bzr OS:Any
Assigned to: CPU Architecture:Any

[18 Oct 2010 9:23] Michael Schuster
Description:
the return type "my_bool" is incorrect here, since this function returns 0 for success (which would be false, therefore exactly counter to expectations). 

How to repeat:
n/a

Suggested fix:
use an int?
[20 Oct 2010 18:57] Sveta Smirnova
Thank you for the report.

Verified as described in ./libmysql/libmysql.c:

my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
                  const char *passwd, const char *db) 
{
  char buff[USERNAME_LENGTH+SCRAMBLED_PASSWORD_CHAR_LENGTH+NAME_LEN+2];
  char *end= buff;
  int rc;
...
  DBUG_RETURN(rc);
}
[28 Oct 2010 18:40] Konstantin Osipov
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.
[28 Oct 2010 18:41] Konstantin Osipov
The function is documented in the manual (for a reference, without any changes since 2001) and the implementation follows the documentation:
http://dev.mysql.com/doc/refman/5.0/en/mysql-change-user.html
[29 Oct 2010 5:11] Michael Schuster
I don't see how this can be interpreted as "how to use ..." - my point was that the *implementation* of mysql_change_user() is wrong in two points:
a) there's a contradiction between "my_bool" data type and a return value of 0 indicating success.
b) (this wasn't in the initial report): the documentation says that return is "Nonzero if an error occurred". for my_bool, this can - if implemented correctly - only be 1, so it should say so.