|
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;
|