diff options
author | Michael Widenius <monty@askmonty.org> | 2013-05-06 16:51:41 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-05-06 16:51:41 +0300 |
commit | d4be9e7bc0cfd5ddd444ecc64daa4166597ca2eb (patch) | |
tree | f3f0cefa31373c8108119522b900f1c7064d645a /mysql-test/r | |
parent | aa885cea7153859951073fc97a726af703abf7a8 (diff) | |
download | mariadb-git-d4be9e7bc0cfd5ddd444ecc64daa4166597ca2eb.tar.gz |
If one declared several continue handler for the same condition on different level of stored procedures, all of them where executed.
Now we only execute the innermost of them (the most relevant).
The solution was to add a 'handled' marker to MYSQL_ERROR and mark all elements for which we have executed a condition handler.
When searching for new conditions, we will ignore any marked element.
.bzrignore:
Ignore error message file
mysql-test/r/sp.result:
Added testcase for continue handlers.
mysql-test/t/sp.test:
Added testcase for continue handlers.
sql/sp_head.cc:
Mark errors for which we will excute a handler as 'handled'
Ignore already handled warnings/errors
sql/sql_error.cc:
Add 'handled' argument to MYSQL_ERROR, so that we can mark the errors/warnings we have handled.
sql/sql_error.h:
Add 'handled' argument to MYSQL_ERROR, so that we can mark the errors/warnings we have handled.
Diffstat (limited to 'mysql-test/r')
-rw-r--r-- | mysql-test/r/sp.result | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index defd3955f6c..a0f21b434d1 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -7916,4 +7916,65 @@ DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP FUNCTION f4; + +Stored procedures and a condition handler in a nested procedure call +doesn't suppress the condition from being passed on to the calling +procedure + +drop procedure if exists p1; +drop procedure if exists p0; +create table t1 (id int); +create procedure p1 () begin +declare i int default 0; +declare continue handler for not found begin +select "You should see this message and the warning that generated this" as "message"; +show warnings; +end; +select id into i from t1; +end$$ +create procedure p0 () begin +declare continue handler for not found begin +select "You should NOT see this message" as "message"; +end; +call p1(); +end$$ +call p0(); +message +You should see this message and the warning that generated this +Level Code Message +Warning 1329 No data - zero rows fetched, selected, or processed +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +drop procedure p1; +drop procedure p0; +drop table t1; + +Test if stored procedures propagates errors + +create table t1 (id int primary key); +create procedure p1 () begin +insert into t1 values(1); +insert into t1 values(2); +insert into t1 values(2); +insert into t1 values(3); +end$$ +create procedure p2 () begin +declare x int; +select id into x from t1 where id=5; +end$$ +call p1(); +ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +show warnings; +Level Code Message +Error 1062 Duplicate entry '2' for key 'PRIMARY' +select * from t1; +id +1 +2 +call p2(); +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +drop procedure p1; +drop procedure p2; +drop table t1; # End of 5.5 test |