Details
-
Technical task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18
Description
When running sql_mode=ORACLE, MariaDB should support:
- user defined EXCEPTION declaration
- using user defined exceptions in RAISE name (signal)
- using user defined exceptions in RAISE (resignal)
- using user defined exceptions in EXCEPTION WHEN
DROP FUNCTION f1; |
CREATE FUNCTION f1 (a INT) RETURN INT |
AS
|
e1 EXCEPTION;
|
BEGIN
|
IF a < 0 THEN |
RAISE e1;
|
END IF; |
RETURN 0; |
EXCEPTION
|
WHEN e1 THEN RETURN 1; |
END; |
/
|
User defined exception names should be case insensitive.
Details
MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error:
SET sql_mode=DEFAULT; |
DROP PROCEDURE IF EXISTS p1; |
DELIMITER $$
|
CREATE PROCEDURE p1() |
BEGIN
|
DECLARE c0 CONDITION FOR SQLSTATE '45000'; |
DECLARE c1 CONDITION FOR SQLSTATE '45000'; |
DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; |
DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; |
END; |
$$
|
ERROR 1413 (42000): Duplicate handler declared in the same block
|
In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with SQLSTATE '45000' and MySQL errno ER_SIGNAL_EXCEPTION
SET sql_mode=ORACLE; |
DELIMITER $$;
|
CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR |
AS
|
e EXCEPTION;
|
f EXCEPTION;
|
a VARCHAR(64):=''; |
BEGIN
|
BEGIN |
IF c = 'e' THEN RAISE e; END IF; |
IF c = 'f' THEN RAISE f; END IF; |
EXCEPTION
|
WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; |
WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; |
END; |
RETURN 'Got no exceptions'; |
EXCEPTION
|
WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; |
END; |
$$
|
Notice, both e and f are associated with the same SQLSTATE and errno, but having WHEN e followed by WHEN f is valid, because e and f are different exceptions.
However, specifying the same exception multiple times in WHEN clause will not be possible:
SET sql_mode=ORACLE; |
DELIMITER $$;
|
CREATE FUNCTION f1() RETURN VARCHAR |
AS
|
e EXCEPTION;
|
BEGIN
|
RETURN 'Got no exceptions'; |
EXCEPTION
|
WHEN e THEN RETURN 'Got exception e'; |
WHEN e THEN RETURN 'Got exception e'; |
END; |
$$
|
The above script will return the ER_SP_DUP_HANDLER error:
ERROR 42000: Duplicate handler declared in the same block
|
Name space
In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions.
In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058.
Attachments
Issue Links
- is blocked by
-
MDEV-11037 Diagnostics_area refactoring for user defined exceptions
-
- Closed
-
- relates to
-
MDEV-11058 Put user defined exceptions to the same name space with variables
-
- Open
-
-
MDEV-20662 sql_mode=oracle does not support custom EXCEPTIONs
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Description |
When running {{sql_mode=ORACLE}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} |
When running {{sql_mode=ORACLE}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} |
Parent |
|
|
Issue Type | Task [ 3 ] | Technical task [ 7 ] |
Labels | Compatibility |
Labels | Compatibility |
Assignee | Alexander Barkov [ bar ] |
Labels | Compatibility |
Labels | Compatibility |
Labels | Compatibility |
Description |
When running {{sql_mode=ORACLE}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} Variables and exceptions are in the same name space. Having a variable and an exception with the same names is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} Variables and exceptions are in the same name space. Having a variable and an exception with the same names is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} Variables and exceptions are in the same name space. Having a variable and an exception with the same name is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE}} - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} Variables and exceptions are in the same name space. Having a variable and an exception with the same name is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignale) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} Variables and exceptions are in the same name space. Having a variable and an exception with the same name is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignale) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} Variables and exceptions are in the same name space. Having a variable and an exception with the same name is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} Variables and exceptions are in the same name space. Having a variable and an exception with the same name is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} Variables and exceptions are in the same name space. Having a variable and an exception with the same name is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. Variables and exceptions are in the same name space. Having a variable and an exception with the same name is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
Status | Open [ 1 ] | In Progress [ 3 ] |
Link |
This issue is blocked by |
Parent |
|
|
Issue Type | Technical task [ 7 ] | Task [ 3 ] |
Epic Link | MDEV-10137 [ 56868 ] |
Sprint | 10.2.3-2 [ 105 ] |
Rank | Ranked lower |
Link | This issue relates to MDEV-11058 [ MDEV-11058 ] |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. Variables and exceptions are in the same name space. Having a variable and an exception with the same name is not possible in the same scope: {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 RETURN VARCHAR AS e INT:=10; e EXCEPTION; BEGIN RAISE e; END; / SHOW ERRORS; {code} {noformat} LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/9 PLS-00371: at most one declaration for 'E' is permitted {noformat} |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. User defined exceptions will also be in the same name space with variables. In Oracle, variables and exceptions are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. User defined exceptions will also be in the same name space with variables. In Oracle, variables and exceptions are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
issue.field.resolutiondate | 2016-10-14 13:07:25.0 | 2016-10-14 13:07:25.166 |
Fix Version/s | 10.3.0 [ 22127 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Parent |
|
|
Issue Type | Task [ 3 ] | Technical task [ 7 ] |
Epic Link | MDEV-10137 [ 56868 ] |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. Note, MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} {code} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. Note, MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} {code} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because they are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} {code} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because they are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} {code} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because they are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because they are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because {{e}} and {{f}} they are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because {{e}} and {{f}} they are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because {{e}} and {{f}} are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
Description |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because {{e}} and {{f}} are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
When running {{sql_mode=ORACLE}}, MariaDB should support:
- user defined {{EXCEPTION}} declaration - using user defined exceptions in {{RAISE name}} (signal) - using user defined exceptions in {{RAISE}} (resignal) - using user defined exceptions in {{EXCEPTION WHEN}} {code:sql} DROP FUNCTION f1; CREATE FUNCTION f1 (a INT) RETURN INT AS e1 EXCEPTION; BEGIN IF a < 0 THEN RAISE e1; END IF; RETURN 0; EXCEPTION WHEN e1 THEN RETURN 1; END; / {code} User defined exception names should be case insensitive. h2. Details MariaDB does not support multiple handlers for the same SQLSTATE. This script returns an error: {code:sql} SET sql_mode=DEFAULT; DROP PROCEDURE IF EXISTS p1; DELIMITER $$ CREATE PROCEDURE p1() BEGIN DECLARE c0 CONDITION FOR SQLSTATE '45000'; DECLARE c1 CONDITION FOR SQLSTATE '45000'; DECLARE CONTINUE HANDLER FOR c0 SET @c0= 0; DECLARE CONTINUE HANDLER FOR c1 SET @c0= 1; END; $$ {code} {noformat} ERROR 1413 (42000): Duplicate handler declared in the same block {noformat} In sql_mode=ORACLE it will be possible to have multiple user-defined exceptions in the same block. All user defined exceptions will be associated with {{SQLSTATE '45000'}} and MySQL errno {{ER_SIGNAL_EXCEPTION}} {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1(c VARCHAR) RETURN VARCHAR AS e EXCEPTION; f EXCEPTION; a VARCHAR(64):=''; BEGIN BEGIN IF c = 'e' THEN RAISE e; END IF; IF c = 'f' THEN RAISE f; END IF; EXCEPTION WHEN e THEN BEGIN a:='Got EXCEPTION1/e; '; RAISE e; END; WHEN f THEN BEGIN a:='Got EXCEPTION1/f; '; RAISE f; END; END; RETURN 'Got no exceptions'; EXCEPTION WHEN OTHERS THEN RETURN a || 'Got EXCEPTION2/OTHERS;'; END; $$ {code} Notice, both {{e}} and {{f}} are associated with the same SQLSTATE and errno, but having {{WHEN e}} followed by {{WHEN f}} is valid, because {{e}} and {{f}} are different exceptions. However, specifying the same exception multiple times in {{WHEN}} clause will not be possible: {code:sql} SET sql_mode=ORACLE; DELIMITER $$; CREATE FUNCTION f1() RETURN VARCHAR AS e EXCEPTION; BEGIN RETURN 'Got no exceptions'; EXCEPTION WHEN e THEN RETURN 'Got exception e'; WHEN e THEN RETURN 'Got exception e'; END; $$ {code} The above script will return the {{ER_SP_DUP_HANDLER}} error: {noformat} ERROR 42000: Duplicate handler declared in the same block {noformat} h2. Name space In MariaDB variables and exceptions (conditions) are in separate name spaces. Oracle-alike user defined exceptions will be in the same name space with MariaDB conditions. In Oracle, variables and exceptions (conditions) are in the same name space. Placing exceptions and variables into the same name space will be done separately. See MDEV-11058. |
Labels | Compatibility | Compatibility NRE-307517 |
Labels | Compatibility NRE-307517 | Approved Compatibility NRE-307517 |
NRE Projects | NRE-307517 |
Labels | Approved Compatibility NRE-307517 | Approved Compatibility |
NRE Approved | Yes [ 10304 ] |
Labels | Approved Compatibility | Compatibility |
Labels | Compatibility | Compatibility need_review |
Component/s | Parser [ 10201 ] | |
Component/s | Stored routines [ 13905 ] | |
Component/s | OTHER [ 10125 ] |
Labels | Compatibility need_review | Compatibility |
Workflow | MariaDB v3 [ 76693 ] | MariaDB v4 [ 150776 ] |
Link |
This issue relates to |