Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-10411 Providing compatibility for basic PL/SQL constructs
Changing label syntax from "label:" to "<<label>>".
- Loading branch information
Alexander Barkov
committed
Apr 5, 2017
1 parent
4de26a8
commit 47a75ed
Showing
3 changed files
with
154 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
SET sql_mode=ORACLE; | ||
CREATE FUNCTION f1 (a INT) RETURNS CLOB | ||
BEGIN | ||
<<label1>> | ||
BEGIN | ||
IF a = 1 THEN | ||
LEAVE label1; | ||
END IF; | ||
RETURN 'IS NOT 1'; | ||
END label1; | ||
RETURN 'IS 1'; | ||
END; | ||
/ | ||
SELECT f1(1); | ||
f1(1) | ||
IS 1 | ||
SELECT f1(2); | ||
f1(2) | ||
IS NOT 1 | ||
DROP FUNCTION f1; | ||
CREATE FUNCTION f1 (a INT) RETURNS INT | ||
BEGIN | ||
<<label1>> | ||
LOOP | ||
IF a = 2 THEN | ||
LEAVE label1; | ||
END IF; | ||
SET a= a-1; | ||
END LOOP; | ||
RETURN a; | ||
END; | ||
/ | ||
SELECT f1(4); | ||
f1(4) | ||
2 | ||
DROP FUNCTION f1; | ||
CREATE FUNCTION f1 (a INT) RETURNS INT | ||
BEGIN | ||
<<label1>> | ||
WHILE a>0 DO | ||
IF a = 2 THEN | ||
LEAVE label1; | ||
END IF; | ||
SET a= a-1; | ||
END WHILE label1; | ||
RETURN a; | ||
END; | ||
/ | ||
SELECT f1(4); | ||
f1(4) | ||
2 | ||
DROP FUNCTION f1; | ||
CREATE FUNCTION f1 (a INT) RETURNS INT | ||
BEGIN | ||
<<label1>> | ||
REPEAT | ||
IF a = 2 THEN | ||
LEAVE label1; | ||
END IF; | ||
SET a= a-1; | ||
UNTIL a=0 END REPEAT; | ||
RETURN a; | ||
END; | ||
/ | ||
SELECT f1(4); | ||
f1(4) | ||
2 | ||
DROP FUNCTION f1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
SET sql_mode=ORACLE; | ||
|
||
DELIMITER /; | ||
CREATE FUNCTION f1 (a INT) RETURNS CLOB | ||
BEGIN | ||
<<label1>> | ||
BEGIN | ||
IF a = 1 THEN | ||
LEAVE label1; | ||
END IF; | ||
RETURN 'IS NOT 1'; | ||
END label1; | ||
RETURN 'IS 1'; | ||
END; | ||
/ | ||
DELIMITER ;/ | ||
SELECT f1(1); | ||
SELECT f1(2); | ||
DROP FUNCTION f1; | ||
|
||
# LOOP WHILE REPEAT | ||
|
||
DELIMITER /; | ||
CREATE FUNCTION f1 (a INT) RETURNS INT | ||
BEGIN | ||
<<label1>> | ||
LOOP | ||
IF a = 2 THEN | ||
LEAVE label1; | ||
END IF; | ||
SET a= a-1; | ||
END LOOP; | ||
RETURN a; | ||
END; | ||
/ | ||
DELIMITER ;/ | ||
SELECT f1(4); | ||
DROP FUNCTION f1; | ||
|
||
|
||
DELIMITER /; | ||
CREATE FUNCTION f1 (a INT) RETURNS INT | ||
BEGIN | ||
<<label1>> | ||
WHILE a>0 DO | ||
IF a = 2 THEN | ||
LEAVE label1; | ||
END IF; | ||
SET a= a-1; | ||
END WHILE label1; | ||
RETURN a; | ||
END; | ||
/ | ||
DELIMITER ;/ | ||
SELECT f1(4); | ||
DROP FUNCTION f1; | ||
|
||
|
||
DELIMITER /; | ||
CREATE FUNCTION f1 (a INT) RETURNS INT | ||
BEGIN | ||
<<label1>> | ||
REPEAT | ||
IF a = 2 THEN | ||
LEAVE label1; | ||
END IF; | ||
SET a= a-1; | ||
UNTIL a=0 END REPEAT; | ||
RETURN a; | ||
END; | ||
/ | ||
DELIMITER ;/ | ||
SELECT f1(4); | ||
DROP FUNCTION f1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters