Commit bd76d445 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10411 Providing compatibility for basic PL/SQL constructs

Part 12: No parentheses if no arguments
Now "CREATE PROCEDURE p1 AS" is supported with no parentheses after the name.
Note, "CREATE FUNCTION f1 AS" is not supported yet, due to grammar conflict
with UDFs. Functions will be done in a separate patch.
parent f3a0df72
SET sql_mode=ORACLE; SET sql_mode=ORACLE;
# Testing routines with no parameters
CREATE PROCEDURE p1
AS
BEGIN
SET @a=10;
END;
/
SHOW CREATE PROCEDURE p1;
Procedure p1
sql_mode PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER
Create Procedure CREATE DEFINER="root"@"localhost" PROCEDURE "p1"()
AS
BEGIN
SET @a=10;
END
character_set_client latin1
collation_connection latin1_swedish_ci
Database Collation latin1_swedish_ci
SET @a=0;
CALL p1();
SELECT @a;
@a
10
DROP PROCEDURE p1;
# Testing ":=" to set the default value of a variable # Testing ":=" to set the default value of a variable
CREATE FUNCTION f1 () RETURNS NUMBER(10) AS CREATE FUNCTION f1 () RETURNS NUMBER(10) AS
a NUMBER(10) := 10; a NUMBER(10) := 10;
......
SET sql_mode=ORACLE; SET sql_mode=ORACLE;
--echo # Testing routines with no parameters
DELIMITER /;
CREATE PROCEDURE p1
AS
BEGIN
SET @a=10;
END;
/
DELIMITER ;/
--vertical_results
SHOW CREATE PROCEDURE p1;
--horizontal_results
SET @a=0;
CALL p1();
SELECT @a;
DROP PROCEDURE p1;
--echo # Testing ":=" to set the default value of a variable --echo # Testing ":=" to set the default value of a variable
DELIMITER /; DELIMITER /;
CREATE FUNCTION f1 () RETURNS NUMBER(10) AS CREATE FUNCTION f1 () RETURNS NUMBER(10) AS
......
...@@ -2944,6 +2944,30 @@ sp_opt_inout: ...@@ -2944,6 +2944,30 @@ sp_opt_inout:
| INOUT_SYM { $$= sp_variable::MODE_INOUT; } | INOUT_SYM { $$= sp_variable::MODE_INOUT; }
; ;
sp_parenthesized_fdparam_list:
'('
{
Lex->sphead->m_param_begin= YYLIP->get_cpp_tok_start() + 1;
}
sp_fdparam_list
')'
{
Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
}
;
sp_parenthesized_pdparam_list:
'('
{
Lex->sphead->m_param_begin= YYLIP->get_cpp_tok_start() + 1;
}
sp_pdparam_list
')'
{
Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
}
;
sp_proc_stmts: sp_proc_stmts:
/* Empty */ {} /* Empty */ {}
| sp_proc_stmts sp_proc_stmt ';' | sp_proc_stmts sp_proc_stmt ';'
...@@ -16409,45 +16433,32 @@ sf_tail: ...@@ -16409,45 +16433,32 @@ sf_tail:
FUNCTION_SYM /* $1 */ FUNCTION_SYM /* $1 */
opt_if_not_exists /* $2 */ opt_if_not_exists /* $2 */
sp_name /* $3 */ sp_name /* $3 */
{ { /* $4 */
if (!Lex->make_sp_head_no_recursive(thd, $2, $3, TYPE_ENUM_FUNCTION)) if (!Lex->make_sp_head_no_recursive(thd, $2, $3,
TYPE_ENUM_FUNCTION))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->spname= $3; Lex->spname= $3;
} }
'(' /* $5 */ sp_parenthesized_fdparam_list /* $5 */
{ /* $6 */ RETURNS_SYM /* $6 */
LEX *lex= Lex; { /* $7 */
Lex_input_stream *lip= YYLIP;
const char* tmp_param_begin;
tmp_param_begin= lip->get_cpp_tok_start();
tmp_param_begin++;
lex->sphead->m_param_begin= tmp_param_begin;
}
sp_fdparam_list /* $7 */
')' /* $8 */
{ /* $9 */
Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
}
RETURNS_SYM /* $10 */
{ /* $11 */
LEX *lex= Lex; LEX *lex= Lex;
lex->init_last_field(&lex->sphead->m_return_field_def, NULL, lex->init_last_field(&lex->sphead->m_return_field_def, NULL,
thd->variables.collation_database); thd->variables.collation_database);
} }
type_with_opt_collate /* $12 */ type_with_opt_collate /* $8 */
{ /* $13 */ { /* $9 */
if (Lex->sphead->fill_field_definition(thd, Lex->last_field)) if (Lex->sphead->fill_field_definition(thd, Lex->last_field))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
sp_c_chistics /* $14 */ sp_c_chistics /* $10 */
{ /* $15 */ { /* $11 */
LEX *lex= thd->lex; LEX *lex= thd->lex;
Lex_input_stream *lip= YYLIP; Lex_input_stream *lip= YYLIP;
lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
} }
sp_proc_stmt_in_returns_clause /* $16 */ sp_proc_stmt_in_returns_clause /* $12 */
{ {
LEX *lex= thd->lex; LEX *lex= thd->lex;
sp_head *sp= lex->sphead; sp_head *sp= lex->sphead;
...@@ -16473,19 +16484,7 @@ sp_tail: ...@@ -16473,19 +16484,7 @@ sp_tail:
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->spname= $3; Lex->spname= $3;
} }
'(' sp_parenthesized_pdparam_list
{
const char* tmp_param_begin;
tmp_param_begin= YYLIP->get_cpp_tok_start();
tmp_param_begin++;
Lex->sphead->m_param_begin= tmp_param_begin;
}
sp_pdparam_list
')'
{
Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
}
sp_c_chistics sp_c_chistics
{ {
Lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start()); Lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start());
......
...@@ -2331,6 +2331,43 @@ sp_opt_inout: ...@@ -2331,6 +2331,43 @@ sp_opt_inout:
| INOUT_SYM { $$= sp_variable::MODE_INOUT; } | INOUT_SYM { $$= sp_variable::MODE_INOUT; }
; ;
sp_parenthesized_fdparam_list:
'('
{
Lex->sphead->m_param_begin= YYLIP->get_cpp_tok_start() + 1;
}
sp_fdparam_list
')'
{
Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
}
;
sp_parenthesized_pdparam_list:
'('
{
Lex->sphead->m_param_begin= YYLIP->get_cpp_tok_start() + 1;
}
sp_pdparam_list
')'
{
Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
}
;
sp_no_param:
/* Empty */
{
Lex->sphead->m_param_begin= Lex->sphead->m_param_end=
YYLIP->get_cpp_tok_start() + 1;
}
;
opt_sp_parenthesized_pdparam_list:
sp_no_param
| sp_parenthesized_pdparam_list
;
sp_proc_stmts: sp_proc_stmts:
/* Empty */ {} /* Empty */ {}
| sp_proc_stmts sp_proc_stmt ';' | sp_proc_stmts sp_proc_stmt ';'
...@@ -15991,46 +16028,33 @@ sf_tail: ...@@ -15991,46 +16028,33 @@ sf_tail:
FUNCTION_SYM /* $1 */ FUNCTION_SYM /* $1 */
opt_if_not_exists /* $2 */ opt_if_not_exists /* $2 */
sp_name /* $3 */ sp_name /* $3 */
{ { /* $4 */
if (!Lex->make_sp_head_no_recursive(thd, $2, $3, TYPE_ENUM_FUNCTION)) if (!Lex->make_sp_head_no_recursive(thd, $2, $3,
TYPE_ENUM_FUNCTION))
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->spname= $3; Lex->spname= $3;
} }
'(' /* $5 */ sp_parenthesized_fdparam_list /* $5 */
{ /* $6 */ RETURNS_SYM /* $6 */
LEX *lex= Lex; { /* $7 */
Lex_input_stream *lip= YYLIP;
const char* tmp_param_begin;
tmp_param_begin= lip->get_cpp_tok_start();
tmp_param_begin++;
lex->sphead->m_param_begin= tmp_param_begin;
}
sp_fdparam_list /* $7 */
')' /* $8 */
{ /* $9 */
Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
}
RETURNS_SYM /* $10 */
{ /* $11 */
LEX *lex= Lex; LEX *lex= Lex;
lex->init_last_field(&lex->sphead->m_return_field_def, NULL, lex->init_last_field(&lex->sphead->m_return_field_def, NULL,
thd->variables.collation_database); thd->variables.collation_database);
} }
type_with_opt_collate /* $12 */ type_with_opt_collate /* $8 */
{ /* $13 */ { /* $9 */
if (Lex->sphead->fill_field_definition(thd, Lex->last_field)) if (Lex->sphead->fill_field_definition(thd, Lex->last_field))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
sp_c_chistics /* $14 */ sp_c_chistics /* $10 */
{ /* $15 */ { /* $11 */
LEX *lex= thd->lex; LEX *lex= thd->lex;
Lex_input_stream *lip= YYLIP; Lex_input_stream *lip= YYLIP;
lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
} }
sp_tail_is /* $16 */ sp_tail_is /* $12 */
sp_body /* $17 */ sp_body /* $13 */
{ {
LEX *lex= thd->lex; LEX *lex= thd->lex;
sp_head *sp= lex->sphead; sp_head *sp= lex->sphead;
...@@ -16056,19 +16080,7 @@ sp_tail: ...@@ -16056,19 +16080,7 @@ sp_tail:
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->spname= $3; Lex->spname= $3;
} }
'(' opt_sp_parenthesized_pdparam_list
{
const char* tmp_param_begin;
tmp_param_begin= YYLIP->get_cpp_tok_start();
tmp_param_begin++;
Lex->sphead->m_param_begin= tmp_param_begin;
}
sp_pdparam_list
')'
{
Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
}
sp_c_chistics sp_c_chistics
{ {
Lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start()); Lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start());
......
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