Bug #62501 I got some error infomation when I use the mysql_init() function.
Submitted: 22 Sep 2011 17:15 Modified: 23 Nov 2011 12:02
Reporter: yu jin Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.3 OS:Any (linux and windows xp sp3)
Assigned to: CPU Architecture:Any
Tags: API, mysql client, mysql_init

[22 Sep 2011 17:15] yu jin
On myslqclient library 4.1 I use mysql_init() function to initialize a mysql object follow these steps ,then every thing was ok.

MYSQL* handle=(MYSQL*)malloc(sizeof(MYSQL));

But I use the same steps on mysqlclient library 5.3 that I can't use the mysql object to connect server.
So we try use follow two methods to initialize object.Every thing was ok.

MYSQL handle;
MYSQL handle=NULL;

I found out some information for mysql_init() in manual 5.0~5.6:

Allocates or initializes a MYSQL object suitable for mysql_real_connect(). If mysql is a NULL pointer, the function allocates, initializes, and returns a new object. Otherwise, the object is initialized and the address of the object is returned. If mysql_init() allocates a new object, it is freed when mysql_close() is called to close the connection.

It means that we can put a mysql object to mysql_init() function which has malloc memory before.
Is this a bug for mysql_init()?

How to repeat:
On mysqlclient library 5.3 ,use follow steps to initializes a mysql object then use mysql_real_connect to connect the server.

MYSQL* handle=(MYSQL*)malloc(sizeof(MYSQL));

Suggested fix:
If this was a bug please fix it or add some notices in the newest manual.
[23 Oct 2011 12:02] Valeriy Kravchuk
I wonder if 5.3 is correct version. Also, please, send the entire code that demonstrates the problem.
[24 Nov 2011 7:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".