Commit 184c3db1 authored by unknown's avatar unknown

Fix result of ROW_COUNT() after 'EXECUTE prepstmt'. (Bug #14956)


mysql-test/r/ps.result:
  Add new results
mysql-test/t/ps.test:
  Add new test
sql/sql_parse.cc:
  Don't reset row_count after processing EXECUTE statement.
parent 8fcf0148
...@@ -806,3 +806,10 @@ execute stmt; ...@@ -806,3 +806,10 @@ execute stmt;
@@tx_isolation @@tx_isolation
REPEATABLE-READ REPEATABLE-READ
deallocate prepare stmt; deallocate prepare stmt;
create table t1 (id int);
prepare ins_call from "insert into t1 (id) values (1)";
execute ins_call;
select row_count();
row_count()
1
drop table t1;
...@@ -843,3 +843,15 @@ execute stmt; ...@@ -843,3 +843,15 @@ execute stmt;
deallocate prepare stmt; deallocate prepare stmt;
# End of 4.1 tests # End of 4.1 tests
#
# Bug #14956: ROW_COUNT() returns incorrect result after EXECUTE of prepared
# statement
#
create table t1 (id int);
prepare ins_call from "insert into t1 (id) values (1)";
execute ins_call;
select row_count();
drop table t1;
# End of 5.0 tests
...@@ -4822,11 +4822,15 @@ mysql_execute_command(THD *thd) ...@@ -4822,11 +4822,15 @@ mysql_execute_command(THD *thd)
/* /*
The return value for ROW_COUNT() is "implementation dependent" if The return value for ROW_COUNT() is "implementation dependent" if the
the statement is not DELETE, INSERT or UPDATE (or a CALL executing statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC
such a statement), but -1 is what JDBC and ODBC wants. wants.
We do not change the value for a CALL or EXECUTE statement, so the value
generated by the last called (or executed) statement is preserved.
*/ */
if (lex->sql_command != SQLCOM_CALL && uc_update_queries[lex->sql_command]<2) if (lex->sql_command != SQLCOM_CALL && lex->sql_command != SQLCOM_EXECUTE &&
uc_update_queries[lex->sql_command]<2)
thd->row_count_func= -1; thd->row_count_func= -1;
goto cleanup; goto cleanup;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment