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

Merge 11.2 into 11.3

This commit is contained in:
Marko Mäkelä
2023-10-27 10:48:29 +03:00
511 changed files with 15169 additions and 29021 deletions

View File

@@ -913,8 +913,7 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
ORDER *group,
List<Window_spec> &win_specs,
List<Item_window_func> &win_funcs,
bool *hidden_group_fields,
uint *reserved)
bool *hidden_group_fields)
{
int res;
enum_parsing_place save_place;
@@ -929,13 +928,6 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
thd->lex->allow_sum_func.clear_bit(select->nest_level);
res= setup_conds(thd, tables, leaves, conds);
if (thd->lex->current_select->first_cond_optimization)
{
if (!res && *conds && ! thd->lex->current_select->merged_into)
(*reserved)= (*conds)->exists2in_reserved_items();
else
(*reserved)= 0;
}
/* it's not wrong to have non-aggregated columns in a WHERE */
select->set_non_agg_field_used(saved_non_agg_field_used);
@@ -1504,6 +1496,15 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
DBUG_ASSERT(select_lex->hidden_bit_fields == 0);
if (setup_wild(thd, tables_list, fields_list, &all_fields, select_lex, false))
DBUG_RETURN(-1);
if (thd->lex->current_select->first_cond_optimization)
{
if ( conds && ! thd->lex->current_select->merged_into)
select_lex->select_n_reserved= conds->exists2in_reserved_items();
else
select_lex->select_n_reserved= 0;
}
if (select_lex->setup_ref_array(thd, real_og_num))
DBUG_RETURN(-1);
@@ -1533,8 +1534,7 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
all_fields, &conds, order, group_list,
select_lex->window_specs,
select_lex->window_funcs,
&hidden_group_fields,
&select_lex->select_n_reserved))
&hidden_group_fields))
DBUG_RETURN(-1);
/*
@@ -2625,7 +2625,7 @@ JOIN::optimize_inner()
result->prepare_to_read_rows();
if (unlikely(make_join_statistics(this, select_lex->leaf_tables,
&keyuse)) ||
unlikely(thd->is_fatal_error))
unlikely(thd->is_error()))
{
DBUG_PRINT("error",("Error: make_join_statistics() failed"));
DBUG_RETURN(1);
@@ -2862,7 +2862,7 @@ int JOIN::optimize_stage2()
{
ref_item= substitute_for_best_equal_field(thd, tab, ref_item,
equals, map2table, true);
if (unlikely(thd->is_fatal_error))
if (unlikely(thd->is_error()))
DBUG_RETURN(1);
if (first_inner)
@@ -3095,7 +3095,7 @@ int JOIN::optimize_stage2()
else
group_list= 0;
}
else if (thd->is_fatal_error) // End of memory
else if (thd->is_error()) // End of memory
DBUG_RETURN(1);
}
simple_group= rollup.state == ROLLUP::STATE_NONE;
@@ -3728,7 +3728,7 @@ bool JOIN::make_aggr_tables_info()
curr_tab->all_fields= &tmp_all_fields1;
curr_tab->fields= &tmp_fields_list1;
DBUG_RETURN(thd->is_fatal_error);
DBUG_RETURN(thd->is_error());
}
}
}
@@ -4049,7 +4049,7 @@ bool JOIN::make_aggr_tables_info()
!join_tab ||
!join_tab-> is_using_agg_loose_index_scan()))
DBUG_RETURN(true);
if (unlikely(setup_sum_funcs(thd, sum_funcs) || thd->is_fatal_error))
if (unlikely(setup_sum_funcs(thd, sum_funcs) || thd->is_error()))
DBUG_RETURN(true);
}
if (group_list || order)
@@ -5303,7 +5303,7 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select,
(table_map) 0,
limit, 0, FALSE,
TRUE, /* remove_where_parts*/
FALSE)) ==
FALSE, TRUE)) ==
1))
{
/*
@@ -6067,7 +6067,12 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
goto error;
records= get_quick_record_count(join->thd, select, s->table,
&s->const_keys, join->row_limit);
if (join->thd->is_error())
{
/* get_quick_record_count generated an error */
delete select;
goto error;
}
/*
Range analyzer might have modified the condition. Put it the new
condition to where we got it from.
@@ -6602,7 +6607,7 @@ add_key_field(JOIN *join,
{
/*
Save info to be able check whether this predicate can be
considered as sargable for range analisis after reading const tables.
considered as sargable for range analysis after reading const tables.
We do not save info about equalities as update_const_equal_items
will take care of updating info on keys from sargable equalities.
*/
@@ -7108,11 +7113,14 @@ add_keyuse(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field,
1 - Out of memory.
*/
static LEX_CSTRING equal_str= { STRING_WITH_LEN("=") };
static bool
add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
{
Field *field=key_field->field;
TABLE *form= field->table;
THD *thd= form->in_use;
if (key_field->eq_func && !(key_field->optimize & KEY_OPTIMIZE_EXISTS))
{
@@ -7127,19 +7135,31 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
uint key_parts= form->actual_n_key_parts(keyinfo);
for (uint part=0 ; part < key_parts ; part++)
{
if (field->eq(form->key_info[key].key_part[part].field) &&
field->can_optimize_keypart_ref(key_field->cond, key_field->val))
{
if (add_keyuse(keyuse_array, key_field, key, part))
return TRUE;
}
if (field->eq(form->key_info[key].key_part[part].field))
{
Data_type_compatibility compat=
field->can_optimize_keypart_ref(key_field->cond, key_field->val);
if (compat == Data_type_compatibility::OK)
{
if (add_keyuse(keyuse_array, key_field, key, part))
return TRUE;
}
else if (thd->give_notes_for_unusable_keys())
{
field->raise_note_cannot_use_key_part(thd, key, part,
equal_str,
key_field->val,
compat);
}
}
}
}
if (field->hash_join_is_possible() &&
(key_field->optimize & KEY_OPTIMIZE_EQ) &&
key_field->val->used_tables())
{
if (!field->can_optimize_hash_join(key_field->cond, key_field->val))
if (field->can_optimize_hash_join(key_field->cond, key_field->val) !=
Data_type_compatibility::OK)
return false;
if (form->is_splittable())
form->add_splitting_info_for_key_field(key_field);
@@ -12546,6 +12566,8 @@ bool JOIN::get_best_combination()
table_map used_tables;
JOIN_TAB *j;
KEYUSE *keyuse;
JOIN_TAB *sjm_nest_end= NULL;
JOIN_TAB *sjm_nest_root= NULL;
DBUG_ENTER("get_best_combination");
/*
@@ -12600,20 +12622,17 @@ bool JOIN::get_best_combination()
DBUG_RETURN(TRUE);
if (inject_splitting_cond_for_all_tables_with_split_opt())
DBUG_RETURN(TRUE);
goto error;
JOIN_TAB_RANGE *root_range;
if (!(root_range= new (thd->mem_root) JOIN_TAB_RANGE))
DBUG_RETURN(TRUE);
goto error;
root_range->start= join_tab;
/* root_range->end will be set later */
join_tab_ranges.empty();
if (join_tab_ranges.push_back(root_range, thd->mem_root))
DBUG_RETURN(TRUE);
JOIN_TAB *sjm_nest_end= NULL;
JOIN_TAB *sjm_nest_root= NULL;
goto error;
for (j=join_tab, tablenr=0 ; tablenr < table_count ; tablenr++,j++)
{
@@ -12651,7 +12670,7 @@ bool JOIN::get_best_combination()
JOIN_TAB_RANGE *jt_range;
if (!(jt= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*sjm->tables)) ||
!(jt_range= new JOIN_TAB_RANGE))
DBUG_RETURN(TRUE);
goto error;
jt_range->start= jt;
jt_range->end= jt + sjm->tables;
join_tab_ranges.push_back(jt_range, thd->mem_root);
@@ -12743,7 +12762,7 @@ bool JOIN::get_best_combination()
{
if ((keyuse= best_positions[tablenr].key) &&
create_ref_for_key(this, j, keyuse, TRUE, used_tables))
DBUG_RETURN(TRUE); // Something went wrong
goto error; // Something went wrong
}
if (j->last_leaf_in_bush)
j= j->bush_root_tab;
@@ -12757,6 +12776,11 @@ bool JOIN::get_best_combination()
update_depend_map(this);
DBUG_RETURN(0);
error:
/* join_tab was not correctly setup. Don't use it */
join_tab= 0;
DBUG_RETURN(1);
}
/**
@@ -13076,7 +13100,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j,
keyinfo->key_part[i].length,
keyuse->val,
FALSE);
if (unlikely(thd->is_fatal_error))
if (unlikely(thd->is_error()))
DBUG_RETURN(TRUE);
tmp.copy(thd);
j->ref.const_ref_part_map |= key_part_map(1) << i ;
@@ -14029,7 +14053,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
OPTION_FOUND_ROWS ?
HA_POS_ERROR :
join->unit->lim.get_select_limit()),0,
FALSE, FALSE, FALSE) < 0)
FALSE, FALSE, FALSE, TRUE) < 0)
DBUG_RETURN(1); // Impossible WHERE
}
else
@@ -24409,7 +24433,8 @@ test_if_quick_select(JOIN_TAB *tab)
int res= tab->select->test_quick_select(tab->join->thd, tab->keys,
(table_map) 0, HA_POS_ERROR, 0,
FALSE, /*remove where parts*/FALSE,
FALSE);
FALSE,
/* no warnings */ TRUE);
if (tab->explain_plan && tab->explain_plan->range_checked_fer)
tab->explain_plan->range_checked_fer->collect_data(tab->select->quick);
@@ -26871,7 +26896,7 @@ create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort)
DBUG_ASSERT(tab->type == JT_REF || tab->type == JT_EQ_REF);
// Update ref value
if (unlikely(cp_buffer_from_ref(thd, table, &tab->ref) &&
thd->is_fatal_error))
thd->is_error()))
goto err; // out of memory
}
}
@@ -28751,7 +28776,7 @@ change_refs_to_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,
itr++;
itr.sublist(res_selected_fields, elements);
return thd->is_fatal_error;
return thd->is_error();
}
@@ -28929,7 +28954,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
value),
thd->mem_root);
}
if (unlikely(thd->is_fatal_error))
if (unlikely(thd->is_error()))
DBUG_RETURN(TRUE);
if (!cond->fixed())
{
@@ -29541,7 +29566,7 @@ int print_explain_message_line(select_result_sink *result,
else
item_list.push_back(item_null, mem_root);
if (unlikely(thd->is_fatal_error) || unlikely(result->send_data(item_list)))
if (unlikely(thd->is_error()) || unlikely(result->send_data(item_list)))
return 1;
return 0;
}