| 402 | */ |
| 403 | |
| 404 | bool JOIN::check_for_splittable_materialized() |
| 405 | { |
| 406 | ORDER *partition_list= 0; |
| 407 | st_select_lex_unit *unit= select_lex->master_unit(); |
| 408 | TABLE_LIST *derived= unit->derived; |
| 409 | |
| 410 | hint_state hint; |
| 411 | if (!is_split_materialized_allowed(thd, derived, &hint) || // !(1) |
| 412 | !derived->is_materialized_derived() || // !(2) |
| 413 | (unit->first_select()->next_select()) || // !(3) |
| 414 | (derived->prohibit_cond_pushdown) || // !(4) |
| 415 | (derived->is_recursive_with_table()) || // !(5) |
| 416 | (table_count == 0 || const_tables == top_join_tab_count) || // !(6) |
| 417 | rollup.state != ROLLUP::STATE_NONE) // (10) |
| 418 | return false; |
| 419 | if (group_list) // (7.1) |
| 420 | { |
| 421 | if (!select_lex->have_window_funcs()) |
| 422 | partition_list= group_list; |
| 423 | } |
| 424 | else if (select_lex->have_window_funcs() && |
| 425 | select_lex->window_specs.elements == 1) // (7.2) |
| 426 | { |
| 427 | partition_list= |
| 428 | select_lex->window_specs.head()->partition_list->first; |
| 429 | } |
| 430 | if (!partition_list) |
| 431 | return false; |
| 432 | |
| 433 | if (select_lex->order_list.elements > 0 && !unit->lim.is_unlimited()) //!(11) |
| 434 | return false; |
| 435 | |
| 436 | Json_writer_object trace_wrapper(thd); |
| 437 | Json_writer_object trace_split(thd, "check_split_materialized"); |
| 438 | |
| 439 | ORDER *ord; |
| 440 | Dynamic_array<SplM_field_ext_info> candidates(PSI_INSTRUMENT_MEM); |
| 441 | |
| 442 | /* |
| 443 | Select from partition_list all candidates for splitting. |
| 444 | A candidate must be |
| 445 | - field item or refer to such (8.1) |
| 446 | - item mentioned in the select list (8.2) |
| 447 | Put info about such candidates into the array candidates |
| 448 | */ |
| 449 | table_map usable_tables= 0; // tables that contains the candidate |
| 450 | for (ord= partition_list; ord; ord= ord->next) |
| 451 | { |
| 452 | Item *ord_item= *ord->item; |
| 453 | if (ord_item->real_item()->type() != Item::FIELD_ITEM) // !(8.1) |
| 454 | continue; |
| 455 | |
| 456 | Field *ord_field= ((Item_field *) (ord_item->real_item()))->field; |
| 457 | |
| 458 | /* Ignore fields from of inner tables of outer joins */ |
| 459 | TABLE_LIST *tbl= ord_field->table->pos_in_table_list; |
| 460 | if (tbl->is_inner_table_of_outer_join()) |
| 461 | continue; |
nothing calls this directly
no test coverage detected