Details
-
Bug
-
Status: Stalled (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.2(EOL)
-
None
-
Linux/Debian, X64, mariadb-10.3.9-linux-x86_64
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:
CREATE DATABASE demo;
|
USE demo;
|
|
CREATE TABLE demo (id BIGINT(20) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
|
|
DELIMITER //
|
CREATE PROCEDURE test1() BEGIN SELECT 1 AS ID; SELECT 2 AS ID; END//
|
CREATE PROCEDURE test2() BEGIN DECLARE cur1 CURSOR FOR SELECT id FROM demo; OPEN cur1; CLOSE cur1; SELECT 3 AS ID; SELECT 4 AS ID; END//
|
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:
gcc demo.c libmariadb.so -o demo
|
Expected result:
Client info: 10.3.6
|
Statement: CALL test1()
|
Server info: 10.3.9-MariaDB
|
Fields: 1
|
val[0] = 1;
|
Fields: 1
|
val[0] = 2;
|
Statement: CALL test2()
|
Server info: 10.3.9-MariaDB
|
Fields: 1
|
val[0] = 3;
|
Fields: 1
|
val[0] = 4;
|
Actual result:
Client info: 10.3.6
|
Statement: CALL test1()
|
Server info: 10.3.9-MariaDB
|
Fields: 1
|
val[0] = 1;
|
Fields: 1
|
val[0] = 2;
|
Statement: CALL test2()
|
Server info: 10.3.9-MariaDB
|
Fields: 1
|
# Error: (errno: 0)
|
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.
Attachments
Issue Links
- causes
-
CONC-424 mysql_stmt_store_result returns empty error
- Closed
- relates to
-
MDEV-19321 Cursor flag set incorrectly in COM_STMT_EXECUTE response
- Open