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

Function end_write_group

sql/sql_select.cc:26574–26657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26572*/
26573
26574enum_nested_loop_state
26575end_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);

Callers

nothing calls this directly

Calls 14

test_if_group_changedFunction · 0.85
copy_sum_funcsFunction · 0.85
unclear_tablesFunction · 0.85
copy_fieldsFunction · 0.85
copy_funcsFunction · 0.85
init_sum_functionsFunction · 0.85
update_sum_funcFunction · 0.85
end_groupMethod · 0.80
rollup_write_dataMethod · 0.80
check_killedMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected