| 26572 | */ |
| 26573 | |
| 26574 | enum_nested_loop_state |
| 26575 | end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), |
| 26576 | bool end_of_records) |
| 26577 | { |
| 26578 | TABLE *table= join_tab->table; |
| 26579 | int idx= -1; |
| 26580 | DBUG_ENTER("end_write_group"); |
| 26581 | |
| 26582 | join->accepted_rows++; |
| 26583 | if (!join->first_record || end_of_records || |
| 26584 | (idx=test_if_group_changed(join->group_fields)) >= 0) |
| 26585 | { |
| 26586 | if (join->first_record || (end_of_records && !join->group)) |
| 26587 | { |
| 26588 | table_map cleared_tables= (table_map) 0; |
| 26589 | if (join->procedure) |
| 26590 | join->procedure->end_group(); |
| 26591 | int send_group_parts= join->send_group_parts; |
| 26592 | if (idx < send_group_parts) |
| 26593 | { |
| 26594 | if (!join->first_record) |
| 26595 | { |
| 26596 | /* No matching rows for group function */ |
| 26597 | join->clear(&cleared_tables); |
| 26598 | } |
| 26599 | copy_sum_funcs(join->sum_funcs, |
| 26600 | join->sum_funcs_end[send_group_parts]); |
| 26601 | if (!join_tab->having || join_tab->having->val_bool()) |
| 26602 | { |
| 26603 | int error= table->file->ha_write_tmp_row(table->record[0]); |
| 26604 | if (unlikely(error) && |
| 26605 | create_internal_tmp_table_from_heap(join->thd, table, |
| 26606 | join_tab->tmp_table_param->start_recinfo, |
| 26607 | &join_tab->tmp_table_param->recinfo, |
| 26608 | error, 0, NULL)) |
| 26609 | DBUG_RETURN(NESTED_LOOP_ERROR); |
| 26610 | } |
| 26611 | if (unlikely(join->rollup.state != ROLLUP::STATE_NONE)) |
| 26612 | { |
| 26613 | if (unlikely(join->rollup_write_data((uint) (idx+1), |
| 26614 | join_tab->tmp_table_param, |
| 26615 | table))) |
| 26616 | { |
| 26617 | DBUG_RETURN(NESTED_LOOP_ERROR); |
| 26618 | } |
| 26619 | } |
| 26620 | if (cleared_tables) |
| 26621 | unclear_tables(join, &cleared_tables); |
| 26622 | if (end_of_records) |
| 26623 | goto end; |
| 26624 | } |
| 26625 | } |
| 26626 | else |
| 26627 | { |
| 26628 | if (end_of_records) |
| 26629 | goto end; |
| 26630 | join->first_record=1; |
| 26631 | (void) test_if_group_changed(join->group_fields); |
nothing calls this directly
no test coverage detected