| 26179 | */ |
| 26180 | |
| 26181 | enum_nested_loop_state |
| 26182 | end_send_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) |
| 26183 | { |
| 26184 | int idx= -1; |
| 26185 | enum_nested_loop_state ok_code= NESTED_LOOP_OK; |
| 26186 | /* |
| 26187 | join_tab can be 0 in the case all tables are const tables and we did not |
| 26188 | need a temporary table to store the result. |
| 26189 | In this case we use the original given fields, which is stored in |
| 26190 | join->fields. |
| 26191 | */ |
| 26192 | List<Item> *fields= join_tab ? (join_tab-1)->fields : join->fields; |
| 26193 | DBUG_ENTER("end_send_group"); |
| 26194 | |
| 26195 | if (!join->items3.is_null() && join->current_ref_ptrs != join->items3) |
| 26196 | join->set_items_ref_array(join->items3); |
| 26197 | |
| 26198 | if (!join->first_record || end_of_records || |
| 26199 | (idx=test_if_group_changed(join->group_fields)) >= 0) |
| 26200 | { |
| 26201 | |
| 26202 | if (!join->group_sent && |
| 26203 | (join->first_record || |
| 26204 | (end_of_records && !join->group && !join->group_optimized_away))) |
| 26205 | { |
| 26206 | table_map cleared_tables= (table_map) 0; |
| 26207 | if (join->procedure) |
| 26208 | join->procedure->end_group(); |
| 26209 | /* Test if there was a group change. */ |
| 26210 | if (idx < (int) join->send_group_parts) |
| 26211 | { |
| 26212 | int error=0; |
| 26213 | if (join->procedure) |
| 26214 | { |
| 26215 | if (join->having && !join->having->val_bool()) |
| 26216 | error= -1; // Didn't satisfy having |
| 26217 | else |
| 26218 | { |
| 26219 | if (join->do_send_rows) |
| 26220 | error=join->procedure->send_row(*fields) ? 1 : 0; |
| 26221 | join->send_records++; |
| 26222 | } |
| 26223 | if (end_of_records && join->procedure->end_of_records()) |
| 26224 | error= 1; // Fatal error |
| 26225 | } |
| 26226 | else |
| 26227 | { |
| 26228 | /* Reset all sum functions on group change. */ |
| 26229 | if (!join->first_record) |
| 26230 | { |
| 26231 | /* No matching rows for group function */ |
| 26232 | |
| 26233 | List_iterator_fast<Item> it(*fields); |
| 26234 | Item *item; |
| 26235 | join->no_rows_in_result_called= 1; |
| 26236 | |
| 26237 | join->clear(&cleared_tables); |
| 26238 | while ((item= it++)) |
nothing calls this directly
no test coverage detected