| 2162 | */ |
| 2163 | |
| 2164 | enum_nested_loop_state JOIN_CACHE::join_records(bool skip_last) |
| 2165 | { |
| 2166 | JOIN_TAB *tab; |
| 2167 | enum_nested_loop_state rc= NESTED_LOOP_OK; |
| 2168 | bool outer_join_first_inner= join_tab->is_first_inner_for_outer_join(); |
| 2169 | DBUG_ENTER("JOIN_CACHE::join_records"); |
| 2170 | |
| 2171 | if (outer_join_first_inner && !join_tab->first_unmatched) |
| 2172 | join_tab->not_null_compl= TRUE; |
| 2173 | |
| 2174 | if (!join_tab->first_unmatched) |
| 2175 | { |
| 2176 | DBUG_ASSERT(join_tab->cached_pfs_batch_update == join_tab->pfs_batch_update()); |
| 2177 | if (join_tab->cached_pfs_batch_update) |
| 2178 | join_tab->table->file->start_psi_batch_mode(); |
| 2179 | /* Find all records from join_tab that match records from join buffer */ |
| 2180 | rc= join_matching_records(skip_last); |
| 2181 | if (join_tab->cached_pfs_batch_update) |
| 2182 | join_tab->table->file->end_psi_batch_mode(); |
| 2183 | if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) |
| 2184 | goto finish; |
| 2185 | if (outer_join_first_inner) |
| 2186 | { |
| 2187 | if (next_cache && join_tab != join_tab->last_inner) |
| 2188 | { |
| 2189 | /* |
| 2190 | Ensure that all matches for outer records from join buffer are to be |
| 2191 | found. Now we ensure that all full records are found for records from |
| 2192 | join buffer. Generally this is an overkill. |
| 2193 | TODO: Ensure that only matches of the inner table records have to be |
| 2194 | found for the records from join buffer. |
| 2195 | */ |
| 2196 | rc= next_cache->join_records(skip_last); |
| 2197 | if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) |
| 2198 | goto finish; |
| 2199 | } |
| 2200 | join_tab->not_null_compl= FALSE; |
| 2201 | /* |
| 2202 | Prepare for generation of null complementing extensions. |
| 2203 | For all inner tables of the outer join operation for which |
| 2204 | regular matches have been just found the field 'first_unmatched' |
| 2205 | is set to point the first inner table. After all null |
| 2206 | complement rows are generated for this outer join this field |
| 2207 | is set back to NULL. |
| 2208 | */ |
| 2209 | for (tab= join_tab->first_inner; tab <= join_tab->last_inner; tab++) |
| 2210 | tab->first_unmatched= join_tab->first_inner; |
| 2211 | } |
| 2212 | } |
| 2213 | if (join_tab->first_unmatched) |
| 2214 | { |
| 2215 | if (is_key_access()) |
| 2216 | restore_last_record(); |
| 2217 | |
| 2218 | /* |
| 2219 | Generate all null complementing extensions for the records from |
| 2220 | join buffer that don't have any matching rows from the inner tables. |
| 2221 | */ |
no test coverage detected