| 26411 | */ |
| 26412 | |
| 26413 | static enum_nested_loop_state |
| 26414 | end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), |
| 26415 | bool end_of_records) |
| 26416 | { |
| 26417 | TABLE *const table= join_tab->table; |
| 26418 | ORDER *group; |
| 26419 | int error; |
| 26420 | DBUG_ENTER("end_update"); |
| 26421 | |
| 26422 | if (end_of_records) |
| 26423 | DBUG_RETURN(NESTED_LOOP_OK); |
| 26424 | |
| 26425 | join->found_records++; |
| 26426 | copy_fields(join_tab->tmp_table_param); // Groups are copied twice. |
| 26427 | /* Make a key of group index */ |
| 26428 | for (group=table->group ; group ; group=group->next) |
| 26429 | { |
| 26430 | Item *item= *group->item; |
| 26431 | if (group->fast_field_copier_setup != group->field) |
| 26432 | { |
| 26433 | DBUG_PRINT("info", ("new setup %p -> %p", |
| 26434 | group->fast_field_copier_setup, |
| 26435 | group->field)); |
| 26436 | group->fast_field_copier_setup= group->field; |
| 26437 | group->fast_field_copier_func= |
| 26438 | item->setup_fast_field_copier(group->field); |
| 26439 | } |
| 26440 | item->save_org_in_field(group->field, group->fast_field_copier_func); |
| 26441 | /* Store in the used key if the field was 0 */ |
| 26442 | if (item->maybe_null()) |
| 26443 | group->buff[-1]= (char) group->field->is_null(); |
| 26444 | } |
| 26445 | if (!table->file->ha_index_read_map(table->record[1], |
| 26446 | join_tab->tmp_table_param->group_buff, |
| 26447 | HA_WHOLE_KEY, |
| 26448 | HA_READ_KEY_EXACT)) |
| 26449 | { /* Update old record */ |
| 26450 | restore_record(table,record[1]); |
| 26451 | update_tmptable_sum_func(join->sum_funcs,table); |
| 26452 | if (unlikely((error= table->file->ha_update_tmp_row(table->record[1], |
| 26453 | table->record[0])))) |
| 26454 | { |
| 26455 | table->file->print_error(error,MYF(0)); /* purecov: inspected */ |
| 26456 | DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ |
| 26457 | } |
| 26458 | goto end; |
| 26459 | } |
| 26460 | |
| 26461 | init_tmptable_sum_functions(join->sum_funcs); |
| 26462 | if (unlikely(copy_funcs(join_tab->tmp_table_param->items_to_copy, |
| 26463 | join->thd))) |
| 26464 | DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ |
| 26465 | if (unlikely((error= table->file->ha_write_tmp_row(table->record[0])))) |
| 26466 | { |
| 26467 | if (create_internal_tmp_table_from_heap(join->thd, table, |
| 26468 | join_tab->tmp_table_param->start_recinfo, |
| 26469 | &join_tab->tmp_table_param->recinfo, |
| 26470 | error, 0, NULL)) |
nothing calls this directly
no test coverage detected