@@ -1918,14 +1918,12 @@ JOIN::optimize_inner()
19181918 (one_storage_engine && one_storage_engine->create_group_by))
19191919 {
19201920 /* Check if the storage engine can intercept the query */
1921- if ((storage_handler_for_group_by=
1922- (one_storage_engine->create_group_by)(thd, select_lex,
1923- &all_fields,
1924- tables_list,
1925- group_list, order,
1926- conds, having)))
1927- {
1928- uint handler_flags= storage_handler_for_group_by->flags();
1921+ group_by_handler *gbh= one_storage_engine->create_group_by(thd, &all_fields,
1922+ tables_list, group_list, order, conds, having);
1923+ if (gbh)
1924+ {
1925+ pushdown_query= new (thd->mem_root) Pushdown_query(select_lex, gbh);
1926+ uint handler_flags= gbh->flags();
19291927 int err;
19301928
19311929 /*
@@ -1962,13 +1960,13 @@ JOIN::optimize_inner()
19621960 DBUG_RETURN(1);
19631961
19641962 /* Give storage engine access to temporary table */
1965- if ((err= storage_handler_for_group_by ->init(exec_tmp_table1,
1963+ if ((err= gbh ->init(exec_tmp_table1,
19661964 having, order)))
19671965 {
1968- storage_handler_for_group_by ->print_error(err, MYF(0));
1966+ gbh ->print_error(err, MYF(0));
19691967 DBUG_RETURN(1);
19701968 }
1971- storage_handler_for_group_by ->store_data_in_temp_table= need_tmp;
1969+ pushdown_query ->store_data_in_temp_table= need_tmp;
19721970 /*
19731971 If no ORDER BY clause was specified explicitly, we should sort things
19741972 according to the group_by
@@ -2082,7 +2080,7 @@ int JOIN::init_execution()
20822080 thd->lex->set_limit_rows_examined();
20832081
20842082 /* Create a tmp table if distinct or if the sort is too complicated */
2085- if (need_tmp && ! storage_handler_for_group_by )
2083+ if (need_tmp && !pushdown_query )
20862084 {
20872085 DBUG_PRINT("info",("Creating tmp table"));
20882086 THD_STAGE_INFO(thd, stage_copying_to_tmp_table);
@@ -12053,8 +12051,8 @@ void JOIN::cleanup(bool full)
1205312051 }
1205412052 tmp_table_param.cleanup();
1205512053
12056- delete storage_handler_for_group_by ;
12057- storage_handler_for_group_by = 0;
12054+ delete pushdown_query ;
12055+ pushdown_query = 0;
1205812056
1205912057 if (!join_tab)
1206012058 {
@@ -17854,15 +17852,14 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
1785417852 join->fields= fields;
1785517853 join->do_select_call_count++;
1785617854
17857- if (join->storage_handler_for_group_by &&
17858- join->do_select_call_count == 1)
17855+ if (join->pushdown_query && join->do_select_call_count == 1)
1785917856 {
1786017857 /* Select fields are in the temporary table */
1786117858 join->fields= &join->tmp_fields_list1;
1786217859 /* Setup HAVING to work with fields in temporary table */
1786317860 join->set_items_ref_array(join->items1);
1786417861 /* The storage engine will take care of the group by query result */
17865- int res= join->storage_handler_for_group_by ->execute(join);
17862+ int res= join->pushdown_query ->execute(join);
1786617863 DBUG_RETURN(res);
1786717864 }
1786817865
@@ -24330,7 +24327,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table,
2433024327 explain->connection_type= Explain_node::EXPLAIN_NODE_DERIVED;
2433124328 output->add_node(explain);
2433224329 }
24333- else if (storage_handler_for_group_by )
24330+ else if (pushdown_query )
2433424331 {
2433524332 explain= new (output->mem_root) Explain_select(output->mem_root,
2433624333 thd->lex->analyze_stmt);
0 commit comments