diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 17e8e499c8d..ca814c17010 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -1427,6 +1427,21 @@ call bug4726()| call bug4726()| drop procedure bug4726| drop table t3| +drop table if exists t3| +create table t3 (s1 int)| +insert into t3 values (3), (4)| +create procedure bug4318() +handler t3 read next| +handler t3 open| +call bug4318()| +s1 +3 +call bug4318()| +s1 +4 +handler t3 close| +drop procedure bug4318| +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 d53cce58767..39f56abb64c 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -1653,6 +1653,28 @@ call bug4726()| drop procedure bug4726| drop table t3| +# +# BUG#4318 +# +--disable_warnings +drop table if exists t3| +--enable_warnings + +create table t3 (s1 int)| +insert into t3 values (3), (4)| + +create procedure bug4318() + handler t3 read next| + +handler t3 open| +# Expect no results, as tables are closed, but there shouldn't be any errors +call bug4318()| +call bug4318()| +handler t3 close| + +drop procedure bug4318| +drop table t3| + # # Some "real" examples diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9458b3830bf..2939090e948 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1713,7 +1713,8 @@ sp_proc_stmt: lex->sql_command == SQLCOM_SHOW_CREATE_FUNC || lex->sql_command == SQLCOM_SHOW_STATUS_PROC || lex->sql_command == SQLCOM_SHOW_STATUS_FUNC || - lex->sql_command == SQLCOM_ANALYZE) + lex->sql_command == SQLCOM_ANALYZE || + lex->sql_command == SQLCOM_HA_READ) { /* We maybe have one or more SELECT without INTO */ lex->sphead->m_multi_results= TRUE;