summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorpem@mysql.telia.com <>2003-10-03 17:38:12 +0200
committerpem@mysql.telia.com <>2003-10-03 17:38:12 +0200
commite8634f80bde84993c16043342742077ca2904881 (patch)
tree769eacf817cf9abb382f61d3cb1a090be509246b /mysql-test
parentdbf45cbc3c49f1a2e7afb3cb6da510e53249f852 (diff)
downloadmariadb-git-e8634f80bde84993c16043342742077ca2904881.tar.gz
Check that a FUNCTION contains RETURN and that we actually get a return value.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/sp-error.result17
-rw-r--r--mysql-test/t/sp-error.test23
2 files changed, 40 insertions, 0 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 109d84b2b8a..d90aef7f609 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -121,3 +121,20 @@ set res = 1;
end if;
end;
ERROR HY000: Undefined CONDITION: bar
+create function f(val int) returns int
+begin
+declare x int;
+set x = val+3;
+end;
+ERROR HY000: No RETURN found in FUNCTION f
+create function f(val int) returns int
+begin
+declare x int;
+set x = val+3;
+if x < 4 then
+return x;
+end if;
+end;
+select f(10);
+ERROR HY000: FUNCTION f ended without RETURN
+drop function f;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index ab3ee6a9ac6..ba2805bfb0c 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -171,4 +171,27 @@ begin
end if;
end|
+--error 1296
+create function f(val int) returns int
+begin
+ declare x int;
+
+ set x = val+3;
+end|
+
+create function f(val int) returns int
+begin
+ declare x int;
+
+ set x = val+3;
+ if x < 4 then
+ return x;
+ end if;
+end|
+
+--error 1297
+select f(10)|
+
+drop function f|
+
delimiter ;|