1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge branch '10.9' into 10.10

This commit is contained in:
Oleksandr Byelkin
2022-08-09 09:47:16 +02:00
585 changed files with 10999 additions and 4575 deletions

View File

@@ -2025,6 +2025,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 &&
@@ -3321,6 +3324,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())
@@ -3634,6 +3640,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())
@@ -3762,6 +3769,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;
@@ -11249,6 +11257,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);