MCPcopy Create free account
hub / github.com/MariaDB/server / exec_recursive

Method exec_recursive

sql/sql_union.cc:2625–2730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2623*/
2624
2625bool 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

Callers 2

fill_recursiveMethod · 0.80
mysql_derived_fillFunction · 0.80

Calls 15

instantiate_tmp_tableFunction · 0.85
is_unrestrictedMethod · 0.80
ha_delete_all_rowsMethod · 0.80
next_selectMethod · 0.80
set_as_stabilizedMethod · 0.80
is_createdMethod · 0.45
extraMethod · 0.45
execMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected