Bug #107559 Why Switch_ref_item_slice in TemptableAggregateIterator::Init
Submitted: 14 Jun 8:45 Modified: 14 Jun 12:23
Reporter: lou shuai (OCA) Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[14 Jun 8:45] lou shuai

I'd ask for an help to understand the code When i read the TemptableAggregateIterator::Init code:

TemptableAggregateIterator::Init {
    for {
         copy_fields(m_temp_table_param, thd())
         for (ORDER *group = table()->group; group; group = group->next) { 
         group_found = !table()->file->ha_index_read_map
         if (group_found) {
             restore_record(table(), record[1]);  
             update_tmptable_sum_func(m_join->sum_funcs, table());
         Switch_ref_item_slice slice_switch(m_join, m_ref_slice); 
         copy_funcs(m_temp_table_param, thd())
after the group by items are evaluated and saved into temp table's field,
Why change current_ref_item_slice to the temp table ?
I tried some example, but find copy_funcs rely on the base table's field instead of temp table's field result.
Can you give me an example?

How to repeat:
[14 Jun 8:53] lou shuai
the version is mysql8.0.25
[14 Jun 12:23] MySQL Verification Team
Hi Mr. shuai,

Thank you for your bug report.

However, it is not a bug.

We accept bug reports with test cases and bug reports based on code analysis. This is not a forum where we are explaining the code or the functionality of our software, hence, you are on the wrong site.

Regarding your question, this is an initialisation function which does many things, including initialising all columns in the temporary table.

Not a bug.