summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorunknown <anozdrin@mysql.com>2005-09-06 21:43:06 +0400
committerunknown <anozdrin@mysql.com>2005-09-06 21:43:06 +0400
commitb89205880f6ce80ccba6e5c43be7af77828b2342 (patch)
treedf64725c04d5d1a1bb409b6ae11e013c340a1d48 /sql/sql_yacc.yy
parent9e7a1bb2b019a1a8048bc9ef8cdf00fcc255d812 (diff)
downloadmariadb-git-b89205880f6ce80ccba6e5c43be7af77828b2342.tar.gz
Fix for Bug#12953 "Stored procedures: crash if OPTIMIZE TABLE in function"
OPTIMIZE TABLE statement is forbidden from usage in stored procedures/functions. NOTE: OPTIMIZE TABLE statement can be useful in stored procedures. The idea is that the user/administrator can create a stored procedure for admin tasks (optimizing, backing up, etc). This procedure can be scheduled to run automatically (by mean of internal cron (WL#1034)). So, once we can make this statement work, it is worth doing it. mysql-test/r/sp-error.result: Results for the test case for Bug#12953 added. mysql-test/t/sp-error.test: Test case for Bug#12953 "Stored procedures: crash if OPTIMIZE TABLE in function" added. sql/sql_yacc.yy: Forbid "OPTIMIZE TABLE" statement from use in stored procedures/functions.
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy5
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c9b41cb495b..cc286e4ff45 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3826,6 +3826,11 @@ optimize:
OPTIMIZE opt_no_write_to_binlog table_or_tables
{
LEX *lex=Lex;
+ if (lex->sphead)
+ {
+ my_error(ER_SP_BADSTATEMENT, MYF(0), "OPTIMIZE TABLE");
+ YYABORT;
+ }
lex->sql_command = SQLCOM_OPTIMIZE;
lex->no_write_to_binlog= $2;
lex->check_opt.init();