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
Add support for the GOTO statement in stored procedures, for Oracle compatibility.
Syntax:
GOTO label_name; |
Note, Oracle's implementation has a number of restrictions.
A GOTO statement cannot transfer control:
- into an IF statement, CASE statement, LOOP statement, or sub-block.
- from one IF statement clause to another, or from one CASE statement WHEN clause to another.
- out of a subprogram.
- into an exception handler.
- from an exception handler back into the current block (but it can transfer control from an exception handler into an enclosing block).
Under terms of this task will also labels to be used with non-block and non-loop statements:
SET sql_mode=ORACLE; |
DROP PROCEDURE p1; |
DELIMITER $$
|
CREATE PROCEDURE p1 AS |
BEGIN
|
<<label>>
|
SELECT 1; |
END; |
$$
|
DELIMITER ;
|
Currently the above definition returns a syntax error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1;
|
Labels with non-block/loop statements are needed, for example, to leave a loop which is inside a loop, which is inside a loop.