| 16180 | */ |
| 16181 | |
| 16182 | void check_join_cache_usage_for_tables(JOIN *join, ulonglong options, |
| 16183 | uint no_jbuf_after) |
| 16184 | { |
| 16185 | JOIN_TAB *tab; |
| 16186 | JOIN_TAB *prev_tab; |
| 16187 | |
| 16188 | for (tab= first_linear_tab(join, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); |
| 16189 | tab; |
| 16190 | tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS)) |
| 16191 | { |
| 16192 | tab->used_join_cache_level= join->max_allowed_join_cache_level; |
| 16193 | } |
| 16194 | |
| 16195 | uint idx= join->const_tables; |
| 16196 | for (tab= first_linear_tab(join, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); |
| 16197 | tab; |
| 16198 | tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS)) |
| 16199 | { |
| 16200 | restart: |
| 16201 | tab->icp_other_tables_ok= TRUE; |
| 16202 | tab->idx_cond_fact_out= TRUE; |
| 16203 | |
| 16204 | /* |
| 16205 | Check if we have a preceding join_tab, as something that will feed us |
| 16206 | records that we could buffer. We don't have it, if |
| 16207 | - this is the first non-const table in the join order, |
| 16208 | - this is the first table inside an SJM nest. |
| 16209 | */ |
| 16210 | prev_tab= tab - 1; |
| 16211 | if (tab == join->join_tab + join->const_tables || |
| 16212 | (tab->bush_root_tab && tab->bush_root_tab->bush_children->start == tab)) |
| 16213 | prev_tab= NULL; |
| 16214 | |
| 16215 | switch (tab->type) { |
| 16216 | case JT_SYSTEM: |
| 16217 | case JT_CONST: |
| 16218 | case JT_EQ_REF: |
| 16219 | case JT_REF: |
| 16220 | case JT_REF_OR_NULL: |
| 16221 | case JT_NEXT: |
| 16222 | case JT_ALL: |
| 16223 | case JT_RANGE: |
| 16224 | tab->used_join_cache_level= check_join_cache_usage(tab, options, |
| 16225 | no_jbuf_after, |
| 16226 | idx, |
| 16227 | prev_tab); |
| 16228 | tab->use_join_cache= MY_TEST(tab->used_join_cache_level); |
| 16229 | /* |
| 16230 | psergey-merge: todo: raise the question that this is really stupid that |
| 16231 | we can first allocate a join buffer, then decide not to use it and free |
| 16232 | it. |
| 16233 | */ |
| 16234 | if (join->return_tab) |
| 16235 | { |
| 16236 | tab= join->return_tab; |
| 16237 | goto restart; |
| 16238 | } |
| 16239 | break; |
no test coverage detected