MCPcopy Create free account
hub / github.com/MariaDB/server / end_unique_update

Function end_unique_update

sql/sql_select.cc:26496–26558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26494*/
26495
26496static enum_nested_loop_state
26497end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
26498 bool end_of_records)
26499{
26500 TABLE *table= join_tab->table;
26501 int error;
26502 DBUG_ENTER("end_unique_update");
26503
26504 if (end_of_records)
26505 DBUG_RETURN(NESTED_LOOP_OK);
26506
26507 init_tmptable_sum_functions(join->sum_funcs);
26508 copy_fields(join_tab->tmp_table_param); // Groups are copied twice.
26509 if (copy_funcs(join_tab->tmp_table_param->items_to_copy, join->thd))
26510 DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
26511
26512 join->accepted_rows++;
26513 if (likely(!(error= table->file->ha_write_tmp_row(table->record[0]))))
26514 join_tab->send_records++; // New group
26515 else
26516 {
26517 if (unlikely((int) table->file->get_dup_key(error) < 0))
26518 {
26519 table->file->print_error(error,MYF(0)); /* purecov: inspected */
26520 DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
26521 }
26522 /* Prepare table for random positioning */
26523 bool rnd_inited= (table->file->inited == handler::RND);
26524 if (!rnd_inited &&
26525 ((error= table->file->ha_index_end()) ||
26526 (error= table->file->ha_rnd_init(0))))
26527 {
26528 table->file->print_error(error, MYF(0));
26529 DBUG_RETURN(NESTED_LOOP_ERROR);
26530 }
26531 if (unlikely(table->file->ha_rnd_pos(table->record[1],table->file->dup_ref)))
26532 {
26533 table->file->print_error(error,MYF(0)); /* purecov: inspected */
26534 DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
26535 }
26536 restore_record(table,record[1]);
26537 update_tmptable_sum_func(join->sum_funcs,table);
26538 if (unlikely((error= table->file->ha_update_tmp_row(table->record[1],
26539 table->record[0]))))
26540 {
26541 table->file->print_error(error,MYF(0)); /* purecov: inspected */
26542 DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
26543 }
26544 if (!rnd_inited &&
26545 ((error= table->file->ha_rnd_end()) ||
26546 (error= table->file->ha_index_init(0, 0))))
26547 {
26548 table->file->print_error(error, MYF(0));
26549 DBUG_RETURN(NESTED_LOOP_ERROR);
26550 }
26551 }
26552 if (unlikely(join->thd->check_killed()))
26553 {

Callers

nothing calls this directly

Calls 12

copy_fieldsFunction · 0.85
copy_funcsFunction · 0.85
update_tmptable_sum_funcFunction · 0.85
get_dup_keyMethod · 0.80
ha_index_endMethod · 0.80
ha_rnd_initMethod · 0.80
ha_rnd_posMethod · 0.80
ha_index_initMethod · 0.80
check_killedMethod · 0.80
print_errorMethod · 0.45
ha_rnd_endMethod · 0.45

Tested by

no test coverage detected