Commit 966cc802 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-13528 Add LEX::sp_body_finalize_{procedure|function}

parent 22c9663d
......@@ -5853,6 +5853,32 @@ sp_head *LEX::make_sp_head(THD *thd, const sp_name *name,
}
bool LEX::sp_body_finalize_procedure(THD *thd)
{
if (sphead->check_unresolved_goto())
return true;
sphead->set_stmt_end(thd);
sphead->restore_thd_mem_root(thd);
return false;
}
bool LEX::sp_body_finalize_function(THD *thd)
{
if (sphead->is_not_allowed_in_function("function"))
return true;
if (!(sphead->m_flags & sp_head::HAS_RETURN))
{
my_error(ER_SP_NORETURN, MYF(0), ErrConvDQName(sphead).ptr());
return true;
}
if (sp_body_finalize_procedure(thd))
return true;
(void) is_native_function_with_warn(thd, &sphead->m_name);
return false;
}
bool LEX::sp_block_with_exceptions_finalize_declarations(THD *thd)
{
/*
......
......@@ -3176,6 +3176,8 @@ struct LEX: public Query_tables_list
return NULL;
return make_sp_head_no_recursive(thd, name, sph);
}
bool sp_body_finalize_function(THD *);
bool sp_body_finalize_procedure(THD *);
bool call_statement_start(THD *thd, sp_name *name);
bool call_statement_start(THD *thd, const LEX_CSTRING *name);
bool call_statement_start(THD *thd, const LEX_CSTRING *name1,
......
......@@ -16615,6 +16615,7 @@ sf_tail:
opt_if_not_exists
sp_name
{
Lex->sql_command= SQLCOM_CREATE_SPFUNCTION;
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
&sp_handler_function))
MYSQL_YYABORT;
......@@ -16631,25 +16632,15 @@ sf_tail:
}
sp_proc_stmt_in_returns_clause
{
LEX *lex= thd->lex;
sp_head *sp= lex->sphead;
if (sp->is_not_allowed_in_function("function"))
if (Lex->sp_body_finalize_function(thd))
MYSQL_YYABORT;
lex->sql_command= SQLCOM_CREATE_SPFUNCTION;
sp->set_stmt_end(thd);
if (!(sp->m_flags & sp_head::HAS_RETURN))
my_yyabort_error((ER_SP_NORETURN, MYF(0),
ErrConvDQName(sp).ptr()));
(void) is_native_function_with_warn(thd, &sp->m_name);
sp->restore_thd_mem_root(thd);
}
;
sp_tail:
opt_if_not_exists sp_name
{
Lex->sql_command= SQLCOM_CREATE_PROCEDURE;
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
&sp_handler_procedure))
MYSQL_YYABORT;
......@@ -16662,12 +16653,8 @@ sp_tail:
}
sp_proc_stmt
{
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp->set_stmt_end(thd);
lex->sql_command= SQLCOM_CREATE_PROCEDURE;
sp->restore_thd_mem_root(thd);
if (Lex->sp_body_finalize_procedure(thd))
MYSQL_YYABORT;
}
;
......
......@@ -16837,6 +16837,7 @@ sf_tail:
opt_if_not_exists
sp_name
{
Lex->sql_command= SQLCOM_CREATE_SPFUNCTION;
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
&sp_handler_function))
MYSQL_YYABORT;
......@@ -16854,27 +16855,15 @@ sf_tail:
sp_tail_is
sp_body
{
LEX *lex= thd->lex;
sp_head *sp= lex->sphead;
if (sp->check_unresolved_goto())
if (Lex->sp_body_finalize_function(thd))
MYSQL_YYABORT;
if (sp->is_not_allowed_in_function("function"))
MYSQL_YYABORT;
lex->sql_command= SQLCOM_CREATE_SPFUNCTION;
sp->set_stmt_end(thd);
if (!(sp->m_flags & sp_head::HAS_RETURN))
my_yyabort_error((ER_SP_NORETURN, MYF(0),
ErrConvDQName(sp).ptr()));
(void) is_native_function_with_warn(thd, &sp->m_name);
sp->restore_thd_mem_root(thd);
}
;
sp_tail:
opt_if_not_exists sp_name
{
Lex->sql_command= SQLCOM_CREATE_PROCEDURE;
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
&sp_handler_procedure))
MYSQL_YYABORT;
......@@ -16888,13 +16877,8 @@ sp_tail:
sp_tail_is
sp_body
{
LEX *lex= Lex;
sp_head *sp= lex->sphead;
if (sp->check_unresolved_goto())
if (Lex->sp_body_finalize_procedure(thd))
MYSQL_YYABORT;
sp->set_stmt_end(thd);
lex->sql_command= SQLCOM_CREATE_PROCEDURE;
sp->restore_thd_mem_root(thd);
}
;
......
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