1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge branch '10.4' into 10.5

This commit is contained in:
Oleksandr Byelkin
2023-11-08 12:59:00 +01:00
396 changed files with 10324 additions and 5797 deletions

View File

@ -13737,8 +13737,18 @@ bool error_if_full_join(JOIN *join)
}
void JOIN_TAB::build_range_rowid_filter_if_needed()
/**
Build rowid filter.
@retval
0 ok
@retval
1 Error, transaction should be rolled back
*/
bool JOIN_TAB::build_range_rowid_filter_if_needed()
{
bool result= false;
if (rowid_filter && !is_rowid_filter_built)
{
/**
@ -13753,10 +13763,9 @@ void JOIN_TAB::build_range_rowid_filter_if_needed()
Rowid_filter_tracker *rowid_tracker= rowid_filter->get_tracker();
table->file->set_time_tracker(rowid_tracker->get_time_tracker());
rowid_tracker->start_tracking(join->thd);
if (!rowid_filter->build())
{
Rowid_filter::build_return_code build_rc= rowid_filter->build();
if (build_rc == Rowid_filter::SUCCESS)
is_rowid_filter_built= true;
}
else
{
delete rowid_filter;
@ -13764,7 +13773,9 @@ void JOIN_TAB::build_range_rowid_filter_if_needed()
}
rowid_tracker->stop_tracking(join->thd);
table->file->set_time_tracker(table_tracker);
result= (build_rc == Rowid_filter::FATAL_ERROR);
}
return result;
}
@ -21137,7 +21148,9 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
if (!join_tab->preread_init_done && join_tab->preread_init())
DBUG_RETURN(NESTED_LOOP_ERROR);
join_tab->build_range_rowid_filter_if_needed();
if (join_tab->build_range_rowid_filter_if_needed())
DBUG_RETURN(NESTED_LOOP_ERROR);
if (join_tab->rowid_filter && join_tab->rowid_filter->is_empty())
rc= NESTED_LOOP_NO_MORE_ROWS;
@ -22114,7 +22127,8 @@ int join_init_read_record(JOIN_TAB *tab)
if (tab->distinct && tab->remove_duplicates()) // Remove duplicates.
return 1;
tab->build_range_rowid_filter_if_needed();
if (tab->build_range_rowid_filter_if_needed())
return 1;
if (tab->filesort && tab->sort_table()) // Sort table.
return 1;
@ -23904,11 +23918,25 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
bool orig_cond_saved= false;
int best_key= -1;
bool changed_key= false;
THD *thd= tab->join->thd;
DBUG_ENTER("test_if_skip_sort_order");
Json_writer_object trace_wrapper(thd);
Json_writer_array trace_arr(thd, "test_if_skip_sort_order");
/* Check that we are always called with first non-const table */
DBUG_ASSERT(tab == tab->join->join_tab + tab->join->const_tables);
/* Sorting a single row can always be skipped */
if (tab->type == JT_EQ_REF ||
tab->type == JT_CONST ||
tab->type == JT_SYSTEM)
{
Json_writer_object trace_skip(thd);
trace_skip.add("skipped", "single row access method");
DBUG_RETURN(1);
}
/*
Keys disabled by ALTER TABLE ... DISABLE KEYS should have already
been taken into account.
@ -27188,6 +27216,7 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta,
// psergey-todo: data for filtering!
tracker= &eta->tracker;
jbuf_tracker= &eta->jbuf_tracker;
jbuf_unpack_tracker= &eta->jbuf_unpack_tracker;
/* Enable the table access time tracker only for "ANALYZE stmt" */
if (thd->lex->analyze_stmt)
@ -27818,7 +27847,8 @@ int JOIN::save_explain_data_intern(Explain_query *output,
Explain_table_access *eta= (new (output->mem_root)
Explain_table_access(output->mem_root));
Explain_table_access(output->mem_root,
thd->lex->analyze_stmt));
if (!eta)
DBUG_RETURN(1);