[MDEV-17252] mysql_stmt_fetch error during fetch of stored procedure (with cursor) results Created: 2018-09-18 Updated: 2019-06-30 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 10.2 |
| Fix Version/s: | 10.2 |
| Type: | Bug | Priority: | Minor |
| Reporter: | David Fehrmann | Assignee: | Oleksandr Byelkin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux/Debian, X64, mariadb-10.3.9-linux-x86_64 |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Hi, I've tried to fetch result sets from a stored procedure which using cursors in a business application. The mysql_stmt_fetch reported an error (Unknown with code 0) during the first result set or "Commands out of Sync" with an older library (5.5.0). I've searched for days now to how to get the correct result without success. All other statements are working fine (selects/inserts/deletes, calls to procedures without cursor). The applications mysql and HeidiSql are working properly and return the expected results. So the server side seems to be working as expected. Here my minimized test set: Database:
The C code is attached (mostly taken from https://dev.mysql.com/doc/refman/5.7/en/c-api-prepared-call-statements.html), compiled with:
Expected result:
Actual result:
I'm pretty sure I'm doing something wrong, but I couldn't figure out what to do. At least the error code is misleading and doesn't help to solve the issue. |
| Comments |
| Comment by Georg Richter [ 2018-09-19 ] |
|
Hmm.. this looks like a server bug: When executing CALL test2() server sends in first packet server status flag SERVER_STATUS_CURSOR_EXISTS which indicates that subsequent rows must be fetched from client via COM_STMT_FETCH command until server sets status flag SERVER_STATUS_LAST_ROW_SENT. However this can never work unless all results from the stored procedure are processed. See also: |
| Comment by David Fehrmann [ 2018-09-20 ] |
|
Thank you very much. Shall I test the workaround in my environments? |
| Comment by Georg Richter [ 2018-09-20 ] |
|
There is already a test in ps_bugs.c which tests the workaround. |
| Comment by David Fehrmann [ 2018-09-20 ] |
|
Okay, thank you. |
| Comment by Georg Richter [ 2018-09-20 ] |
|
I added a workaround in Connector/C, but this needs to be fixed also in server. For both result sets from call test2() the server sets the status "SERVER_STATUS_CURSOR_EXISTS". |