Skip to content

Commit

Permalink
MDEV-12088 sql_mode=ORACLE: Do not require BEGIN..END in multi-statem…
Browse files Browse the repository at this point in the history
…ent exception handlers in THEN clause
  • Loading branch information
Alexander Barkov committed Apr 5, 2017
1 parent 99df09e commit 915c5df
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
26 changes: 26 additions & 0 deletions mysql-test/suite/compat/oracle/r/exception.result
Expand Up @@ -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;
24 changes: 24 additions & 0 deletions mysql-test/suite/compat/oracle/t/exception.test
Expand Up @@ -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;
6 changes: 3 additions & 3 deletions sql/sql_yacc_ora.yy
Expand Up @@ -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:
Expand All @@ -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;
Expand Down

0 comments on commit 915c5df

Please sign in to comment.