Commit 7ca2f816 authored by Alexander Barkov's avatar Alexander Barkov

Part#2 for MDEV-12107 sql_mode=ORACLE: Inside routines the CALL keywoard is optional

Allowing qualified procedure names to be used without the CALL keyword:

BEGIN
  test.p1(10);
  test.p2;
END;

Note:
- COMMIT and ROLLBACK cannot be used in a direct assignment anymore:
    COMMIT:= 10;
    ROLLBACK:= 10;
  But as they are reserved keywords in Oracle anyway, this is not a problem.
- SHUTDOWN now also cannot be used in direct a direct assignment:
    SHUTDOWN:=10;
  If this causes migration problems in the future, the grammar should
  be modified.

Note:
  Variables with names COMMIT, ROLLBACK and SHUTDOWN can still be assigned
  with the SET statement, e.g. SET COMMIT=10;
parent 29e7cf01
......@@ -200,8 +200,6 @@ CREATE PROCEDURE p1 (column_delete OUT INT) AS BEGIN column_delete:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (column_get OUT INT) AS BEGIN column_get:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (commit OUT INT) AS BEGIN commit:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (deallocate OUT INT) AS BEGIN deallocate:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (examined OUT INT) AS BEGIN examined:=10; END;/
......@@ -238,14 +236,10 @@ CREATE PROCEDURE p1 (reset OUT INT) AS BEGIN reset:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (restore OUT INT) AS BEGIN restore:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (rollback OUT INT) AS BEGIN rollback:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (security OUT INT) AS BEGIN security:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (server OUT INT) AS BEGIN server:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (shutdown OUT INT) AS BEGIN shutdown:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (signed OUT INT) AS BEGIN signed:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (socket OUT INT) AS BEGIN socket:=10; END;/
......@@ -272,6 +266,13 @@ CREATE PROCEDURE p1 (wrapper OUT INT) AS BEGIN wrapper:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (xa OUT INT) AS BEGIN xa:=10; END;/
DROP PROCEDURE p1/
# Testing that keyword_directly_not_assignable does not work in :=
CREATE PROCEDURE p1 (commit OUT INT) AS BEGIN commit:=10; END;/
ERROR 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 ':=10; END' at line 1
CREATE PROCEDURE p1 (rollback OUT INT) AS BEGIN rollback:=10; END;/
ERROR 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 ':=10; END' at line 1
CREATE PROCEDURE p1 (shutdown OUT INT) AS BEGIN shutdown:=10; END;/
ERROR 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 ':=10; END' at line 1
# Testing that keyword_directly_not_assignable works in SET statements.
CREATE PROCEDURE p1 (contains OUT INT) AS BEGIN SET contains=10; END;/
DROP PROCEDURE p1/
......@@ -2166,16 +2167,24 @@ END;
BEGIN
p1(10);
p2;
test.p1(10);
test.p2;
END;
/
comment
This is p1
comment
This is p2
comment
This is p1
comment
This is p2
CREATE PROCEDURE p3 AS
BEGIN
p1(10);
p2;
test.p1(10);
test.p2;
END
/
CALL p3;
......@@ -2183,6 +2192,10 @@ comment
This is p1
comment
This is p2
comment
This is p1
comment
This is p2
DROP PROCEDURE p3;
DROP PROCEDURE p2;
DROP PROCEDURE p1;
......@@ -209,8 +209,6 @@ CREATE PROCEDURE p1 (column_delete OUT INT) AS BEGIN column_delete:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (column_get OUT INT) AS BEGIN column_get:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (commit OUT INT) AS BEGIN commit:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (deallocate OUT INT) AS BEGIN deallocate:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (examined OUT INT) AS BEGIN examined:=10; END;/
......@@ -247,14 +245,10 @@ CREATE PROCEDURE p1 (reset OUT INT) AS BEGIN reset:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (restore OUT INT) AS BEGIN restore:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (rollback OUT INT) AS BEGIN rollback:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (security OUT INT) AS BEGIN security:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (server OUT INT) AS BEGIN server:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (shutdown OUT INT) AS BEGIN shutdown:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (signed OUT INT) AS BEGIN signed:=10; END;/
DROP PROCEDURE p1/
CREATE PROCEDURE p1 (socket OUT INT) AS BEGIN socket:=10; END;/
......@@ -284,6 +278,17 @@ DROP PROCEDURE p1/
DELIMITER ;/
--echo # Testing that keyword_directly_not_assignable does not work in :=
DELIMITER /;
--error ER_PARSE_ERROR
CREATE PROCEDURE p1 (commit OUT INT) AS BEGIN commit:=10; END;/
--error ER_PARSE_ERROR
CREATE PROCEDURE p1 (rollback OUT INT) AS BEGIN rollback:=10; END;/
--error ER_PARSE_ERROR
CREATE PROCEDURE p1 (shutdown OUT INT) AS BEGIN shutdown:=10; END;/
DELIMITER ;/
--echo # Testing that keyword_directly_not_assignable works in SET statements.
DELIMITER /;
CREATE PROCEDURE p1 (contains OUT INT) AS BEGIN SET contains=10; END;/
......@@ -1985,12 +1990,16 @@ END;
BEGIN
p1(10);
p2;
test.p1(10);
test.p2;
END;
/
CREATE PROCEDURE p3 AS
BEGIN
p1(10);
p2;
test.p1(10);
test.p2;
END
/
DELIMITER ;/
......
......@@ -3079,7 +3079,7 @@ sp_proc_stmt_if:
sp_statement:
statement
| IDENT_sys
| ident_directly_assignable
{
// Direct procedure call (without the CALL keyword)
LEX *lex = Lex;
......@@ -3090,6 +3090,16 @@ sp_statement:
sp_add_used_routine(lex, thd, lex->spname, TYPE_ENUM_PROCEDURE);
}
opt_sp_cparam_list
| ident_directly_assignable '.' ident
{
LEX *lex = Lex;
if (!(lex->spname= lex->make_sp_name(thd, $1, $3)))
MYSQL_YYABORT;
lex->sql_command= SQLCOM_CALL;
lex->value_list.empty();
sp_add_used_routine(lex, thd, lex->spname, TYPE_ENUM_PROCEDURE);
}
opt_sp_cparam_list
;
sp_proc_stmt_statement:
......@@ -14317,7 +14327,6 @@ keyword_directly_assignable:
| COLUMN_CREATE_SYM {}
| COLUMN_DELETE_SYM {}
| COLUMN_GET_SYM {}
| COMMIT_SYM {}
| DEALLOCATE_SYM {}
| EXAMINED_SYM {}
| EXCLUDE_SYM {}
......@@ -14339,10 +14348,8 @@ keyword_directly_assignable:
| REMOVE_SYM {}
| RESET_SYM {}
| RESTORE_SYM {}
| ROLLBACK_SYM {}
| SECURITY_SYM {}
| SERVER_SYM {}
| SHUTDOWN {}
| SIGNED_SYM {}
| SOCKET_SYM {}
| SLAVE {}
......@@ -14412,6 +14419,9 @@ keyword_directly_not_assignable:
| END { /* Compound. Reserved in Oracle */ }
| FOLLOWS_SYM { /* Conflicts with assignment in FOR EACH */}
| PRECEDES_SYM { /* Conflicts with assignment in FOR EACH */}
| COMMIT_SYM { /* Verb clause. Reserved in Oracle */ }
| ROLLBACK_SYM { /* Verb clause. Reserver in Oracle */ }
| SHUTDOWN { /* Verb clause */ }
;
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment