mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Refactoring for MDEV-10580 sql_mode=ORACLE: FOR loop statement
Adding methods: - LEX::sp_while_loop_expression() - LEX::sp_while_loop_finalize() to reuse code between sql_yacc.yy and sql_yacc_ora.yy. FOR loop will also reuse these methods.
This commit is contained in:
parent
28f2859136
commit
8ec4cf1f01
4 changed files with 33 additions and 36 deletions
|
@ -5618,6 +5618,31 @@ void LEX::sp_pop_loop_empty_label(THD *thd)
|
|||
}
|
||||
|
||||
|
||||
bool LEX::sp_while_loop_expression(THD *thd, Item *expr)
|
||||
{
|
||||
sp_instr_jump_if_not *i= new (thd->mem_root)
|
||||
sp_instr_jump_if_not(sphead->instructions(), spcont, expr, this);
|
||||
return i == NULL ||
|
||||
/* Jumping forward */
|
||||
sphead->push_backpatch(thd, i, spcont->last_label()) ||
|
||||
sphead->new_cont_backpatch(i) ||
|
||||
sphead->add_instr(i);
|
||||
}
|
||||
|
||||
|
||||
bool LEX::sp_while_loop_finalize(THD *thd)
|
||||
{
|
||||
sp_label *lab= spcont->last_label(); /* Jumping back */
|
||||
sp_instr_jump *i= new (thd->mem_root)
|
||||
sp_instr_jump(sphead->instructions(), spcont, lab->ip);
|
||||
if (i == NULL ||
|
||||
sphead->add_instr(i))
|
||||
return true;
|
||||
sphead->do_cont_backpatch();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MYSQL_SERVER
|
||||
uint binlog_unsafe_map[256];
|
||||
|
||||
|
|
|
@ -3164,6 +3164,8 @@ public:
|
|||
bool sp_push_loop_empty_label(THD *thd);
|
||||
bool sp_pop_loop_label(THD *thd, const LEX_STRING label_name);
|
||||
void sp_pop_loop_empty_label(THD *thd);
|
||||
bool sp_while_loop_expression(THD *thd, Item *expr);
|
||||
bool sp_while_loop_finalize(THD *thd);
|
||||
|
||||
// Check if "KEY IF NOT EXISTS name" used outside of ALTER context
|
||||
bool check_add_key(DDL_options_st ddl)
|
||||
|
|
|
@ -3944,30 +3944,15 @@ while_body:
|
|||
expr DO_SYM
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
sp_head *sp= lex->sphead;
|
||||
uint ip= sp->instructions();
|
||||
sp_instr_jump_if_not *i= new (thd->mem_root)
|
||||
sp_instr_jump_if_not(ip, lex->spcont, $1, lex);
|
||||
if (i == NULL ||
|
||||
/* Jumping forward */
|
||||
sp->push_backpatch(thd, i, lex->spcont->last_label()) ||
|
||||
sp->new_cont_backpatch(i) ||
|
||||
sp->add_instr(i))
|
||||
if (lex->sp_while_loop_expression(thd, $1))
|
||||
MYSQL_YYABORT;
|
||||
if (sp->restore_lex(thd))
|
||||
if (lex->sphead->restore_lex(thd))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
sp_proc_stmts1 END WHILE_SYM
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
uint ip= lex->sphead->instructions();
|
||||
sp_label *lab= lex->spcont->last_label(); /* Jumping back */
|
||||
sp_instr_jump *i= new (thd->mem_root)
|
||||
sp_instr_jump(ip, lex->spcont, lab->ip);
|
||||
if (i == NULL ||
|
||||
lex->sphead->add_instr(i))
|
||||
if (Lex->sp_while_loop_finalize(thd))
|
||||
MYSQL_YYABORT;
|
||||
lex->sphead->do_cont_backpatch();
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
@ -3488,30 +3488,15 @@ while_body:
|
|||
expr LOOP_SYM
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
sp_head *sp= lex->sphead;
|
||||
uint ip= sp->instructions();
|
||||
sp_instr_jump_if_not *i= new (thd->mem_root)
|
||||
sp_instr_jump_if_not(ip, lex->spcont, $1, lex);
|
||||
if (i == NULL ||
|
||||
/* Jumping forward */
|
||||
sp->push_backpatch(thd, i, lex->spcont->last_label()) ||
|
||||
sp->new_cont_backpatch(i) ||
|
||||
sp->add_instr(i))
|
||||
if (lex->sp_while_loop_expression(thd, $1))
|
||||
MYSQL_YYABORT;
|
||||
if (sp->restore_lex(thd))
|
||||
if (lex->sphead->restore_lex(thd))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
sp_proc_stmts1 END LOOP_SYM
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
uint ip= lex->sphead->instructions();
|
||||
sp_label *lab= lex->spcont->last_label(); /* Jumping back */
|
||||
sp_instr_jump *i= new (thd->mem_root)
|
||||
sp_instr_jump(ip, lex->spcont, lab->ip);
|
||||
if (i == NULL ||
|
||||
lex->sphead->add_instr(i))
|
||||
if (Lex->sp_while_loop_finalize(thd))
|
||||
MYSQL_YYABORT;
|
||||
lex->sphead->do_cont_backpatch();
|
||||
}
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in a new issue