diff options
author | pem@mysql.telia.com <> | 2003-09-16 14:26:08 +0200 |
---|---|---|
committer | pem@mysql.telia.com <> | 2003-09-16 14:26:08 +0200 |
commit | 04f0570fe8a846ade8c4eaa2b87f4432239269bd (patch) | |
tree | dccbb3bbe8e061d9d2956a24883ae6f2b5002f9e /mysql-test/r | |
parent | 7a7f3c13d4189ae38471edc517d72ecf8948fb92 (diff) | |
download | mariadb-git-04f0570fe8a846ade8c4eaa2b87f4432239269bd.tar.gz |
Implemented SP CONDITIONs and HANDLERs, with the extension of handling
MySQL error codes as well.
(No UNDO HANDLERs yet, and no SIGNAL or RESIGNAL.)
WL#850
Diffstat (limited to 'mysql-test/r')
-rw-r--r-- | mysql-test/r/sp-error.result | 25 | ||||
-rw-r--r-- | mysql-test/r/sp.result | 57 |
2 files changed, 82 insertions, 0 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 95fe8edf321..d839b8a3af8 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -96,3 +96,28 @@ select f(1, 2); ERROR HY000: Wrong number of arguments for FUNCTION f, expected 1, got 2 drop procedure p; drop function f; +create procedure p(val int, out res int) +begin +declare x int default 0; +declare continue handler for foo set x = 1; +insert into test.t1 values (val); +if (x) then +set res = 0; +else +set res = 1; +end if; +end; +ERROR HY000: Undefined CONDITION: foo +create procedure p(val int, out res int) +begin +declare x int default 0; +declare foo condition for 1146; +declare continue handler for bar set x = 1; +insert into test.t1 values (val); +if (x) then +set res = 0; +else +set res = 1; +end if; +end; +ERROR HY000: Undefined CONDITION: bar diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index c08d252cfe3..42f720c7791 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -443,6 +443,63 @@ drop function inc; drop function mul; drop function append; drop function fun; +create procedure hndlr1(val int) +begin +declare x int default 0; +declare foo condition for 1146; +declare continue handler for foo set x = 1; +insert into test.t666 values ("hndlr1", val); # Non-existing table +if (x) then +insert into test.t1 values ("hndlr1", val); # This instead then +end if; +end; +call hndlr1(42); +select * from t1; +id data +hndlr1 42 +delete from t1; +drop procedure hndlr1; +create procedure hndlr2(val int) +begin +declare x int default 0; +begin +declare exit handler for '42S02' set x = 1; +insert into test.t666 values ("hndlr2", val); # Non-existing table +end; +insert into test.t1 values ("hndlr2", x); +end; +call hndlr2(42); +select * from t1; +id data +hndlr2 1 +delete from t1; +drop procedure hndlr2; +create procedure hndlr3(val int) +begin +declare x int default 0; +declare continue handler for sqlexception # Any error +begin +declare z int; +set z = 2 * val; +set x = 1; +end; +if val < 10 then +begin +declare y int; +set y = val + 10; +insert into test.t666 values ("hndlr3", y); # Non-existing table +if x then +insert into test.t1 values ("hndlr3", y); +end if; +end; +end if; +end; +call hndlr3(3); +select * from t1; +id data +hndlr3 13 +delete from t1; +drop procedure hndlr3; drop table if exists fac; create table fac (n int unsigned not null primary key, f bigint unsigned); create procedure ifac(n int unsigned) |