summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mysqld_error.h3
-rw-r--r--include/sql_state.h1
-rw-r--r--mysql-test/r/sp-error.result21
-rw-r--r--mysql-test/t/sp-error.test27
-rw-r--r--sql/share/czech/errmsg.txt1
-rw-r--r--sql/share/danish/errmsg.txt1
-rw-r--r--sql/share/dutch/errmsg.txt1
-rw-r--r--sql/share/english/errmsg.txt1
-rw-r--r--sql/share/estonian/errmsg.txt1
-rw-r--r--sql/share/french/errmsg.txt1
-rw-r--r--sql/share/german/errmsg.txt1
-rw-r--r--sql/share/greek/errmsg.txt1
-rw-r--r--sql/share/hungarian/errmsg.txt1
-rw-r--r--sql/share/italian/errmsg.txt1
-rw-r--r--sql/share/japanese/errmsg.txt1
-rw-r--r--sql/share/korean/errmsg.txt1
-rw-r--r--sql/share/norwegian-ny/errmsg.txt1
-rw-r--r--sql/share/norwegian/errmsg.txt1
-rw-r--r--sql/share/polish/errmsg.txt1
-rw-r--r--sql/share/portuguese/errmsg.txt1
-rw-r--r--sql/share/romanian/errmsg.txt1
-rw-r--r--sql/share/russian/errmsg.txt1
-rw-r--r--sql/share/serbian/errmsg.txt1
-rw-r--r--sql/share/slovak/errmsg.txt1
-rw-r--r--sql/share/spanish/errmsg.txt1
-rw-r--r--sql/share/swedish/errmsg.txt1
-rw-r--r--sql/share/ukrainian/errmsg.txt1
-rw-r--r--sql/sql_yacc.yy11
28 files changed, 83 insertions, 3 deletions
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 4b01004f1b4..b4d7edf3e96 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -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
diff --git a/include/sql_state.h b/include/sql_state.h
index 0c35f6bf8c9..9eff300d494 100644
--- a/include/sql_state.h
+++ b/include/sql_state.h
@@ -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", "",
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 6bc2af9862e..a48256e6824 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -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|
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index cbff9b37a11..ad96d0b403b 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -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 ;|
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index 6bcdeb9b05a..dd3ea82790a 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -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"
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index 2d9543e1076..c1471c78c7e 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -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"
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index 484892432c0..0f1f9f65e99 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -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"
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 4d3113d4055..2d5757977a4 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -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"
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index ba30d48b895..e610121e278 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -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"
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index 1285b7c9d54..04310561c90 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -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"
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index 0a6886686b4..ccbb0ced3d3 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -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"
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index 676beedc8f7..f7294fc0697 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -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"
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index 82b96eb8928..a127f35584d 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -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"
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index aea6afdd304..e8225c6ba48 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -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"
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index 6838a53ddca..af4e626a1fd 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -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"
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index 04c480108b9..dd67927adef 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -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"
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index 0b535727c9f..06c26a06e99 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -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"
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index 99782982ea7..08358db4b3a 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -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"
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 16dc1982a70..9aa6cf0d453 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -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"
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index 1db07659e8f..49ccf308634 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -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"
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index f58e91e5559..b79926cb7e4 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -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"
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index e12c4cbeb1f..be92447d43e 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -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"
diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt
index 9695ae5d207..92710650f50 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -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"
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index 2631a9b8e5e..c81d74075ad 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -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"
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index e3312dbdb8d..e79af2de398 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -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"
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 8e57aaeda51..28314a7367a 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -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"
diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt
index 0a40fe5b2a8..9263ee89400 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -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"
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b9e9b0126df..6a0d254a90c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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: