Commit a6131b85 authored by unknown's avatar unknown

Bug 8407, post review cleanup: use instr::get_cont_dest() to get the instruction
continuation instruction, for CONTINUE exception handlers.


sql/sp_head.cc:
  Post review cleanup: use instr::get_cont_dest() to get the instruction
  continuation instruction, for CONTINUE exception handlers.
sql/sp_head.h:
  Post review cleanup: use instr::get_cont_dest() to get the instruction
  continuation instruction, for CONTINUE exception handlers.
parent 4d6e16f2
...@@ -1078,7 +1078,7 @@ sp_head::execute(THD *thd) ...@@ -1078,7 +1078,7 @@ sp_head::execute(THD *thd)
case SP_HANDLER_CONTINUE: case SP_HANDLER_CONTINUE:
thd->restore_active_arena(&execute_arena, &backup_arena); thd->restore_active_arena(&execute_arena, &backup_arena);
thd->set_n_backup_active_arena(&execute_arena, &backup_arena); thd->set_n_backup_active_arena(&execute_arena, &backup_arena);
ctx->push_hstack(ip); ctx->push_hstack(i->get_cont_dest());
// Fall through // Fall through
default: default:
ip= hip; ip= hip;
...@@ -2394,7 +2394,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, ...@@ -2394,7 +2394,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
reinit_stmt_before_use(thd, m_lex); reinit_stmt_before_use(thd, m_lex);
if (open_tables) if (open_tables)
res= instr->exec_open_and_lock_tables(thd, m_lex->query_tables, nextp); res= instr->exec_open_and_lock_tables(thd, m_lex->query_tables);
if (!res) if (!res)
res= instr->exec_core(thd, nextp); res= instr->exec_core(thd, nextp);
...@@ -2443,8 +2443,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, ...@@ -2443,8 +2443,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
sp_instr class functions sp_instr class functions
*/ */
int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables, int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables)
uint *nextp)
{ {
int result; int result;
...@@ -2454,19 +2453,16 @@ int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables, ...@@ -2454,19 +2453,16 @@ int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables,
*/ */
if (check_table_access(thd, SELECT_ACL, tables, 0) if (check_table_access(thd, SELECT_ACL, tables, 0)
|| open_and_lock_tables(thd, tables)) || open_and_lock_tables(thd, tables))
{
get_cont_dest(nextp);
result= -1; result= -1;
}
else else
result= 0; result= 0;
return result; return result;
} }
void sp_instr::get_cont_dest(uint *nextp) uint sp_instr::get_cont_dest()
{ {
*nextp= m_ip+1; return (m_ip+1);
} }
...@@ -2654,9 +2650,9 @@ sp_instr_set_trigger_field::print(String *str) ...@@ -2654,9 +2650,9 @@ sp_instr_set_trigger_field::print(String *str)
sp_instr_opt_meta sp_instr_opt_meta
*/ */
void sp_instr_opt_meta::get_cont_dest(uint *nextp) uint sp_instr_opt_meta::get_cont_dest()
{ {
*nextp= m_cont_dest; return m_cont_dest;
} }
...@@ -2748,7 +2744,6 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp) ...@@ -2748,7 +2744,6 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp)
if (! it) if (! it)
{ {
res= -1; res= -1;
*nextp = m_cont_dest;
} }
else else
{ {
...@@ -3317,7 +3312,6 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp) ...@@ -3317,7 +3312,6 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
spcont->clear_handler(); spcont->clear_handler();
thd->spcont= spcont; thd->spcont= spcont;
} }
*nextp= m_cont_dest; /* For continue handler */
} }
else else
*nextp= m_ip+1; *nextp= m_ip+1;
......
...@@ -449,11 +449,13 @@ public: ...@@ -449,11 +449,13 @@ public:
thd Thread handle thd Thread handle
nextp OUT index of the next instruction to execute. (For most nextp OUT index of the next instruction to execute. (For most
instructions this will be the instruction following this instructions this will be the instruction following this
one). one). Note that this parameter is undefined in case of
errors, use get_cont_dest() to find the continuation
instruction for CONTINUE error handlers.
RETURN RETURN
0 on success, 0 on success,
other if some error occured other if some error occurred
*/ */
virtual int execute(THD *thd, uint *nextp) = 0; virtual int execute(THD *thd, uint *nextp) = 0;
...@@ -463,22 +465,17 @@ public: ...@@ -463,22 +465,17 @@ public:
Open and lock the tables used by this statement, as a pre-requisite Open and lock the tables used by this statement, as a pre-requisite
to execute the core logic of this instruction with to execute the core logic of this instruction with
<code>exec_core()</code>. <code>exec_core()</code>.
If this statement fails, the next instruction to execute is also returned.
This is useful when a user defined SQL continue handler needs to be
executed.
@param thd the current thread @param thd the current thread
@param tables the list of tables to open and lock @param tables the list of tables to open and lock
@param nextp the continuation instruction, returned to the caller if this
method fails.
@return zero on success, non zero on failure. @return zero on success, non zero on failure.
*/ */
int exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables, uint *nextp); int exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables);
/** /**
Get the continuation destination of this instruction. Get the continuation destination of this instruction.
@param nextp the continuation destination (output) @return the continuation destination
*/ */
virtual void get_cont_dest(uint *nextp); virtual uint get_cont_dest();
/* /*
Execute core function of instruction after all preparations (e.g. Execute core function of instruction after all preparations (e.g.
...@@ -744,7 +741,7 @@ public: ...@@ -744,7 +741,7 @@ public:
virtual void set_destination(uint old_dest, uint new_dest) virtual void set_destination(uint old_dest, uint new_dest)
= 0; = 0;
virtual void get_cont_dest(uint *nextp); virtual uint get_cont_dest();
protected: protected:
......
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