| 2623 | */ |
| 2624 | |
| 2625 | bool st_select_lex_unit::exec_recursive() |
| 2626 | { |
| 2627 | st_select_lex *lex_select_save= thd->lex->current_select; |
| 2628 | st_select_lex *start= with_element->first_recursive; |
| 2629 | TABLE *incr_table= with_element->rec_result->incr_table; |
| 2630 | st_select_lex *end= NULL; |
| 2631 | bool is_unrestricted= with_element->is_unrestricted(); |
| 2632 | List_iterator_fast<TABLE_LIST> li(with_element->rec_result->rec_table_refs); |
| 2633 | TMP_TABLE_PARAM *tmp_table_param= &with_element->rec_result->tmp_table_param; |
| 2634 | bool was_executed= executed; |
| 2635 | TABLE_LIST *rec_tbl; |
| 2636 | |
| 2637 | DBUG_ENTER("st_select_lex_unit::exec_recursive"); |
| 2638 | |
| 2639 | executed= 1; |
| 2640 | create_explain_query_if_not_exists(thd->lex, thd->mem_root); |
| 2641 | if (!was_executed) |
| 2642 | save_union_explain(thd->lex->explain); |
| 2643 | |
| 2644 | if (with_element->level == 0) |
| 2645 | { |
| 2646 | if (!incr_table->is_created() && |
| 2647 | instantiate_tmp_table(incr_table, |
| 2648 | tmp_table_param->keyinfo, |
| 2649 | tmp_table_param->start_recinfo, |
| 2650 | &tmp_table_param->recinfo, |
| 2651 | 0)) |
| 2652 | DBUG_RETURN(1); |
| 2653 | incr_table->file->extra(HA_EXTRA_WRITE_CACHE); |
| 2654 | incr_table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); |
| 2655 | start= first_select(); |
| 2656 | if (with_element->with_anchor) |
| 2657 | end= with_element->first_recursive; |
| 2658 | } |
| 2659 | else if (unlikely((saved_error= incr_table->file->ha_delete_all_rows()))) |
| 2660 | goto err; |
| 2661 | |
| 2662 | for (st_select_lex *sl= start ; sl != end; sl= sl->next_select()) |
| 2663 | { |
| 2664 | if (with_element->level) |
| 2665 | { |
| 2666 | for (TABLE_LIST *derived= with_element->derived_with_rec_ref.first; |
| 2667 | derived; |
| 2668 | derived= derived->next_with_rec_ref) |
| 2669 | { |
| 2670 | if (derived->is_materialized_derived()) |
| 2671 | { |
| 2672 | if (derived->table->is_created()) |
| 2673 | derived->table->file->ha_delete_all_rows(); |
| 2674 | derived->table->reginfo.join_tab->preread_init_done= false; |
| 2675 | } |
| 2676 | } |
| 2677 | } |
| 2678 | thd->lex->current_select= sl; |
| 2679 | set_limit(sl); |
| 2680 | if (sl->tvc) |
| 2681 | sl->tvc->exec(sl); |
| 2682 | else |
no test coverage detected