Commit 5c7f368b authored by unknown's avatar unknown

Fixed BUG#3287: Stored Procedure Case Statement Not SQL:2003 Compliant.


include/mysqld_error.h:
  New error code for missing ELSE in SP CASE statement.
include/sql_state.h:
  New error code for missing ELSE in SP CASE statement.
mysql-test/r/sp-error.result:
  Test case for missing ELSE in SP CASE statement.
mysql-test/t/sp-error.test:
  Test case for missing ELSE in SP CASE statement.
sql/share/czech/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/danish/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/dutch/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/english/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/estonian/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/french/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/german/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/greek/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/hungarian/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/italian/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/japanese/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/korean/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/norwegian-ny/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/norwegian/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/polish/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/portuguese/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/romanian/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/russian/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/serbian/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/slovak/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/spanish/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/swedish/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/share/ukrainian/errmsg.txt:
  New error message for missing ELSE in SP CASE statement.
sql/sql_yacc.yy:
  Generate run-time error instruction when no ELSE in SP CASE statement.
parent 7456a3e9
......@@ -342,4 +342,5 @@
#define ER_SP_NO_USE 1323
#define ER_SP_VARCOND_AFTER_CURSHNDLR 1324
#define ER_SP_CURSOR_AFTER_HANDLER 1325
#define ER_ERROR_MESSAGES 326
#define ER_SP_CASE_NOT_FOUND 1326
#define ER_ERROR_MESSAGES 327
......@@ -199,3 +199,4 @@ ER_SP_SUBSELECT_NYI, "0A000", "",
ER_SP_NO_USE, "42000", "",
ER_SP_VARCOND_AFTER_CURSHNDLR, "42000", "",
ER_SP_CURSOR_AFTER_HANDLER, "42000", "",
ER_SP_CASE_NOT_FOUND, "20000", "",
......@@ -341,4 +341,25 @@ call bug2329_2()|
ERROR 42S22: Unknown column 'v' in 'field list'
drop procedure bug2329_1|
drop procedure bug2329_2|
create function bug3287() returns int
begin
declare v int default null;
case
when v is not null then return 1;
end case;
return 2;
end|
select bug3287()|
ERROR 20000: Case not found for CASE statement
drop function bug3287|
create procedure bug3287(x int)
case x
when 0 then
insert into test.t1 values (x, 0.1);
when 1 then
insert into test.t1 values (x, 1.1);
end case|
call bug3287(2)|
ERROR 20000: Case not found for CASE statement
drop procedure bug3287|
drop table t1|
......@@ -473,6 +473,33 @@ call bug2329_2()|
drop procedure bug2329_1|
drop procedure bug2329_2|
#
# BUG#3287
#
create function bug3287() returns int
begin
declare v int default null;
case
when v is not null then return 1;
end case;
return 2;
end|
--error 1326
select bug3287()|
drop function bug3287|
create procedure bug3287(x int)
case x
when 0 then
insert into test.t1 values (x, 0.1);
when 1 then
insert into test.t1 values (x, 1.1);
end case|
--error 1326
call bug3287(2)|
drop procedure bug3287|
drop table t1|
delimiter ;|
......@@ -338,3 +338,4 @@ character-set=latin2
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -332,3 +332,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -340,3 +340,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -329,3 +329,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -334,3 +334,4 @@ character-set=latin7
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -329,3 +329,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -341,3 +341,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -329,3 +329,4 @@ character-set=greek
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -331,3 +331,4 @@ character-set=latin2
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -329,3 +329,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -331,3 +331,4 @@ character-set=ujis
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -329,3 +329,4 @@ character-set=euckr
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -331,3 +331,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -331,3 +331,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -333,3 +333,4 @@ character-set=latin2
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -330,3 +330,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -333,3 +333,4 @@ character-set=latin2
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -331,3 +331,4 @@ character-set=koi8r
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -324,3 +324,4 @@ character-set=cp1250
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -337,3 +337,4 @@ character-set=latin2
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -331,3 +331,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -329,3 +329,4 @@ character-set=latin1
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -334,3 +334,4 @@ character-set=koi8u
"USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration"
"Case not found for CASE statement"
......@@ -1908,9 +1908,16 @@ sp_case:
;
sp_whens:
/* Empty */ {}
| WHEN_SYM sp_case {}
/* Empty */
{
sp_head *sp= Lex->sphead;
uint ip= sp->instructions();
sp_instr_error *i= new sp_instr_error(ip, ER_SP_CASE_NOT_FOUND);
sp->add_instr(i);
}
| ELSE sp_proc_stmts {}
| WHEN_SYM sp_case {}
;
sp_labeled_control:
......
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