Bug #8413 C API mysql_stmt_fetch core dump on copying to bound C structure
Submitted: 10 Feb 2005 0:31 Modified: 10 Mar 2005 0:55
Reporter: Fan Zhang Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.7-standard-log OS:HP/UX (hp-hpux11.11)
Assigned to: CPU Architecture:Any

[10 Feb 2005 0:31] Fan Zhang
Description:
When using mysql C API prepared statments, if the result is bound to a C structure, mysql_stmt_fetch will core dump on the last field of the C structure. The first guess is that mysql_stmt_fetch has problems to deal with the C structure boundry. For example, in the following code, FIRST LINE would cause mysql_stmt_fetch core dump, but the SECOND LINE would not because the second line is a indepenant variable of char[2] while the FIRST line is the last field of a structure of the same type char[2]. 

If you know this is a known bug, please let me know. Thanks, 

-----------------------------------------

result_bind[3].buffer_type=MYSQL_TYPE_STRING;

result_bind[3].buffer=(char *)(my_rec.dispcustname);   /* FIRST LINE*/

/*result_bind[3].buffer=(char *)(cust);*/           /* SECOND LINE */

result_bind[3].buffer_length=2;

result_bind[3].is_null=&is_null[3];

result_bind[3].length=&length[3];

----------------------------------------------

How to repeat:

Create a C structure of mutiple fields. Ensure the last field is a char* type. 
Use result_bind to point to individual fields of the C structure. 
Follow the normal procedure of preparing statement, execute statement, store result, binding results, fetch results. See if you get the core dump.
[10 Feb 2005 0:55] Jorge del Conde
Hi!

Can you please provide us with a test-case that reproduces this behaviour ?  A simple c file will do.

Thanks.
[11 Mar 2005 0: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".