MDEV-12088 sql_mode=ORACLE: Do not require BEGIN..END in multi-statement exception handlers in THEN clause

This commit is contained in:
Alexander Barkov 2017-02-20 19:50:39 +04:00
parent 99df09ecab
commit 915c5df865
3 changed files with 53 additions and 3 deletions

View file

@ -381,3 +381,29 @@ DROP FUNCTION f1;
#
# End of MDEV-10587 sql_mode=ORACLE: User defined exceptions
#
#
# MDEV-12088 sql_mode=ORACLE: Do not require BEGIN..END in multi-statement exception handlers in THEN clause
#
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (10),(20),(30);
CREATE PROCEDURE p1(a INT) AS
BEGIN
INSERT INTO t1 (a) VALUES (a);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
a:= a+1;
INSERT INTO t1 VALUES (a);
WHEN OTHERS THEN
NULL;
NULL;
END;
$$
CALL p1(30);
SELECT * FROM t1;
a
10
20
30
31
DROP PROCEDURE p1;
DROP TABLE t1;

View file

@ -431,3 +431,27 @@ DROP FUNCTION f1;
--echo #
--echo # End of MDEV-10587 sql_mode=ORACLE: User defined exceptions
--echo #
--echo #
--echo # MDEV-12088 sql_mode=ORACLE: Do not require BEGIN..END in multi-statement exception handlers in THEN clause
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (10),(20),(30);
DELIMITER $$;
CREATE PROCEDURE p1(a INT) AS
BEGIN
INSERT INTO t1 (a) VALUES (a);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
a:= a+1;
INSERT INTO t1 VALUES (a);
WHEN OTHERS THEN
NULL;
NULL;
END;
$$
DELIMITER ;$$
CALL p1(30);
SELECT * FROM t1;
DROP PROCEDURE p1;
DROP TABLE t1;

View file

@ -3734,8 +3734,8 @@ opt_exception_clause:
;
exception_handlers:
exception_handler ';' { $$= 1; }
| exception_handlers exception_handler ';' { $$= $1 + 1; }
exception_handler { $$= 1; }
| exception_handlers exception_handler { $$= $1 + 1; }
;
exception_handler:
@ -3746,7 +3746,7 @@ exception_handler:
}
sp_hcond_list
THEN_SYM
sp_proc_stmt
sp_proc_stmts1_implicit_block
{
if (Lex->sp_handler_declaration_finalize(thd, sp_handler::EXIT))
MYSQL_YYABORT;