Commit 737084b2 authored by dlenev@mysql.com's avatar dlenev@mysql.com

Fix for bug #16829 "Firing trigger with RETURN crashes the server"

We should disallow usage of RETURN statement in triggers and emit
error at parsing time (instead of crashing when trigger is fired).
parent edca1d6f
...@@ -785,3 +785,8 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0; ...@@ -785,3 +785,8 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0;
ERROR 3D000: No database selected ERROR 3D000: No database selected
drop trigger t1_bi; drop trigger t1_bi;
ERROR 3D000: No database selected ERROR 3D000: No database selected
create table t1 (i int);
create trigger t1_bi before insert on t1 for each row return 0;
ERROR 42000: RETURN is only allowed in a FUNCTION
insert into t1 values (1);
drop table t1;
...@@ -958,3 +958,12 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0; ...@@ -958,3 +958,12 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0;
--error ER_NO_DB_ERROR --error ER_NO_DB_ERROR
drop trigger t1_bi; drop trigger t1_bi;
connection default; connection default;
# Test for bug #16829 "Firing trigger with RETURN crashes the server"
# RETURN is not supposed to be used anywhere except functions, so error
# should be returned when one attempts to create trigger with RETURN.
create table t1 (i int);
--error ER_SP_BADRETURN
create trigger t1_bi before insert on t1 for each row return 0;
insert into t1 values (1);
drop table t1;
...@@ -1981,7 +1981,7 @@ sp_proc_stmt: ...@@ -1981,7 +1981,7 @@ sp_proc_stmt:
LEX *lex= Lex; LEX *lex= Lex;
sp_head *sp= lex->sphead; sp_head *sp= lex->sphead;
if (sp->m_type == TYPE_ENUM_PROCEDURE) if (sp->m_type != TYPE_ENUM_FUNCTION)
{ {
my_message(ER_SP_BADRETURN, ER(ER_SP_BADRETURN), MYF(0)); my_message(ER_SP_BADRETURN, ER(ER_SP_BADRETURN), MYF(0));
YYABORT; YYABORT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment