Bug #14956 no way to get row_count() info when using prepared statements
Submitted: 15 Nov 2005 18:44 Modified: 2 Dec 2005 4:24
Reporter: Matthew Lord Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Prepared statements Severity:S2 (Serious)
Version:5.0.15 OS:Any (all)
Assigned to: Jim Winstead CPU Architecture:Any

[15 Nov 2005 18:44] Matthew Lord
Description:
row_count() and mysql_affected_rows() always return -1 when using prepared statements.

How to repeat:
create table t (id int);
prepare ins_call from "insert into t (id) values (1)";
execute ins_call;
select row_count();
[15 Nov 2005 20:28] Andrey Hristov
mysql_stmt_row_count() is the right function to call to get the number of rows. Bogus report?
[15 Nov 2005 20:32] Matthew Lord
Yes, mysql_stmt_affected_rows() is the correct call in this case.  We need a way to get this value
with SQL, from an SP for example.
[16 Nov 2005 2:12] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/32296
[23 Nov 2005 11:28] Konstantin Osipov
Please consider adding a comment before the if statement you modified, that says:
In case of CALL or EXECUTE statements, do not reset row count so that the value
of row count of the last inner statement is preserved.

OK to push.
[23 Nov 2005 22:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/32622
[29 Nov 2005 19:37] Jim Winstead
Fixed in 5.0.17 and 5.1.4.
[2 Dec 2005 4:24] Paul Dubois
Noted in 5.0.17, 5.1.4 changelogs.