1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge 10.2 into 10.3

This commit is contained in:
Marko Mäkelä
2018-05-17 08:42:53 +03:00
92 changed files with 2959 additions and 375 deletions

View File

@ -1083,7 +1083,9 @@ JOIN::prepare(TABLE_LIST *tables_init,
select_lex != select_lex->master_unit()->global_parameters())
real_og_num+= select_lex->order_list.elements;
if (setup_wild(thd, tables_list, fields_list, &all_fields, wild_num))
DBUG_ASSERT(select_lex->hidden_bit_fields == 0);
if (setup_wild(thd, tables_list, fields_list, &all_fields, wild_num,
&select_lex->hidden_bit_fields))
DBUG_RETURN(-1);
if (select_lex->setup_ref_array(thd, real_og_num))
DBUG_RETURN(-1);
@ -2529,7 +2531,7 @@ int JOIN::optimize_stage2()
ordered_index_usage= ordered_index_order_by;
}
}
}
}
if (having)
having_is_correlated= MY_TEST(having->used_tables() & OUTER_REF_TABLE_BIT);
@ -2671,6 +2673,25 @@ bool JOIN::add_having_as_table_cond(JOIN_TAB *tab)
}
bool JOIN::add_fields_for_current_rowid(JOIN_TAB *cur, List<Item> *table_fields)
{
/*
this will not walk into semi-join materialization nests but this is ok
because we will never need to save current rowids for those.
*/
for (JOIN_TAB *tab=join_tab; tab < cur; tab++)
{
if (!tab->keep_current_rowid)
continue;
Item *item= new (thd->mem_root) Item_temptable_rowid(tab->table);
item->fix_fields(thd, 0);
table_fields->push_back(item, thd->mem_root);
cur->tmp_table_param->func_count++;
}
return 0;
}
/**
Set info for aggregation tables
@ -2977,13 +2998,13 @@ bool JOIN::make_aggr_tables_info()
(select_distinct && tmp_table_param.using_outer_summary_function))
{ /* Must copy to another table */
DBUG_PRINT("info",("Creating group table"));
calc_group_buffer(this, group_list);
count_field_types(select_lex, &tmp_table_param, tmp_all_fields1,
select_distinct && !group_list);
tmp_table_param.hidden_field_count=
tmp_table_param.hidden_field_count=
tmp_all_fields1.elements - tmp_fields_list1.elements;
curr_tab++;
aggr_tables++;
bzero(curr_tab, sizeof(JOIN_TAB));
@ -2998,12 +3019,11 @@ bool JOIN::make_aggr_tables_info()
if (join_tab->is_using_loose_index_scan())
tmp_table_param.precomputed_group_by= TRUE;
tmp_table_param.hidden_field_count=
tmp_table_param.hidden_field_count=
curr_all_fields->elements - curr_fields_list->elements;
ORDER *dummy= NULL; //TODO can use table->group here also
if (create_postjoin_aggr_table(curr_tab,
curr_all_fields, dummy, true,
if (create_postjoin_aggr_table(curr_tab, curr_all_fields, dummy, true,
distinct, keep_row_order))
DBUG_RETURN(true);
@ -3274,11 +3294,13 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
*/
ha_rows table_rows_limit= ((order == NULL || skip_sort_order) &&
!table_group &&
!select_lex->with_sum_func) ?
select_limit : HA_POS_ERROR;
!select_lex->with_sum_func) ? select_limit
: HA_POS_ERROR;
if (!(tab->tmp_table_param= new TMP_TABLE_PARAM(tmp_table_param)))
DBUG_RETURN(true);
if (tmp_table_keep_current_rowid)
add_fields_for_current_rowid(tab, table_fields);
tab->tmp_table_param->skip_create_table= true;
TABLE* table= create_tmp_table(thd, tab->tmp_table_param, *table_fields,
table_group, distinct,
@ -3673,7 +3695,7 @@ bool JOIN::prepare_result(List<Item> **columns_list)
select_lex->handle_derived(thd->lex, DT_CREATE))
goto err;
if (result->prepare2())
if (result->prepare2(this))
goto err;
if ((select_lex->options & OPTION_SCHEMA_TABLE) &&
@ -3810,7 +3832,7 @@ void JOIN::exec_inner()
}
columns_list= &procedure_fields_list;
}
if (result->prepare2())
if (result->prepare2(this))
DBUG_VOID_RETURN;
if (!tables_list && (table_count || !select_lex->with_sum_func) &&
@ -9373,7 +9395,7 @@ bool JOIN::get_best_combination()
*/
uint aggr_tables= (group_list ? 1 : 0) +
(select_distinct ?
(tmp_table_param. using_outer_summary_function ? 2 : 1) : 0) +
(tmp_table_param.using_outer_summary_function ? 2 : 1) : 0) +
(order ? 1 : 0) +
(select_options & (SELECT_BIG_RESULT | OPTION_BUFFER_RESULT) ? 1 : 0) ;
@ -16628,8 +16650,6 @@ static void create_tmp_field_from_item_finalize(THD *thd,
update the record in the original table.
If modify_item is 0 then fill_record() will
update the temporary table
@param convert_blob_length If >0 create a varstring(convert_blob_length)
field instead of blob.
@retval
0 on error
@ -16947,6 +16967,10 @@ setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps)
temporary table
@param table_alias possible name of the temporary table that can
be used for name resolving; can be "".
@param do_not_open only create the TABLE object, do not
open the table in the engine
@param keep_row_order rows need to be read in the order they were
inserted, the engine should preserve this order
*/
TABLE *
@ -23399,13 +23423,10 @@ get_sort_by_table(ORDER *a,ORDER *b, List<TABLE_LIST> &tables,
calc how big buffer we need for comparing group entries.
*/
static void
calc_group_buffer(JOIN *join,ORDER *group)
void calc_group_buffer(TMP_TABLE_PARAM *param, ORDER *group)
{
uint key_length=0, parts=0, null_parts=0;
if (group)
join->group= 1;
for (; group ; group=group->next)
{
Item *group_item= *group->item;
@ -23475,9 +23496,16 @@ calc_group_buffer(JOIN *join,ORDER *group)
if (group_item->maybe_null)
null_parts++;
}
join->tmp_table_param.group_length=key_length+null_parts;
join->tmp_table_param.group_parts=parts;
join->tmp_table_param.group_null_parts=null_parts;
param->group_length= key_length + null_parts;
param->group_parts= parts;
param->group_null_parts= null_parts;
}
static void calc_group_buffer(JOIN *join, ORDER *group)
{
if (group)
join->group= 1;
calc_group_buffer(&join->tmp_table_param, group);
}
@ -26220,7 +26248,7 @@ bool JOIN::change_result(select_result *new_result, select_result *old_result)
{
result= new_result;
if (result->prepare(fields_list, select_lex->master_unit()) ||
result->prepare2())
result->prepare2(this))
DBUG_RETURN(true); /* purecov: inspected */
DBUG_RETURN(false);
}