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

Merge branch '10.7' into 10.8

This commit is contained in:
Oleksandr Byelkin
2022-02-04 14:50:25 +01:00
907 changed files with 20182 additions and 6211 deletions

View File

@@ -3260,6 +3260,14 @@ setup_subq_exit:
}
if (make_aggr_tables_info())
DBUG_RETURN(1);
/*
It could be that we've only done optimization stage 1 for
some of the derived tables, and never did stage 2.
Do it now, otherwise Explain data structure will not be complete.
*/
if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE))
DBUG_RETURN(1);
}
/*
Even with zero matching rows, subqueries in the HAVING clause may
@@ -10707,7 +10715,10 @@ bool JOIN::get_best_combination()
if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*
(top_join_tab_count + aggr_tables))))
DBUG_RETURN(TRUE);
if (inject_splitting_cond_for_all_tables_with_split_opt())
DBUG_RETURN(TRUE);
JOIN_TAB_RANGE *root_range;
if (!(root_range= new (thd->mem_root) JOIN_TAB_RANGE))
DBUG_RETURN(TRUE);
@@ -14757,8 +14768,6 @@ return_zero_rows(JOIN *join, select_result *result, List<TABLE_LIST> &tables,
DBUG_RETURN(0);
}
join->join_free();
if (send_row)
{
/*
@@ -14805,6 +14814,14 @@ return_zero_rows(JOIN *join, select_result *result, List<TABLE_LIST> &tables,
if (likely(!send_error))
result->send_eof(); // Should be safe
}
/*
JOIN::join_free() must be called after the virtual method
select::send_result_set_metadata() returned control since
implementation of this method could use data strutcures
that are released by the method JOIN::join_free().
*/
join->join_free();
DBUG_RETURN(0);
}
@@ -18536,7 +18553,7 @@ Field *create_tmp_field(TABLE *table, Item *item,
make_copy_field);
Field *result= item->create_tmp_field_ex(table->in_use->mem_root,
table, &src, &prm);
if (item->is_json_type() && make_json_valid_expr(table, result))
if (is_json_type(item) && make_json_valid_expr(table, result))
result= NULL;
*from_field= src.field();
@@ -18983,7 +19000,7 @@ bool Create_tmp_table::add_fields(THD *thd,
item->marker == MARKER_NULL_KEY ||
param->bit_fields_as_long,
param->force_copy_fields);
if (!new_field)
if (unlikely(!new_field))
{
if (unlikely(thd->is_fatal_error))
goto err; // Got OOM
@@ -19578,16 +19595,7 @@ bool Create_tmp_table::add_schema_fields(THD *thd, TABLE *table,
DBUG_RETURN(true); // EOM
}
field->init(table);
switch (def.def()) {
case DEFAULT_NONE:
field->flags|= NO_DEFAULT_VALUE_FLAG;
break;
case DEFAULT_TYPE_IMPLICIT:
break;
default:
DBUG_ASSERT(0);
break;
}
field->flags|= NO_DEFAULT_VALUE_FLAG;
add_field(table, field, fieldnr, param->force_not_null_cols);
}
@@ -21323,11 +21331,8 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
*/
if (shortcut_for_distinct && found_records != join->found_records)
DBUG_RETURN(NESTED_LOOP_NO_MORE_ROWS);
}
else
{
join->thd->get_stmt_da()->inc_current_row_for_warning();
join_tab->read_record.unlock_row(join_tab);
DBUG_RETURN(NESTED_LOOP_OK);
}
}
else
@@ -21337,9 +21342,11 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
with the beginning coinciding with the current partial join.
*/
join->join_examined_rows++;
join->thd->get_stmt_da()->inc_current_row_for_warning();
join_tab->read_record.unlock_row(join_tab);
}
join->thd->get_stmt_da()->inc_current_row_for_warning();
join_tab->read_record.unlock_row(join_tab);
DBUG_RETURN(NESTED_LOOP_OK);
}
@@ -23143,21 +23150,6 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,
cond->marker= MARKER_CHECK_ON_READ; // Checked when read
return (COND*) 0;
}
/*
If cond is an equality injected for split optimization then
a. when retain_ref_cond == false : cond is removed unconditionally
(cond that supports ref access is removed by the preceding code)
b. when retain_ref_cond == true : cond is removed if it does not
support ref access
*/
if (left_item->type() == Item::FIELD_ITEM &&
is_eq_cond_injected_for_split_opt((Item_func_eq *) cond) &&
(!retain_ref_cond ||
!test_if_ref(root_cond, (Item_field*) left_item,right_item)))
{
cond->marker= MARKER_CHECK_ON_READ;
return (COND*) 0;
}
}
cond->marker= MARKER_PROCESSED;
cond->set_join_tab_idx((uint8) join_tab_idx_arg);
@@ -29517,6 +29509,12 @@ AGGR_OP::end_send()
table->reginfo.lock_type= TL_UNLOCK;
bool in_first_read= true;
/*
Reset the counter before copying rows from internal temporary table to
INSERT table.
*/
join_tab->join->thd->get_stmt_da()->reset_current_row_for_warning(1);
while (rc == NESTED_LOOP_OK)
{
int error;