1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Merge branch '10.5' into 10.6

This commit is contained in:
Oleksandr Byelkin
2022-08-04 16:58:42 +02:00
28 changed files with 645 additions and 183 deletions

View File

@ -1998,6 +1998,9 @@ JOIN::optimize_inner()
DEBUG_SYNC(thd, "before_join_optimize");
THD_STAGE_INFO(thd, stage_optimizing);
#ifndef DBUG_OFF
dbug_join_tab_array_size= 0;
#endif
// rownum used somewhere in query, no limits and it is derived
if (unlikely(thd->lex->with_rownum &&
@ -3293,6 +3296,9 @@ setup_subq_exit:
{
if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB))))
DBUG_RETURN(1);
#ifndef DBUG_OFF
dbug_join_tab_array_size= 1;
#endif
need_tmp= 1;
}
if (make_aggr_tables_info())
@ -3606,6 +3612,7 @@ bool JOIN::make_aggr_tables_info()
{
aggr_tables++;
curr_tab= join_tab + exec_join_tab_cnt();
DBUG_ASSERT(curr_tab - join_tab < dbug_join_tab_array_size);
bzero((void*)curr_tab, sizeof(JOIN_TAB));
curr_tab->ref.key= -1;
if (only_const_tables())
@ -3734,6 +3741,7 @@ bool JOIN::make_aggr_tables_info()
curr_tab++;
aggr_tables++;
DBUG_ASSERT(curr_tab - join_tab < dbug_join_tab_array_size);
bzero((void*)curr_tab, sizeof(JOIN_TAB));
curr_tab->ref.key= -1;
@ -10887,6 +10895,21 @@ bool JOIN::get_best_combination()
fix_semijoin_strategies_for_picked_join_order(this);
top_join_tab_count= get_number_of_tables_at_top_level(this);
#ifndef DBUG_OFF
dbug_join_tab_array_size= top_join_tab_count + aggr_tables;
#endif
/*
NOTE: The above computation of aggr_tables can produce wrong result because some
of the variables it uses may change their values after we leave this function.
Known examples:
- Dangerous: using_outer_summary_function=false at this point. Added
DBUG_ASSERT below to demonstrate. Can this cause us to allocate less
space than we would need?
- Not dangerous: select_distinct can be true here but be assigned false
afterwards.
*/
aggr_tables= 2;
DBUG_ASSERT(!tmp_table_param.using_outer_summary_function);
if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*
(top_join_tab_count + aggr_tables))))
DBUG_RETURN(TRUE);