Commit e399949b authored by Alexander Barkov's avatar Alexander Barkov

Adding Lex_spblock_st::init() and Lex_spblock_st::join().

parent 365e0b31
......@@ -3092,7 +3092,6 @@ struct LEX: public Query_tables_list
// Unlabeled blocks get an empty label
sp_block_init(thd, empty_lex_str);
}
public:
bool sp_block_finalize(THD *thd, const Lex_spblock_st spblock)
{
class sp_label *tmp;
......@@ -3100,6 +3099,23 @@ struct LEX: public Query_tables_list
}
bool sp_block_finalize(THD *thd, const Lex_spblock_st spblock,
const LEX_STRING end_label);
bool sp_declarations_join(Lex_spblock_st *res,
const Lex_spblock_st b1,
const Lex_spblock_st b2) const
{
if ((b2.vars || b2.conds) && (b1.curs || b1.hndlrs))
{
my_error(ER_SP_VARCOND_AFTER_CURSHNDLR, MYF(0));
return true;
}
if (b2.curs && b1.hndlrs)
{
my_error(ER_SP_CURSOR_AFTER_HANDLER, MYF(0));
return true;
}
res->join(b1, b2);
return false;
}
// Check if "KEY IF NOT EXISTS name" used outside of ALTER context
bool check_add_key(DDL_options_st ddl)
{
......
......@@ -2976,7 +2976,7 @@ sp_proc_stmts1:
sp_decls:
/* Empty */
{
$$.vars= $$.conds= $$.hndlrs= $$.curs= 0;
$$.init();
}
| sp_decls sp_decl ';'
{
......@@ -2984,14 +2984,8 @@ sp_decls:
because letting the grammar rules reflect it caused tricky
shift/reduce conflicts with the wrong result. (And we get
better error handling this way.) */
if (($2.vars || $2.conds) && ($1.curs || $1.hndlrs))
my_yyabort_error((ER_SP_VARCOND_AFTER_CURSHNDLR, MYF(0)));
if ($2.curs && $1.hndlrs)
my_yyabort_error((ER_SP_CURSOR_AFTER_HANDLER, MYF(0)));
$$.vars= $1.vars + $2.vars;
$$.conds= $1.conds + $2.conds;
$$.hndlrs= $1.hndlrs + $2.hndlrs;
$$.curs= $1.curs + $2.curs;
if (Lex->sp_declarations_join(&$$, $1, $2))
MYSQL_YYABORT;
}
;
......
......@@ -2362,7 +2362,7 @@ sp_proc_stmts1:
sp_decls:
/* Empty */
{
$$.vars= $$.conds= $$.hndlrs= $$.curs= 0;
$$.init();
}
| sp_decls sp_decl ';'
{
......@@ -2370,14 +2370,8 @@ sp_decls:
because letting the grammar rules reflect it caused tricky
shift/reduce conflicts with the wrong result. (And we get
better error handling this way.) */
if (($2.vars || $2.conds) && ($1.curs || $1.hndlrs))
my_yyabort_error((ER_SP_VARCOND_AFTER_CURSHNDLR, MYF(0)));
if ($2.curs && $1.hndlrs)
my_yyabort_error((ER_SP_CURSOR_AFTER_HANDLER, MYF(0)));
$$.vars= $1.vars + $2.vars;
$$.conds= $1.conds + $2.conds;
$$.hndlrs= $1.hndlrs + $2.hndlrs;
$$.curs= $1.curs + $2.curs;
if (Lex->sp_declarations_join(&$$, $1, $2))
MYSQL_YYABORT;
}
;
......
......@@ -635,6 +635,17 @@ struct Lex_spblock_st
int conds;
int hndlrs;
int curs;
void init()
{
vars= conds= hndlrs= curs= 0;
}
void join(const Lex_spblock_st &b1, const Lex_spblock_st &b2)
{
vars= b1.vars + b2.vars;
conds= b1.conds + b2.conds;
hndlrs= b1.hndlrs + b2.hndlrs;
curs= b1.curs + b2.curs;
}
};
......
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