Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-67

Prepared statements failure: The statement (3) has no open cursor

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None
    • Ubuntu 12.04LTS (though not limited to environment)

    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 (pseudo 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 white space cleanups being mixed in.

      Attachments

        Activity

          georg Georg Richter added a comment -

          Hi Brad,

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

          georg Georg Richter added a comment - Hi Brad, thanks for your bug report. Which server version do you use?

          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

          brad_mssw Brad House (Inactive) added a comment - 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

          test case to reproduce issue

          brad_mssw Brad House (Inactive) added a comment - test case to reproduce issue

          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.

          brad_mssw Brad House (Inactive) added a comment - 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.
          georg Georg Richter added a comment -

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

          georg Georg Richter added a comment - Thanks for your bug report and test case. Issue fixed in rev. 112

          People

            georg Georg Richter
            brad_mssw Brad House (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.