From 166accffda5d2019804c842a91b33e7d1a65f6ac Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 May 2005 16:19:25 +0200 Subject: [PATCH] Fixed BUG#8409: Stored procedure crash if function contains FLUSH by simply disabling FLUSH for stored functions. (I can't really work.) mysql-test/r/sp-error.result: New test case for BUG#8409. mysql-test/t/sp-error.test: New test case for BUG#8409. sql/sql_yacc.yy: Disable FLUSH for stored functions. --- mysql-test/r/sp-error.result | 8 ++++++++ mysql-test/t/sp-error.test | 15 +++++++++++++++ sql/sql_yacc.yy | 5 +++++ 3 files changed, 28 insertions(+) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 7c19f60471a..5eb651e2fca 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -646,4 +646,12 @@ drop procedure if exists bug10537| create procedure bug10537() load data local infile '/tmp/somefile' into table t1| ERROR 0A000: LOAD DATA is not allowed in stored procedures +drop function if exists bug8409| +create function bug8409() +returns int +begin +flush tables; +return 5; +end| +ERROR 0A000: FLUSH is not allowed in stored procedures drop table t1| diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 67e9be5dd5d..78a6cdd49e1 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -905,6 +905,21 @@ create procedure bug10537() load data local infile '/tmp/somefile' into table t1| +# +# BUG#8409: Stored procedure crash if function contains FLUSH +# +--disable_warnings +drop function if exists bug8409| +--enable_warnings +--error ER_SP_BADSTATEMENT +create function bug8409() + returns int +begin + flush tables; + return 5; +end| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6b9676c8124..feb9b9a6363 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6511,6 +6511,11 @@ flush: FLUSH_SYM opt_no_write_to_binlog { LEX *lex=Lex; + if (lex->sphead && lex->sphead->m_type == TYPE_ENUM_FUNCTION) + { + my_error(ER_SP_BADSTATEMENT, MYF(0), "FLUSH"); + YYABORT; + } lex->sql_command= SQLCOM_FLUSH; lex->type=0; lex->no_write_to_binlog= $2; }