Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.0.5
-
None
-
None
Description
After fetching all rows from an unbuffered prepared statement result set, a new call to mysql_stmt_execute() doesn't reset internal number of rows (stmt->result.rows).
Test case:
static int test_num_rows(MYSQL *mysql) |
{
|
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
int rc; |
|
rc= mysql_query(mysql, "CREATE OR REPLACE TABLE t1 (a int, b int)"); |
check_mysql_rc(rc, mysql);
|
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1,1), (2,2),(3,3),(4,4),(5,5)"); |
check_mysql_rc(rc, mysql);
|
|
rc= mysql_stmt_prepare(stmt, SL("SELECT * FROM t1 ORDER BY a")); |
check_stmt_rc(rc, stmt);
|
|
rc= mysql_stmt_execute(stmt);
|
check_stmt_rc(rc, stmt);
|
|
while (!mysql_stmt_fetch(stmt)); |
FAIL_IF(mysql_stmt_num_rows(stmt) != 5, "expected 5 rows"); |
rc= mysql_stmt_execute(stmt);
|
check_stmt_rc(rc, stmt);
|
rc= mysql_stmt_fetch(stmt);
|
diag("num_rows: %lld", mysql_stmt_num_rows(stmt)); |
FAIL_IF(mysql_stmt_num_rows(stmt) != 1, "expected 1 row"); |
|
mysql_stmt_close(stmt);
|
return OK; |
}
|
Output:
# num_rows: 6 |
# Error: expected 1 row |
|