[CONC-141] Hang when working with prepared statements Created: 2015-09-16 Updated: 2015-09-17 Resolved: 2015-09-17 |
|
| Status: | Closed |
| Project: | MariaDB Connector/C |
| Component/s: | None |
| Affects Version/s: | 2.1 |
| Fix Version/s: | 3.0.0, 2.2.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Matt Fagan | Assignee: | Georg Richter |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
All |
||
| Description |
|
There is a sequence of operations that can cause the client to hang when working with prepared statements. It only happens when 1) using stored procedures to return multiple result sets, 2) when an error occurs in the second or subsequent result set in the procedure, 3) when the statement is then re-used, and 4) when mysql_stmt_free_result() is called between receiving the error and reusing the statement. I think that the error is on line 1886 of my_stmt.c, but am not totally sure. (Perhaps need a line inserted at around 1890 of my_stmt.c to update the state once an error is detected.) To reproduce, first need to setup the database:
When this stored proc is run, it will return a two result sets, but with an error value in the second one. The C code side is:
After writing the above, I did some additional testing, and everything seems to work if I remove the mysql_stmt_free_result() call. However, the behavior is inconsistent between when an error occurs in the first result set and when it occurs in a subsequent result set. (See line 1506 of my_stmt.c. If an error is returned by the first result set, the stmt is put into the MYSQL_STMT_PREPARED state.) There is another inconsistency there, too. When an error occurs in the first result set, stmt->upsert_status.affected_rows gets updated before returning the error code. In mysql_stmt_next_result(), this happens afterwards. Update:
|
| Comments |
| Comment by Georg Richter [ 2015-09-17 ] |
|
We need to check in mysql_stmt_next_result if more data is on the wire, if not stmt->state should be set to MYSQL_STMT_FETCH_DONE (return code 1). The given example is not correct: |
| Comment by Georg Richter [ 2015-09-17 ] |
|
Fixed. Changeset: b950d2cf4882fb3424df8dee452efe42891e6530 |