From: Date: August 5 2005 12:37pm Subject: bk commit into 5.0 tree (dlenev:1.1939) BUG#12280 List-Archive: http://lists.mysql.com/internals/27913 X-Bug: 12280 Message-Id: <20050805103759.17A4F137859@brandersnatch.localdomain> Below is the list of changes that have just been committed into a local 5.0 repository of dlenev. When dlenev does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1939 05/08/05 14:37:50 dlenev@stripped +7 -0 Fix for bug #12280 "Triggers: crash if flush tables". We should not allow FLUSH statement to be executed inside both triggers and stored functions. sql/sql_yacc.yy 1.411 05/08/05 14:37:45 dlenev@stripped +2 -2 We should not allow FLUSH statement inside both triggers and stored functions. Replaced error which is thrown in this case with more specific. sql/sql_parse.cc 1.458 05/08/05 14:37:45 dlenev@stripped +7 -0 reload_acl_and_cache(): FLUSH TABLES should not be allowed if we are inside of stored function or trigger. sql/share/errmsg.txt 1.38 05/08/05 14:37:44 dlenev@stripped +2 -0 Added error message for barking about statements which should not be allowed inside of stored functions or triggers. mysql-test/t/trigger.test 1.21 05/08/05 14:37:44 dlenev@stripped +13 -0 Added test for bug #12280 "Triggers: crash if flush tables" mysql-test/t/sp-error.test 1.80 05/08/05 14:37:44 dlenev@stripped +1 -1 Updated test after replacing error which is thrown when one uses FLUSH statement inside of stored function with more specific. mysql-test/r/trigger.result 1.16 05/08/05 14:37:44 dlenev@stripped +10 -0 Added test for bug #12280 "Triggers: crash if flush tables" mysql-test/r/sp-error.result 1.77 05/08/05 14:37:44 dlenev@stripped +1 -1 Updated test after replacing error, which is thrown when one uses FLUSH statement inside of stored function, with more specific. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: dlenev # Host: brandersnatch.localdomain # Root: /home/dlenev/src/mysql-5.0-bg12280 --- 1.457/sql/sql_parse.cc 2005-08-03 14:13:59 +04:00 +++ 1.458/sql/sql_parse.cc 2005-08-05 14:37:45 +04:00 @@ -6395,6 +6395,13 @@ bool result=0; select_errors=0; /* Write if more errors */ bool tmp_write_to_binlog= 1; + + if (thd->in_sub_stmt) + { + my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0), "FLUSH"); + return 1; + } + #ifndef NO_EMBEDDED_ACCESS_CHECKS if (options & REFRESH_GRANT) { --- 1.410/sql/sql_yacc.yy 2005-07-19 20:52:55 +04:00 +++ 1.411/sql/sql_yacc.yy 2005-08-05 14:37:45 +04:00 @@ -6642,9 +6642,9 @@ FLUSH_SYM opt_no_write_to_binlog { LEX *lex=Lex; - if (lex->sphead && lex->sphead->m_type == TYPE_ENUM_FUNCTION) + if (lex->sphead && lex->sphead->m_type != TYPE_ENUM_PROCEDURE) { - my_error(ER_SP_BADSTATEMENT, MYF(0), "FLUSH"); + my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0), "FLUSH"); YYABORT; } lex->sql_command= SQLCOM_FLUSH; lex->type=0; --- 1.37/sql/share/errmsg.txt 2005-08-03 03:28:30 +04:00 +++ 1.38/sql/share/errmsg.txt 2005-08-05 14:37:44 +04:00 @@ -5388,3 +5388,5 @@ eng "Thread stack overrun: %ld bytes used of a %ld byte stack, and %ld bytes needed. Use 'mysqld -O thread_stack=#' to specify a bigger stack." ER_TOO_LONG_BODY 42000 S1009 eng "Routine body for '%-.100s' is too long" +ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG + eng "%s is not allowed in stored function or trigger" --- 1.15/mysql-test/r/trigger.result 2005-07-30 10:24:47 +04:00 +++ 1.16/mysql-test/r/trigger.result 2005-08-05 14:37:44 +04:00 @@ -2,6 +2,7 @@ drop view if exists v1; drop database if exists mysqltest; drop function if exists f1; +drop procedure if exists p1; create table t1 (i int); create trigger trg before insert on t1 for each row set @a:=1; set @a:=0; @@ -634,4 +635,13 @@ show triggers; Trigger Event Table Statement Timing Created sql_mode t1_bi INSERT t1 set new.a = '2004-01-00' BEFORE # +drop table t1; +create table t1 (id int); +create trigger t1_ai after insert on t1 for each row flush tables; +ERROR HY000: FLUSH is not allowed in stored function or trigger +create procedure p1() flush tables; +create trigger t1_ai after insert on t1 for each row call p1(); +insert into t1 values (0); +ERROR HY000: FLUSH is not allowed in stored function or trigger +drop procedure p1; drop table t1; --- 1.20/mysql-test/t/trigger.test 2005-07-30 10:24:47 +04:00 +++ 1.21/mysql-test/t/trigger.test 2005-08-05 14:37:44 +04:00 @@ -7,6 +7,7 @@ drop view if exists v1; drop database if exists mysqltest; drop function if exists f1; +drop procedure if exists p1; --enable_warnings create table t1 (i int); @@ -641,4 +642,16 @@ show create table t1; --replace_column 6 # show triggers; +drop table t1; + +# Test for bug #12280 "Triggers: crash if flush tables" +# FLUSH TABLES should be disallowed inside of functions and triggers. +create table t1 (id int); +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create trigger t1_ai after insert on t1 for each row flush tables; +create procedure p1() flush tables; +create trigger t1_ai after insert on t1 for each row call p1(); +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +insert into t1 values (0); +drop procedure p1; drop table t1; --- 1.76/mysql-test/r/sp-error.result 2005-07-13 13:57:01 +04:00 +++ 1.77/mysql-test/r/sp-error.result 2005-08-05 14:37:44 +04:00 @@ -616,7 +616,7 @@ flush tables; return 5; end| -ERROR 0A000: FLUSH is not allowed in stored procedures +ERROR HY000: FLUSH is not allowed in stored function or trigger create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123() begin end| --- 1.79/mysql-test/t/sp-error.test 2005-07-13 13:57:01 +04:00 +++ 1.80/mysql-test/t/sp-error.test 2005-08-05 14:37:44 +04:00 @@ -885,7 +885,7 @@ --disable_warnings drop function if exists bug8409| --enable_warnings ---error ER_SP_BADSTATEMENT +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG create function bug8409() returns int begin