Bug #18169 Multi Statement Queries cause incorrect return value with C API mysql_query
Submitted: 12 Mar 2006 20:35 Modified: 15 Apr 2006 1:15
Reporter: Charles Salvia Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S5 (Performance)
Version: OS:Linux (Linux)
Assigned to: MySQL Verification Team CPU Architecture:Any

[12 Mar 2006 20:35] Charles Salvia
Description:
There may be a bug in the mysql C API when dealing with multi statements. Normally, mysql_query will return a value of 0 when you execute a successful query, and a value of 1 when you execute an unsuccessful query. But if you execute a query AFTER executing a multistatement query, it will return a value of 1 even though the query actually worked.

How to repeat:
Example:

char* q = "INSERT into mytable (column1) VALUES (\"abcdef\"); INSERT into mytable (column2) VALUES (\"ghijkl\")";

printf("%d\n",mysql_query(conn, q));

q = "INSERT into mytable (column1) VALUES (\"mnopqr\")";
printf("%d\n",mysql_query(conn, q));

This prints out:
0
1

The second query returns 1 even though it was successful. This makes error checking difficult when using multiple statement queries.

Suggested fix:
mysql_query should return a value of 0 for all successful queries.
[12 Mar 2006 20:55] Charles Salvia
Using mysql_error I discover this is due to a lost connection.  Why should using multiple statements cause a lost connection?
[15 Mar 2006 1:15] MySQL Verification Team
Thank you for the bug report.
Could you please provide a complete test case, the table definition,
some inserts, the C application code and the server/client library
version which are empty on your bug report.

Thanks in advance.
[15 Apr 2006 23: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".