Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-17252

mysql_stmt_fetch error during fetch of stored procedure (with cursor) results

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.2(EOL)
    • 10.2(EOL)
    • Server
    • 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

          Activity

            People

              sanja Oleksandr Byelkin
              Feyd David Fehrmann
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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