Loading mysql-test/r/ps.result +7 −0 Original line number Diff line number Diff line Loading @@ -825,3 +825,10 @@ execute stmt; drop table t1; set names default; 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; mysql-test/t/ps.test +12 −0 Original line number Diff line number Diff line Loading @@ -871,3 +871,15 @@ set names default; deallocate prepare stmt; # 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 sql/sql_parse.cc +8 −4 Original line number Diff line number Diff line Loading @@ -4844,11 +4844,15 @@ mysql_execute_command(THD *thd) /* The return value for ROW_COUNT() is "implementation dependent" if the statement is not DELETE, INSERT or UPDATE (or a CALL executing such a statement), but -1 is what JDBC and ODBC wants. The return value for ROW_COUNT() is "implementation dependent" if the statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC 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; goto cleanup; Loading Loading
mysql-test/r/ps.result +7 −0 Original line number Diff line number Diff line Loading @@ -825,3 +825,10 @@ execute stmt; drop table t1; set names default; 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;
mysql-test/t/ps.test +12 −0 Original line number Diff line number Diff line Loading @@ -871,3 +871,15 @@ set names default; deallocate prepare stmt; # 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
sql/sql_parse.cc +8 −4 Original line number Diff line number Diff line Loading @@ -4844,11 +4844,15 @@ mysql_execute_command(THD *thd) /* The return value for ROW_COUNT() is "implementation dependent" if the statement is not DELETE, INSERT or UPDATE (or a CALL executing such a statement), but -1 is what JDBC and ODBC wants. The return value for ROW_COUNT() is "implementation dependent" if the statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC 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; goto cleanup; Loading