| 385 | */ |
| 386 | |
| 387 | bool Sql_cmd_delete::delete_from_single_table(THD *thd) |
| 388 | { |
| 389 | int error; |
| 390 | int loc_error; |
| 391 | bool transactional_table; |
| 392 | bool const_cond; |
| 393 | bool safe_update; |
| 394 | bool const_cond_result; |
| 395 | bool return_error= 0; |
| 396 | bool binlogged= 0; |
| 397 | TABLE *table; |
| 398 | SQL_SELECT *select= 0; |
| 399 | SORT_INFO *file_sort= 0; |
| 400 | READ_RECORD info; |
| 401 | bool reverse= FALSE; |
| 402 | bool binlog_is_row; |
| 403 | killed_state killed_status= NOT_KILLED; |
| 404 | THD::enum_binlog_query_type query_type= THD::ROW_QUERY_TYPE; |
| 405 | bool will_batch= FALSE; |
| 406 | |
| 407 | bool has_triggers= false; |
| 408 | SELECT_LEX_UNIT *unit = &lex->unit; |
| 409 | SELECT_LEX *select_lex= unit->first_select(); |
| 410 | SELECT_LEX *returning= thd->lex->has_returning() ? thd->lex->returning() : 0; |
| 411 | TABLE_LIST *const table_list = select_lex->get_table_list(); |
| 412 | ulonglong options= select_lex->options; |
| 413 | ORDER *order= select_lex->order_list.first; |
| 414 | COND *conds= select_lex->join->conds; |
| 415 | ha_rows limit= unit->lim.get_select_limit(); |
| 416 | bool using_limit= limit != HA_POS_ERROR; |
| 417 | |
| 418 | Delete_plan query_plan(thd->mem_root); |
| 419 | Explain_delete *explain; |
| 420 | Unique * deltempfile= NULL; |
| 421 | bool delete_record= false; |
| 422 | bool delete_while_scanning= table_list->delete_while_scanning; |
| 423 | bool portion_of_time_through_update; |
| 424 | /* |
| 425 | TRUE if we are after the call to |
| 426 | select_lex->optimize_unflattened_subqueries(true) and before the |
| 427 | call to select_lex->optimize_unflattened_subqueries(false), to |
| 428 | ensure a call to |
| 429 | select_lex->optimize_unflattened_subqueries(false) happens which |
| 430 | avoid 2nd ps mem leaks when e.g. the first execution produces |
| 431 | empty result and the second execution produces a non-empty set |
| 432 | */ |
| 433 | bool optimize_subqueries= FALSE; |
| 434 | |
| 435 | DBUG_ENTER("Sql_cmd_delete::delete_single_table"); |
| 436 | |
| 437 | query_plan.index= MAX_KEY; |
| 438 | query_plan.using_filesort= FALSE; |
| 439 | |
| 440 | THD_STAGE_INFO(thd, stage_init_update); |
| 441 | |
| 442 | const bool delete_history= table_list->vers_conditions.delete_history; |
| 443 | DBUG_ASSERT(!(delete_history && table_list->period_conditions.is_set())); |
| 444 |
nothing calls this directly
no test coverage detected