Commit 329013f9 authored by pem@mysql.comhem.se's avatar pem@mysql.comhem.se

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

parent 52c820fb
...@@ -342,4 +342,5 @@ ...@@ -342,4 +342,5 @@
#define ER_SP_NO_USE 1323 #define ER_SP_NO_USE 1323
#define ER_SP_VARCOND_AFTER_CURSHNDLR 1324 #define ER_SP_VARCOND_AFTER_CURSHNDLR 1324
#define ER_SP_CURSOR_AFTER_HANDLER 1325 #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", "", ...@@ -199,3 +199,4 @@ ER_SP_SUBSELECT_NYI, "0A000", "",
ER_SP_NO_USE, "42000", "", ER_SP_NO_USE, "42000", "",
ER_SP_VARCOND_AFTER_CURSHNDLR, "42000", "", ER_SP_VARCOND_AFTER_CURSHNDLR, "42000", "",
ER_SP_CURSOR_AFTER_HANDLER, "42000", "", ER_SP_CURSOR_AFTER_HANDLER, "42000", "",
ER_SP_CASE_NOT_FOUND, "20000", "",
...@@ -341,4 +341,25 @@ call bug2329_2()| ...@@ -341,4 +341,25 @@ call bug2329_2()|
ERROR 42S22: Unknown column 'v' in 'field list' ERROR 42S22: Unknown column 'v' in 'field list'
drop procedure bug2329_1| drop procedure bug2329_1|
drop procedure bug2329_2| 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| drop table t1|
...@@ -473,6 +473,33 @@ call bug2329_2()| ...@@ -473,6 +473,33 @@ call bug2329_2()|
drop procedure bug2329_1| drop procedure bug2329_1|
drop procedure bug2329_2| 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| drop table t1|
delimiter ;| delimiter ;|
...@@ -338,3 +338,4 @@ character-set=latin2 ...@@ -338,3 +338,4 @@ character-set=latin2
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -332,3 +332,4 @@ character-set=latin1 ...@@ -332,3 +332,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -340,3 +340,4 @@ character-set=latin1 ...@@ -340,3 +340,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -329,3 +329,4 @@ character-set=latin1 ...@@ -329,3 +329,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -334,3 +334,4 @@ character-set=latin7 ...@@ -334,3 +334,4 @@ character-set=latin7
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -329,3 +329,4 @@ character-set=latin1 ...@@ -329,3 +329,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -341,3 +341,4 @@ character-set=latin1 ...@@ -341,3 +341,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -329,3 +329,4 @@ character-set=greek ...@@ -329,3 +329,4 @@ character-set=greek
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -331,3 +331,4 @@ character-set=latin2 ...@@ -331,3 +331,4 @@ character-set=latin2
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -329,3 +329,4 @@ character-set=latin1 ...@@ -329,3 +329,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -331,3 +331,4 @@ character-set=ujis ...@@ -331,3 +331,4 @@ character-set=ujis
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -329,3 +329,4 @@ character-set=euckr ...@@ -329,3 +329,4 @@ character-set=euckr
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -331,3 +331,4 @@ character-set=latin1 ...@@ -331,3 +331,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -331,3 +331,4 @@ character-set=latin1 ...@@ -331,3 +331,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -333,3 +333,4 @@ character-set=latin2 ...@@ -333,3 +333,4 @@ character-set=latin2
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -330,3 +330,4 @@ character-set=latin1 ...@@ -330,3 +330,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -333,3 +333,4 @@ character-set=latin2 ...@@ -333,3 +333,4 @@ character-set=latin2
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -331,3 +331,4 @@ character-set=koi8r ...@@ -331,3 +331,4 @@ character-set=koi8r
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -324,3 +324,4 @@ character-set=cp1250 ...@@ -324,3 +324,4 @@ character-set=cp1250
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -337,3 +337,4 @@ character-set=latin2 ...@@ -337,3 +337,4 @@ character-set=latin2
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -331,3 +331,4 @@ character-set=latin1 ...@@ -331,3 +331,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -329,3 +329,4 @@ character-set=latin1 ...@@ -329,3 +329,4 @@ character-set=latin1
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -334,3 +334,4 @@ character-set=koi8u ...@@ -334,3 +334,4 @@ character-set=koi8u
"USE is not allowed in a stored procedure" "USE is not allowed in a stored procedure"
"Variable or condition declaration after cursor or handler declaration" "Variable or condition declaration after cursor or handler declaration"
"Cursor declaration after handler declaration" "Cursor declaration after handler declaration"
"Case not found for CASE statement"
...@@ -1908,9 +1908,16 @@ sp_case: ...@@ -1908,9 +1908,16 @@ sp_case:
; ;
sp_whens: sp_whens:
/* Empty */ {} /* Empty */
| WHEN_SYM sp_case {} {
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 {} | ELSE sp_proc_stmts {}
| WHEN_SYM sp_case {}
; ;
sp_labeled_control: 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