| 24997 | */ |
| 24998 | |
| 24999 | static enum_nested_loop_state |
| 25000 | evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab) |
| 25001 | { |
| 25002 | /* |
| 25003 | The table join_tab is the first inner table of a outer join operation |
| 25004 | and no matches has been found for the current outer row. |
| 25005 | */ |
| 25006 | JOIN_TAB *last_inner_tab= join_tab->last_inner; |
| 25007 | /* Cache variables for faster loop */ |
| 25008 | COND *select_cond; |
| 25009 | for ( ; join_tab <= last_inner_tab ; join_tab++) |
| 25010 | { |
| 25011 | /* Change the values of guard predicate variables. */ |
| 25012 | join_tab->found= 1; |
| 25013 | join_tab->not_null_compl= 0; |
| 25014 | /* The outer row is complemented by nulls for each inner tables */ |
| 25015 | restore_record(join_tab->table,s->default_values); // Make empty record |
| 25016 | mark_as_null_row(join_tab->table); // For group by without error |
| 25017 | select_cond= join_tab->select_cond; |
| 25018 | /* Check all attached conditions for inner table rows. */ |
| 25019 | if (select_cond && !select_cond->val_bool()) |
| 25020 | return NESTED_LOOP_OK; |
| 25021 | } |
| 25022 | join_tab--; |
| 25023 | /* |
| 25024 | The row complemented by nulls might be the first row |
| 25025 | of embedding outer joins. |
| 25026 | If so, perform the same actions as in the code |
| 25027 | for the first regular outer join row above. |
| 25028 | */ |
| 25029 | for ( ; ; ) |
| 25030 | { |
| 25031 | JOIN_TAB *first_unmatched= join_tab->first_unmatched; |
| 25032 | if ((first_unmatched= first_unmatched->first_upper) && |
| 25033 | first_unmatched->last_inner != join_tab) |
| 25034 | first_unmatched= 0; |
| 25035 | join_tab->first_unmatched= first_unmatched; |
| 25036 | if (!first_unmatched) |
| 25037 | break; |
| 25038 | first_unmatched->found= 1; |
| 25039 | for (JOIN_TAB *tab= first_unmatched; tab <= join_tab; tab++) |
| 25040 | { |
| 25041 | if (tab->select_cond && !tab->select_cond->val_bool()) |
| 25042 | { |
| 25043 | join->return_tab= tab; |
| 25044 | return NESTED_LOOP_OK; |
| 25045 | } |
| 25046 | } |
| 25047 | } |
| 25048 | /* |
| 25049 | The row complemented by nulls satisfies all conditions |
| 25050 | attached to inner tables. |
| 25051 | */ |
| 25052 | if (join_tab->check_weed_out_table) |
| 25053 | { |
| 25054 | int res= join_tab->check_weed_out_table->sj_weedout_check_row(join->thd); |
| 25055 | if (res == -1) |
| 25056 | return NESTED_LOOP_ERROR; |
no test coverage detected