Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
28f28591
Commit
28f28591
authored
Aug 22, 2016
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 18: WHILE syntax
parent
4212039d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
10 deletions
+90
-10
mysql-test/suite/compat/oracle/r/sp.result
mysql-test/suite/compat/oracle/r/sp.result
+42
-4
mysql-test/suite/compat/oracle/t/sp.test
mysql-test/suite/compat/oracle/t/sp.test
+46
-4
sql/sql_yacc_ora.yy
sql/sql_yacc_ora.yy
+2
-2
No files found.
mysql-test/suite/compat/oracle/r/sp.result
View file @
28f28591
...
@@ -98,12 +98,12 @@ DROP FUNCTION f1;
...
@@ -98,12 +98,12 @@ DROP FUNCTION f1;
CREATE FUNCTION f1 (a INT) RETURN INT AS
CREATE FUNCTION f1 (a INT) RETURN INT AS
BEGIN
BEGIN
<<label1>>
<<label1>>
WHILE a>0
DO
WHILE a>0
LOOP
IF a = 2 THEN
IF a = 2 THEN
LEAVE label1;
LEAVE label1;
END IF;
END IF;
SET a= a-1;
SET a= a-1;
END
WHILE
label1;
END
LOOP
label1;
RETURN a;
RETURN a;
END;
END;
/
/
...
@@ -427,10 +427,10 @@ i INT DEFAULT 5;
...
@@ -427,10 +427,10 @@ i INT DEFAULT 5;
x INT DEFAULT 10;
x INT DEFAULT 10;
BEGIN
BEGIN
<<label>>
<<label>>
WHILE i > 3
DO
WHILE i > 3
LOOP
i:= i - 1;
i:= i - 1;
SELECT i;
SELECT i;
END
WHILE
label;
END
LOOP
label;
END;
END;
END
END
/
/
...
@@ -736,3 +736,41 @@ SELECT @v;
...
@@ -736,3 +736,41 @@ SELECT @v;
@v
@v
100
100
DROP PROCEDURE p1;
DROP PROCEDURE p1;
# Testing WHILE loop
CREATE PROCEDURE p1 (a IN OUT INT)
AS
i INT:= 1;
j INT:= 3;
BEGIN
WHILE i<=j
LOOP
a:= a + i;
i:= i + 1;
END LOOP;
END;
/
SET @v=0;
CALL p1(@v);
SELECT @v;
@v
6
DROP PROCEDURE p1;
CREATE PROCEDURE p1 (a IN OUT INT)
AS
i INT:= 1;
j INT:= 3;
BEGIN
<<label>>
WHILE i<=j
LOOP
a:= a + i;
i:= i + 1;
END LOOP label;
END;
/
SET @v=0;
CALL p1(@v);
SELECT @v;
@v
6
DROP PROCEDURE p1;
mysql-test/suite/compat/oracle/t/sp.test
View file @
28f28591
...
@@ -91,12 +91,12 @@ DELIMITER /;
...
@@ -91,12 +91,12 @@ DELIMITER /;
CREATE
FUNCTION
f1
(
a
INT
)
RETURN
INT
AS
CREATE
FUNCTION
f1
(
a
INT
)
RETURN
INT
AS
BEGIN
BEGIN
<<
label1
>>
<<
label1
>>
WHILE
a
>
0
DO
WHILE
a
>
0
LOOP
IF
a
=
2
THEN
IF
a
=
2
THEN
LEAVE
label1
;
LEAVE
label1
;
END
IF
;
END
IF
;
SET
a
=
a
-
1
;
SET
a
=
a
-
1
;
END
WHILE
label1
;
END
LOOP
label1
;
RETURN
a
;
RETURN
a
;
END
;
END
;
/
/
...
@@ -454,10 +454,10 @@ BEGIN NOT ATOMIC
...
@@ -454,10 +454,10 @@ BEGIN NOT ATOMIC
x
INT
DEFAULT
10
;
x
INT
DEFAULT
10
;
BEGIN
BEGIN
<<
label
>>
<<
label
>>
WHILE
i
>
3
DO
WHILE
i
>
3
LOOP
i
:=
i
-
1
;
i
:=
i
-
1
;
SELECT
i
;
SELECT
i
;
END
WHILE
label
;
END
LOOP
label
;
END
;
END
;
END
END
/
/
...
@@ -801,3 +801,45 @@ SET @v=10;
...
@@ -801,3 +801,45 @@ SET @v=10;
CALL
p1
(
@
v
);
CALL
p1
(
@
v
);
SELECT
@
v
;
SELECT
@
v
;
DROP
PROCEDURE
p1
;
DROP
PROCEDURE
p1
;
--
echo
# Testing WHILE loop
DELIMITER
/
;
CREATE
PROCEDURE
p1
(
a
IN
OUT
INT
)
AS
i
INT
:=
1
;
j
INT
:=
3
;
BEGIN
WHILE
i
<=
j
LOOP
a
:=
a
+
i
;
i
:=
i
+
1
;
END
LOOP
;
END
;
/
DELIMITER
;
/
SET
@
v
=
0
;
CALL
p1
(
@
v
);
SELECT
@
v
;
DROP
PROCEDURE
p1
;
DELIMITER
/
;
CREATE
PROCEDURE
p1
(
a
IN
OUT
INT
)
AS
i
INT
:=
1
;
j
INT
:=
3
;
BEGIN
<<
label
>>
WHILE
i
<=
j
LOOP
a
:=
a
+
i
;
i
:=
i
+
1
;
END
LOOP
label
;
END
;
/
DELIMITER
;
/
SET
@
v
=
0
;
CALL
p1
(
@
v
);
SELECT
@
v
;
DROP
PROCEDURE
p1
;
sql/sql_yacc_ora.yy
View file @
28f28591
...
@@ -3485,7 +3485,7 @@ loop_body:
...
@@ -3485,7 +3485,7 @@ loop_body:
;
;
while_body:
while_body:
expr
DO
_SYM
expr
LOOP
_SYM
{
{
LEX *lex= Lex;
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
...
@@ -3501,7 +3501,7 @@ while_body:
...
@@ -3501,7 +3501,7 @@ while_body:
if (sp->restore_lex(thd))
if (sp->restore_lex(thd))
MYSQL_YYABORT;
MYSQL_YYABORT;
}
}
sp_proc_stmts1 END
WHILE
_SYM
sp_proc_stmts1 END
LOOP
_SYM
{
{
LEX *lex= Lex;
LEX *lex= Lex;
uint ip= lex->sphead->instructions();
uint ip= lex->sphead->instructions();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment