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

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.10
    • Fix Version/s: 3.1.11
    • Labels:
      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

            Assignee:
            georg Georg Richter
            Reporter:
            Lawrin Lawrin Novitsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: