Bug #1447 mysql_stmt_affected_rows returns incorrect value (embedded)
Submitted: 30 Sep 2003 11:45 Modified: 6 Oct 2003 5:22
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S3 (Non-critical)
Version:4.1.1 OS:
Assigned to: Alexey Botchkov CPU Architecture:Any

[30 Sep 2003 11:45] Georg Richter
Description:
mysql_stmt_affected_rows returns an incorrect value, if an prepared statement was executed 
and closed before. 

How to repeat:
	... 
	mysql_query(mysql,"DROP TABLE IF EXISTS test_store_result"); 
  	mysql_query(mysql,"CREATE TABLE test_store_result (a int)"); 
 
	mysql_query(mysql, "INSERT INTO test_store_result VALUES (1),(2),(3)"); 
 
	stmt = mysql_prepare(mysql, "SELECT * FROM test_store_result", 100); 
	mysql_execute(stmt); 
	mysql_stmt_close(stmt); 
 
	stmt = mysql_prepare(mysql, "SELECT * FROM test_store_result", 100); 
	mysql_execute(stmt); 
 
	res = mysql_get_metadata(stmt); 
	mysql_stmt_store_result(stmt); 
 
	printf ("Rows: %d\n", mysql_stmt_affected_rows(stmt)); 
 
Output:  
Rows: 6 
 
should be 3. 
 
If you remove the first prepare/execute/close block, mysql_affected_rows returns the correct 
value (3).
[6 Oct 2003 5:22] Alexey Botchkov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

changeset 1.1619