| 15864 | */ |
| 15865 | |
| 15866 | static |
| 15867 | uint check_join_cache_usage(JOIN_TAB *tab, |
| 15868 | ulonglong options, |
| 15869 | uint no_jbuf_after, |
| 15870 | uint table_index, |
| 15871 | JOIN_TAB *prev_tab) |
| 15872 | { |
| 15873 | uint flags= 0; |
| 15874 | ha_rows rows= 0; |
| 15875 | uint bufsz= 4096; |
| 15876 | JOIN_CACHE *prev_cache=0; |
| 15877 | JOIN *join= tab->join; |
| 15878 | MEM_ROOT *root= join->thd->mem_root; |
| 15879 | uint cache_level= tab->used_join_cache_level; |
| 15880 | bool force_unlinked_cache= |
| 15881 | !(join->allowed_join_cache_types & JOIN_CACHE_INCREMENTAL_BIT); |
| 15882 | bool no_hashed_cache= |
| 15883 | !(join->allowed_join_cache_types & JOIN_CACHE_HASHED_BIT); |
| 15884 | bool hint_disables_bnl= !hint_table_state(join->thd, tab->tab_list->table, |
| 15885 | BNL_HINT_ENUM, true); |
| 15886 | bool no_bka_cache= !hint_table_state(join->thd, tab->tab_list->table, |
| 15887 | BKA_HINT_ENUM, join->allowed_join_cache_types & JOIN_CACHE_BKA_BIT); |
| 15888 | bool hint_forces_bnl= hint_table_state(join->thd, tab->tab_list->table, |
| 15889 | BNL_HINT_ENUM, false); |
| 15890 | bool hint_forces_bka= hint_table_state(join->thd, tab->tab_list->table, |
| 15891 | BKA_HINT_ENUM, false); |
| 15892 | join->return_tab= 0; |
| 15893 | |
| 15894 | if (tab->no_forced_join_cache || (hint_disables_bnl && no_bka_cache)) |
| 15895 | goto no_join_cache; |
| 15896 | |
| 15897 | // Hints BNL() and BKA() cannot be both specified for a single table |
| 15898 | DBUG_ASSERT(!(hint_forces_bnl && hint_forces_bka)); |
| 15899 | |
| 15900 | if (cache_level < 4 && hint_forces_bnl) |
| 15901 | { |
| 15902 | // BNL() hint present, raise join_cache_level to BNLH-incremental |
| 15903 | cache_level= 4; |
| 15904 | } |
| 15905 | else if (hint_forces_bka && !(cache_level >= 5 && cache_level <= 8)) |
| 15906 | { |
| 15907 | /* |
| 15908 | BKA() hint present. If join_cache_level is already set to BKA or BKAH, |
| 15909 | just ignore the hint. For other join_cache_levels raise the level to |
| 15910 | maximum possible (BKAH incremental) as there is no such granularity |
| 15911 | in hints as there is in join cache levels |
| 15912 | */ |
| 15913 | cache_level= 8; |
| 15914 | } |
| 15915 | |
| 15916 | /* |
| 15917 | Don't use join cache if @@join_cache_level==0 or this table is the first |
| 15918 | one join suborder (either at top level or inside a bush) |
| 15919 | */ |
| 15920 | if (cache_level == 0 || !prev_tab) |
| 15921 | { |
| 15922 | /* |
| 15923 | We could have cache_level==0 but join cache was forced for some previous |
no test coverage detected