| 12985 | */ |
| 12986 | |
| 12987 | static JOIN_TAB *next_breadth_first_tab(JOIN_TAB *first_top_tab, |
| 12988 | uint n_top_tabs_count, JOIN_TAB *tab) |
| 12989 | { |
| 12990 | /* |
| 12991 | tab->join == NULL means that we're performing JOIN::cleanup() |
| 12992 | after a raised error: on EOM, or on an attempt to create a temporary table |
| 12993 | with a column of a non allowed data type, such as SYS_REFCURSOR. |
| 12994 | */ |
| 12995 | DBUG_ASSERT(tab->join || current_thd->is_error()); |
| 12996 | if (tab->join) |
| 12997 | n_top_tabs_count += tab->join->aggr_tables; |
| 12998 | if (!tab->bush_root_tab) |
| 12999 | { |
| 13000 | /* We're at top level. Get the next top-level tab */ |
| 13001 | tab++; |
| 13002 | if (tab < first_top_tab + n_top_tabs_count) |
| 13003 | return tab; |
| 13004 | |
| 13005 | /* No more top-level tabs. Switch to enumerating SJM nest children */ |
| 13006 | tab= first_top_tab; |
| 13007 | } |
| 13008 | else |
| 13009 | { |
| 13010 | /* We're inside of an SJM nest */ |
| 13011 | if (!tab->last_leaf_in_bush) |
| 13012 | { |
| 13013 | /* There's one more table in the nest, return it. */ |
| 13014 | return ++tab; |
| 13015 | } |
| 13016 | else |
| 13017 | { |
| 13018 | /* |
| 13019 | There are no more tables in this nest. Get out of it and then we'll |
| 13020 | proceed to the next nest. |
| 13021 | */ |
| 13022 | tab= tab->bush_root_tab + 1; |
| 13023 | } |
| 13024 | } |
| 13025 | |
| 13026 | /* |
| 13027 | Ok, "tab" points to a top-level table, and we need to find the next SJM |
| 13028 | nest and enter it. |
| 13029 | */ |
| 13030 | for (; tab < first_top_tab + n_top_tabs_count; tab++) |
| 13031 | { |
| 13032 | if (tab->bush_children) |
| 13033 | return tab->bush_children->start; |
| 13034 | } |
| 13035 | return NULL; |
| 13036 | } |
| 13037 | |
| 13038 | |
| 13039 | /* |
no test coverage detected