| Bug #12573 | C api function mysql_next_result() and mysql_more_results() return error | ||
|---|---|---|---|
| Submitted: | 14 Aug 2005 13:20 | Modified: | 24 Aug 2005 9:05 |
| Reporter: | sanxi wang | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.0.10-0 | OS: | Linux (Redhat Linux 9) |
| Assigned to: | Georg Richter | CPU Architecture: | Any |
[24 Aug 2005 9:05]
Georg Richter
When calling a stored procedure you have an additional (empty) resultset and errorcode for the procedure call itself. Same behaviour when you mix select and dml statements in a multi query. For statements which don't return a resultset (like INSERT/DELETE/UPDATE) you will get only the errorcode.

Description: version: client: MySQL-client-5.0.10-0 MySQL-devel-5.0.10-0 server: MySQL-server-5.0.10-0 When no more data, mysql_next_result() still return 0 How to repeat: use C API call stored procedure and use mysql_next_result get last result: call stored procedure like: CREATE PROCEDURE `test`() NOT DETERMINISTIC SQL SECURITY DEFINER COMMENT '' BEGIN select 1; select 2; select 3; end; then use C API the get result: ... mysql_init(&mysql); mysql_real_connect(&mysql, hostname, username, passwd, dbname, 0, NULL, CLIENT_MULTI_RESULTS); ... mysql_ping(&mysql); mysql_real_query(&mysql, access, (unsigned int) strlen(access)); do { // Process all results if (!(res= mysql_store_result(&mysql))) return -5; if(row = mysql_fetch_row(res)) { if( mysql_num_fields(res) >= 4 ) { if(row[0]!=NULL) strncpy(buff01, row[0], 1023); // save the data } } mysql_free_result(res); // FOR BUG OF MySQL C API: // If no more data, must call mysql_next_result on 2 times // At the next time, my_sql_next_result will return -1 and mysql_more_results will return 0; // Otherwise, mysql_next_result will return 0(success) mysql_next_result(&mysql); mysql_more_results(&mysql); } while (mysql_next_result(&mysql)!=-1);