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

mysql_stmt_num_rows returns accumulated number of rows of all stored resultsets

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.1.10
    • 3.1.11
    • None
    • None

    Description

      The KnowledgeBase says, that "mysql_stmt_num_rows ... Returns the number of rows in the result set." But it looks like in case of multiple results, the number returned by mysql_stmt_num_rows is accumulated number of rows in all stored to the moment resultsets.

       MYSQL      *ma;
       MYSQL_STMT *stmt;
       
       if (!mysql_real_connect(ma, "localhost", "uid", "pwd", "test", 3306, NULL, 0))
        {
          printf("Could not connect: %s\n", mysql_error(ma));
          exit(1);
        }
        stmt = mysql_stmt_init(ma);
       
        mysql_query(ma, "DROP PROCEDURE IF EXISTS p");
        mysql_query(ma, "CREATE PROCEDURE p() BEGIN SELECT 1; SELECT 2; SELECT 3; END;");
       
        mysql_stmt_prepare(stmt, "call p()", -1);
       
        mysql_stmt_execute(stmt);
       
        mysql_stmt_store_result(stmt);
        printf("Number of rows: %llu\n", mysql_stmt_num_rows(stmt));
       
        mysql_stmt_next_result(stmt);
        mysql_stmt_store_result(stmt);
       
        printf("Number of rows: %llu\n", mysql_stmt_num_rows(stmt));
       
        mysql_stmt_next_result(stmt);
        mysql_stmt_store_result(stmt);
        printf("Number of rows: %llu\n", mysql_stmt_num_rows(stmt));
       
        mysql_stmt_close(stmt);
        mysql_close(ma);
      

      I'd say, that stmt->result.rows should be reset by mysql_stmt_next_result somewhere at the end of function - like before or after
      stmt->field_count= stmt->mysql->field_count;

      Attachments

        Activity

          People

            georg Georg Richter
            Lawrin Lawrin Novitsky
            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.