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
47a75ed7
Commit
47a75ed7
authored
Aug 05, 2016
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-10411 Providing compatibility for basic PL/SQL constructs
Changing label syntax from "label:" to "<<label>>".
parent
4de26a8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
7 deletions
+154
-7
mysql-test/suite/compat/oracle/r/sp.result
mysql-test/suite/compat/oracle/r/sp.result
+68
-0
mysql-test/suite/compat/oracle/t/sp.test
mysql-test/suite/compat/oracle/t/sp.test
+74
-0
sql/sql_yacc_ora.yy
sql/sql_yacc_ora.yy
+12
-7
No files found.
mysql-test/suite/compat/oracle/r/sp.result
0 → 100644
View file @
47a75ed7
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;
mysql-test/suite/compat/oracle/t/sp.test
0 → 100644
View file @
47a75ed7
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
;
sql/sql_yacc_ora.yy
View file @
47a75ed7
...
...
@@ -1059,6 +1059,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
opt_component key_cache_name
sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
opt_constraint constraint opt_ident
label_declaration_oracle
%type <lex_string_with_metadata>
TEXT_STRING
...
...
@@ -3507,7 +3508,7 @@ sp_opt_label:
;
sp_labeled_block:
label_
ident ':'
BEGIN_SYM
label_
declaration_oracle
BEGIN_SYM
{
LEX *lex= Lex;
sp_pcontext *ctx= lex->spcont;
...
...
@@ -3519,10 +3520,10 @@ sp_labeled_block:
}
sp_block_content sp_opt_label
{
if ($
6
.str)
if ($
5
.str)
{
if (my_strcasecmp(system_charset_info, $
6.str, $5
->name.str) != 0)
my_yyabort_error((ER_SP_LABEL_MISMATCH, MYF(0), $
6
.str));
if (my_strcasecmp(system_charset_info, $
5.str, $4
->name.str) != 0)
my_yyabort_error((ER_SP_LABEL_MISMATCH, MYF(0), $
5
.str));
}
}
;
...
...
@@ -3675,14 +3676,14 @@ pop_sp_empty_label:
;
sp_labeled_control:
label_
ident ':'
LOOP_SYM
label_
declaration_oracle
LOOP_SYM
{
if (push_sp_label(thd, $1))
MYSQL_YYABORT;
}
loop_body pop_sp_label
{ }
| label_
ident ':'
WHILE_SYM
| label_
declaration_oracle
WHILE_SYM
{
if (push_sp_label(thd, $1))
MYSQL_YYABORT;
...
...
@@ -3690,7 +3691,7 @@ sp_labeled_control:
}
while_body pop_sp_label
{ }
| label_
ident ':'
REPEAT_SYM
| label_
declaration_oracle
REPEAT_SYM
{
if (push_sp_label(thd, $1))
MYSQL_YYABORT;
...
...
@@ -13808,6 +13809,10 @@ label_ident:
}
;
label_declaration_oracle:
SHIFT_LEFT label_ident SHIFT_RIGHT { $$= $2; }
;
ident_or_text:
ident { $$=$1;}
| TEXT_STRING_sys { $$=$1;}
...
...
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