Commit 9718b976 authored by Sergey Petrunya's avatar Sergey Petrunya

SHOW EXPLAIN DELETE, post merge fixes

- Fix asserts, make sure that mysql_delete() operates on 
  thd->apc_target correctly* in all kinds of special cases 
  * - correctly means that one must switch it OFF iff it
  was switched ON.
- Added a few asserts to catch similar errors.
parent 99890baf
...@@ -70,6 +70,7 @@ void Apc_target::enable() ...@@ -70,6 +70,7 @@ void Apc_target::enable()
void Apc_target::disable() void Apc_target::disable()
{ {
bool process= FALSE; bool process= FALSE;
DBUG_ASSERT(enabled);
mysql_mutex_lock(LOCK_thd_data_ptr); mysql_mutex_lock(LOCK_thd_data_ptr);
if (!(--enabled)) if (!(--enabled))
process= TRUE; process= TRUE;
......
...@@ -807,7 +807,9 @@ bool do_command(THD *thd) ...@@ -807,7 +807,9 @@ bool do_command(THD *thd)
my_net_set_read_timeout(net, thd->variables.net_read_timeout); my_net_set_read_timeout(net, thd->variables.net_read_timeout);
DBUG_ASSERT(packet_length); DBUG_ASSERT(packet_length);
DBUG_ASSERT(!thd->apc_target.is_enabled());
return_value= dispatch_command(command, thd, packet+1, (uint) (packet_length-1)); return_value= dispatch_command(command, thd, packet+1, (uint) (packet_length-1));
DBUG_ASSERT(!thd->apc_target.is_enabled());
out: out:
DBUG_RETURN(return_value); DBUG_RETURN(return_value);
...@@ -1109,6 +1111,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1109,6 +1111,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
ulong length= (ulong)(packet_end - beginning_of_next_stmt); ulong length= (ulong)(packet_end - beginning_of_next_stmt);
log_slow_statement(thd); log_slow_statement(thd);
DBUG_ASSERT(!thd->apc_target.is_enabled());
/* Remove garbage at start of query */ /* Remove garbage at start of query */
while (length > 0 && my_isspace(thd->charset(), *beginning_of_next_stmt)) while (length > 0 && my_isspace(thd->charset(), *beginning_of_next_stmt))
......
...@@ -279,6 +279,7 @@ int mysql_update(THD *thd, ...@@ -279,6 +279,7 @@ int mysql_update(THD *thd,
Update_plan query_plan; Update_plan query_plan;
query_plan.index= MAX_KEY; query_plan.index= MAX_KEY;
query_plan.using_filesort= FALSE; query_plan.using_filesort= FALSE;
bool apc_target_enabled= false; // means was enabled *by code this function*
DBUG_ENTER("mysql_update"); DBUG_ENTER("mysql_update");
if (open_tables(thd, &table_list, &table_count, 0)) if (open_tables(thd, &table_list, &table_count, 0))
...@@ -497,6 +498,7 @@ int mysql_update(THD *thd, ...@@ -497,6 +498,7 @@ int mysql_update(THD *thd,
goto exit_without_my_ok; goto exit_without_my_ok;
thd->apc_target.enable(); thd->apc_target.enable();
apc_target_enabled= true;
DBUG_EXECUTE_IF("show_explain_probe_update_exec_start", DBUG_EXECUTE_IF("show_explain_probe_update_exec_start",
dbug_serve_apcs(thd, 1);); dbug_serve_apcs(thd, 1););
...@@ -923,6 +925,7 @@ int mysql_update(THD *thd, ...@@ -923,6 +925,7 @@ int mysql_update(THD *thd,
thd->transaction.stmt.modified_non_trans_table= TRUE; thd->transaction.stmt.modified_non_trans_table= TRUE;
thd->apc_target.disable(); //psergey-todo. thd->apc_target.disable(); //psergey-todo.
apc_target_enabled= false;
end_read_record(&info); end_read_record(&info);
delete select; delete select;
thd_proc_info(thd, "end"); thd_proc_info(thd, "end");
...@@ -996,6 +999,9 @@ int mysql_update(THD *thd, ...@@ -996,6 +999,9 @@ int mysql_update(THD *thd,
DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0); DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0);
err: err:
if (apc_target_enabled)
thd->apc_target.disable();
delete select; delete select;
free_underlaid_joins(thd, select_lex); free_underlaid_joins(thd, select_lex);
table->disable_keyread(); table->disable_keyread();
...@@ -1003,6 +1009,7 @@ int mysql_update(THD *thd, ...@@ -1003,6 +1009,7 @@ int mysql_update(THD *thd,
DBUG_RETURN(1); DBUG_RETURN(1);
exit_without_my_ok: exit_without_my_ok:
DBUG_ASSERT(!apc_target_enabled);
thd->lex->upd_del_plan= &query_plan; thd->lex->upd_del_plan= &query_plan;
select_send *result; select_send *result;
......
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