summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2005-08-10 10:31:32 +0400
committerunknown <dlenev@mysql.com>2005-08-10 10:31:32 +0400
commitf6fff55eb01baf5830db23198cd9d0c2bdeb4bb5 (patch)
treec88db3649fdcba130d7af9b97d86210c4c5ed3da /sql/sql_yacc.yy
parent2b41471429d9db41d64bfb214e29ba57cb3db381 (diff)
downloadmariadb-git-f6fff55eb01baf5830db23198cd9d0c2bdeb4bb5.tar.gz
Fix for bug #12280 "Triggers: crash if flush tables".
We should not allow FLUSH statement to be executed inside both triggers and stored functions. mysql-test/r/sp-error.result: Updated test after replacing error, which is thrown when one uses FLUSH statement inside of stored function, with more specific. Also now we issue more general error when we barking about USE command in stored routines. mysql-test/r/trigger.result: Added test for bug #12280 "Triggers: crash if flush tables" mysql-test/t/sp-error.test: Updated test after replacing error, which is thrown when one uses FLUSH statement inside of stored function, with more specific. Also now we issue more general error when we barking about USE command in stored routines. mysql-test/t/trigger.test: Added test for bug #12280 "Triggers: crash if flush tables" sql/share/errmsg.txt: Removed ER_SP_NO_USE error. Now we use more general ER_SP_BADSTATEMENT in this case. Instead added error message for barking about statements which should not be allowed inside of stored functions or triggers. It is safe to do this since it is highly unprobable that someone will upgrade first to the new 5.0 release and then downgrade back to the old one. sql/sql_parse.cc: reload_acl_and_cache(): FLUSH TABLES and FLUSH PRIVILEGES should not be allowed if we are inside of stored function or trigger. sql/sql_yacc.yy: We should not allow FLUSH statement inside both triggers and stored functions. Replaced error which is thrown in this case with more specific. Also now we issue more general ER_SP_BADSTATEMENT error when one tries to use USE command inside of stored routine.
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy11
1 files changed, 8 insertions, 3 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b680787b9a3..849987a267c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1960,7 +1960,7 @@ sp_proc_stmt:
}
if (lex->sql_command == SQLCOM_CHANGE_DB)
{ /* "USE db" doesn't work in a procedure */
- my_message(ER_SP_NO_USE, ER(ER_SP_NO_USE), MYF(0));
+ my_error(ER_SP_BADSTATEMENT, MYF(0), "USE");
YYABORT;
}
/*
@@ -6642,9 +6642,14 @@ flush:
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");
+ /*
+ Note that both FLUSH TABLES and FLUSH PRIVILEGES will break
+ execution in prelocked mode. So it is better to disable
+ FLUSH in stored functions and triggers completely.
+ */
+ my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0), "FLUSH");
YYABORT;
}
lex->sql_command= SQLCOM_FLUSH; lex->type=0;