[CONC-67] Prepared statements failure: The statement (3) has no open cursor Created: 2014-01-22  Updated: 2014-01-25  Resolved: 2014-01-25

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Brad House (Inactive) Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None
Environment:

Ubuntu 12.04LTS (though not limited to environment)


Attachments: File CONC-67.c    

 Description   

I have an application which has been tested against the mysql 5.0, 5.1, and 5.5 client libraries. Last year, we started testing the mariadb client for C, and were on revision 42 and the application worked properly there too. Trying to replicate testing on the current revision 109, mysql_stmt_fetch() fails with error code 1421 with the message: "The statement (3) has no open cursor"

After further research, the issue appears to have been introduced in revision 62, as up to revision 61 works fine.

I have not yet produced a minimal test case for this, but in general, the application follows what I believe is a fairly standard flow (psuedo code to give general idea):

stmt = mysql_stmt_init()
mysql_stmt_prepare(stmt, ...)
/* Create bind_params for statement here */
mysql_stmt_bind_param(stmt, bind_params)
mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, CURSOR_TYPE_READ_ONLY)
mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS, 1000)
mysql_stmt_execute(stmt)
res = mysql_stmt_result_metadata(stmt)
num = mysql_num_fields(res)
fields = mysql_fetch_fields(res)
for (i=0; i<num; i++) {
/* cache fields[i].name and fields[i].type */
}
mysql_free_result(res)
/* Create bind result data here based on cached name and type for each response column */
mysql_stmt_bind_result(stmt, bind_result)
mysql_stmt_fetch(stmt)
... and it fails at that fetch so I won't continue...

I haven't yet tried to determine what in the commit caused the change as there seems to be a bit to go through due to whitespace cleanups being mixed in.



 Comments   
Comment by Georg Richter [ 2014-01-22 ]

Hi Brad,

thanks for your bug report. Which server version do you use?

Comment by Brad House (Inactive) [ 2014-01-22 ]

I'm currently just running the mysql server that comes with ubuntu 12.04LTS for testing:
mysql-server-5.5 5.5.34-0ubuntu0.12.04.1

Comment by Brad House (Inactive) [ 2014-01-24 ]

test case to reproduce issue

Comment by Brad House (Inactive) [ 2014-01-24 ]

After further investigation (in writing the test case), the issue seems to be the response code returned by mysql_stmt_fetch() is no longer MYSQL_NO_DATA after all data has been fetched, but rather an error condition. So it does successfully fetch one row of data in the test case, but then when it goes to fetch another row which should indicate the fetch is complete, it throws an error instead.

Comment by Georg Richter [ 2014-01-25 ]

Thanks for your bug report and test case.
Issue fixed in rev. 112

Generated at Thu Feb 08 03:02:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.