diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index eedc692bb85..18d0f4d5b23 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -1894,6 +1894,32 @@ flush status| flush query cache| delete from t1| drop procedure bug3583| +drop table if exists t3| +drop procedure if exists bug4905| +create table t3 (s1 int,primary key (s1))| +create procedure bug4905() +begin +declare v int; +declare continue handler for sqlstate '23000' set v = 5; +insert into t3 values (1); +end| +call bug4905()| +select row_count()| +row_count() +1 +call bug4905()| +select row_count()| +row_count() +0 +call bug4905()| +select row_count()| +row_count() +0 +select * from t3| +s1 +1 +drop procedure bug4905| +drop table t3| drop table if exists fac| create table fac (n int unsigned not null primary key, f bigint unsigned)| create procedure ifac(n int unsigned) diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 2f519a98488..a3101ff9488 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -2056,6 +2056,35 @@ flush query cache| delete from t1| drop procedure bug3583| +# +# BUG#4905: Stored procedure doesn't clear for "Rows affected" +# +--disable_warnings +drop table if exists t3| +drop procedure if exists bug4905| +--enable_warnings + +create table t3 (s1 int,primary key (s1))| + +create procedure bug4905() +begin + declare v int; + declare continue handler for sqlstate '23000' set v = 5; + + insert into t3 values (1); +end| + +call bug4905()| +select row_count()| +call bug4905()| +select row_count()| +call bug4905()| +select row_count()| +select * from t3| + +drop procedure bug4905| +drop table t3| + # # Some "real" examples diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7be33c751e1..655ba63c6e5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3724,6 +3724,7 @@ purposes internal to the MySQL server", MYF(0)); select_limit= thd->variables.select_limit; thd->variables.select_limit= HA_POS_ERROR; + thd->row_count_func= 0; res= sp->execute_procedure(thd, &lex->value_list); thd->variables.select_limit= select_limit;