Skip to content

Commit

Permalink
Merge 10.9 into 10.10
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Mar 6, 2023
2 parents 0bf400a + 46a7603 commit 4ccb2be
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 102 deletions.
4 changes: 2 additions & 2 deletions mysql-test/include/not_valgrind_build.inc
@@ -1,4 +1,4 @@
if (`select version() like '%valgrind%'`)
if (`select version() like '%valgrind%' || version() like '%asan%'`)
{
skip Does not run with binaries built with valgrind;
skip Does not run with binaries built with valgrind or asan;
}
@@ -1,5 +1,7 @@
--source include/have_innodb.inc
--source include/have_debug.inc
# Valgrind builds may block on this one
--source include/not_valgrind.inc

SET @start_global_value = @@global.innodb_log_checkpoint_now;
SELECT @start_global_value;
Expand Down
19 changes: 19 additions & 0 deletions mysys/mulalloc.c
Expand Up @@ -17,6 +17,11 @@
#include "mysys_priv.h"
#include <stdarg.h>

#ifndef DBUG_OFF
/* Put a protected barrier after every element when using my_multi_malloc() */
#define ALLOC_BARRIER
#endif

/*
Malloc many pointers at the same time
Only ptr1 can be free'd, and doing this will free all
Expand Down Expand Up @@ -45,6 +50,9 @@ void* my_multi_malloc(PSI_memory_key key, myf myFlags, ...)
{
length=va_arg(args,uint);
tot_length+=ALIGN_SIZE(length);
#ifdef ALLOC_BARRIER
tot_length+= ALIGN_SIZE(1);
#endif
}
va_end(args);

Expand All @@ -58,6 +66,10 @@ void* my_multi_malloc(PSI_memory_key key, myf myFlags, ...)
*ptr=res;
length=va_arg(args,uint);
res+=ALIGN_SIZE(length);
#ifdef ALLOC_BARRIER
TRASH_FREE(res, ALIGN_SIZE(1));
res+= ALIGN_SIZE(1);
#endif
}
va_end(args);
DBUG_RETURN((void*) start);
Expand Down Expand Up @@ -89,6 +101,9 @@ void *my_multi_malloc_large(PSI_memory_key key, myf myFlags, ...)
{
length=va_arg(args,ulonglong);
tot_length+=ALIGN_SIZE(length);
#ifdef ALLOC_BARRIER
tot_length+= ALIGN_SIZE(1);
#endif
}
va_end(args);

Expand All @@ -102,6 +117,10 @@ void *my_multi_malloc_large(PSI_memory_key key, myf myFlags, ...)
*ptr=res;
length=va_arg(args,ulonglong);
res+=ALIGN_SIZE(length);
#ifdef ALLOC_BARRIER
TRASH_FREE(res, ALIGN_SIZE(1));
res+= ALIGN_SIZE(1);
#endif
}
va_end(args);
DBUG_RETURN((void*) start);
Expand Down
12 changes: 12 additions & 0 deletions mysys/my_alloc.c
Expand Up @@ -28,6 +28,11 @@
#undef EXTRA_DEBUG
#define EXTRA_DEBUG

#ifndef DBUG_OFF
/* Put a protected barrier after every element when using multi_alloc_root() */
#define ALLOC_BARRIER
#endif

/* data packed in MEM_ROOT -> min_malloc */

/* Don't allocate too small blocks */
Expand Down Expand Up @@ -396,6 +401,9 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
{
length= va_arg(args, uint);
tot_length+= ALIGN_SIZE(length);
#ifdef ALLOC_BARRIER
tot_length+= ALIGN_SIZE(1);
#endif
}
va_end(args);

Expand All @@ -409,6 +417,10 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
*ptr= res;
length= va_arg(args, uint);
res+= ALIGN_SIZE(length);
#ifdef ALLOC_BARRIER
TRASH_FREE(res, ALIGN_SIZE(1));
res+= ALIGN_SIZE(1);
#endif
}
va_end(args);
DBUG_RETURN((void*) start);
Expand Down
5 changes: 3 additions & 2 deletions sql/opt_subselect.cc
Expand Up @@ -4186,6 +4186,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
}

sjm->sjm_table_param.field_count= subq_select->item_list.elements;
sjm->sjm_table_param.func_count= sjm->sjm_table_param.field_count;
sjm->sjm_table_param.force_not_null_cols= TRUE;

if (!(sjm->table= create_tmp_table(thd, &sjm->sjm_table_param,
Expand Down Expand Up @@ -5801,14 +5802,14 @@ TABLE *create_dummy_tmp_table(THD *thd)
DBUG_ENTER("create_dummy_tmp_table");
TABLE *table;
TMP_TABLE_PARAM sjm_table_param;
sjm_table_param.init();
sjm_table_param.field_count= 1;
List<Item> sjm_table_cols;
const LEX_CSTRING dummy_name= { STRING_WITH_LEN("dummy") };
Item *column_item= new (thd->mem_root) Item_int(thd, 1);
if (!column_item)
DBUG_RETURN(NULL);

sjm_table_param.init();
sjm_table_param.field_count= sjm_table_param.func_count= 1;
sjm_table_cols.push_back(column_item, thd->mem_root);
if (!(table= create_tmp_table(thd, &sjm_table_param,
sjm_table_cols, (ORDER*) 0,
Expand Down
15 changes: 8 additions & 7 deletions sql/select_handler.cc
Expand Up @@ -51,18 +51,19 @@ select_handler::~select_handler()

TABLE *select_handler::create_tmp_table(THD *thd, SELECT_LEX *select)
{
DBUG_ENTER("select_handler::create_tmp_table");
List<Item> types;
TMP_TABLE_PARAM tmp_table_param;
TABLE *table;
DBUG_ENTER("select_handler::create_tmp_table");

if (select->master_unit()->join_union_item_types(thd, types, 1))
DBUG_RETURN(NULL);
tmp_table_param.init();
tmp_table_param.field_count= types.elements;

TABLE *table= ::create_tmp_table(thd, &tmp_table_param, types,
(ORDER *) 0, false, 0,
TMP_TABLE_ALL_COLUMNS, 1,
&empty_clex_str, true, false);
tmp_table_param.field_count= tmp_table_param.func_count= types.elements;
table= ::create_tmp_table(thd, &tmp_table_param, types,
(ORDER *) 0, false, 0,
TMP_TABLE_ALL_COLUMNS, 1,
&empty_clex_str, true, false);
DBUG_RETURN(table);
}

Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.cc
Expand Up @@ -4286,6 +4286,7 @@ create_result_table(THD *thd_arg, List<Item> *column_types,
{
DBUG_ASSERT(table == 0);
tmp_table_param.field_count= column_types->elements;
tmp_table_param.func_count= tmp_table_param.field_count;
tmp_table_param.bit_fields_as_long= bit_fields_as_long;

if (! (table= create_tmp_table(thd_arg, &tmp_table_param, *column_types,
Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.h
Expand Up @@ -6278,6 +6278,7 @@ class TMP_TABLE_PARAM :public Sql_alloc
@see opt_sum_query, count_field_types
*/
uint sum_func_count;
uint copy_func_count; // Allocated copy fields
uint hidden_field_count;
uint group_parts,group_length,group_null_parts;

Expand Down
2 changes: 1 addition & 1 deletion sql/sql_expression_cache.cc
Expand Up @@ -114,7 +114,7 @@ void Expression_cache_tmptable::init()

cache_table_param.init();
/* dependent items and result */
cache_table_param.field_count= items.elements;
cache_table_param.field_count= cache_table_param.func_count= items.elements;
/* postpone table creation to index description */
cache_table_param.skip_create_table= 1;

Expand Down
20 changes: 15 additions & 5 deletions sql/sql_select.cc
Expand Up @@ -3546,7 +3546,8 @@ bool JOIN::make_aggr_tables_info()

if (gbh)
{
if (!(pushdown_query= new (thd->mem_root) Pushdown_query(select_lex, gbh)))
if (!(pushdown_query= new (thd->mem_root) Pushdown_query(select_lex,
gbh)))
DBUG_RETURN(1);
/*
We must store rows in the tmp table if we need to do an ORDER BY
Expand All @@ -3566,6 +3567,7 @@ bool JOIN::make_aggr_tables_info()

if (!(curr_tab->tmp_table_param= new TMP_TABLE_PARAM(tmp_table_param)))
DBUG_RETURN(1);
curr_tab->tmp_table_param->func_count= all_fields.elements;
TABLE* table= create_tmp_table(thd, curr_tab->tmp_table_param,
all_fields,
NULL, distinct,
Expand Down Expand Up @@ -19600,6 +19602,7 @@ TABLE *Create_tmp_table::start(THD *thd,
*/
if (param->precomputed_group_by)
copy_func_count+= param->sum_func_count;
param->copy_func_count= copy_func_count;

init_sql_alloc(key_memory_TABLE, &own_root, TABLE_ALLOC_BLOCK_SIZE, 0,
MYF(MY_THREAD_SPECIFIC));
Expand Down Expand Up @@ -19805,8 +19808,9 @@ bool Create_tmp_table::add_fields(THD *thd,
We here distinguish between UNION and multi-table-updates by the fact
that in the later case group is set to the row pointer.

The test for item->marker == 4 is ensure we don't create a group-by
key over a bit field as heap tables can't handle that.
The test for item->marker == MARKER_NULL_KEY is ensure we
don't create a group-by key over a bit field as heap tables
can't handle that.
*/
DBUG_ASSERT(!param->schema_table);
Field *new_field=
Expand Down Expand Up @@ -19873,6 +19877,7 @@ bool Create_tmp_table::add_fields(THD *thd,
new_field->flags|= FIELD_PART_OF_TMP_UNIQUE;
}
}

DBUG_ASSERT(fieldnr == m_field_count[other] + m_field_count[distinct]);
DBUG_ASSERT(m_blob_count == m_blobs_count[other] + m_blobs_count[distinct]);
share->fields= fieldnr;
Expand All @@ -19881,6 +19886,8 @@ bool Create_tmp_table::add_fields(THD *thd,
share->blob_field[m_blob_count]= 0; // End marker
copy_func[0]= 0; // End marker
param->func_count= (uint) (copy_func - param->items_to_copy);
DBUG_ASSERT(param->func_count <= param->copy_func_count);

share->column_bitmap_size= bitmap_buffer_size(share->fields);

thd->mem_root= mem_root_save;
Expand Down Expand Up @@ -27337,6 +27344,11 @@ bool JOIN::rollup_init()
Item **ref_array;

tmp_table_param.quick_group= 0; // Can't create groups in tmp table
/*
Each group can potentially be replaced with Item_func_rollup_const() which
needs a copy_func placeholder.
*/
tmp_table_param.func_count+= send_group_parts;
rollup.state= ROLLUP::STATE_INITED;

/*
Expand All @@ -27361,7 +27373,6 @@ bool JOIN::rollup_init()

ref_array= (Item**) (rollup.ref_pointer_arrays+send_group_parts);


/*
Prepare space for field list for the different levels
These will be filled up in rollup_make_fields()
Expand Down Expand Up @@ -27525,7 +27536,6 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields,
/* Point to first hidden field */
uint ref_array_ix= fields_arg.elements-1;


/* Remember where the sum functions ends for the previous level */
sum_funcs_end[pos+1]= *func;

Expand Down
23 changes: 15 additions & 8 deletions sql/sql_show.cc
Expand Up @@ -8306,27 +8306,34 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
TABLE *table;
ST_SCHEMA_TABLE *schema_table= table_list->schema_table;
ST_FIELD_INFO *fields= schema_table->fields_info;
bool need_all_fieds= table_list->schema_table_reformed || // SHOW command
bool need_all_fields= table_list->schema_table_reformed || // SHOW command
thd->lex->only_view_structure(); // need table structure
bool keep_row_order;
TMP_TABLE_PARAM *tmp_table_param;
SELECT_LEX *select_lex;
DBUG_ENTER("create_schema_table");

for (; !fields->end_marker(); fields++)
field_count++;

TMP_TABLE_PARAM *tmp_table_param = new (thd->mem_root) TMP_TABLE_PARAM;
tmp_table_param = new (thd->mem_root) TMP_TABLE_PARAM;
tmp_table_param->init();
tmp_table_param->table_charset= system_charset_info;
tmp_table_param->field_count= field_count;
tmp_table_param->schema_table= 1;
SELECT_LEX *select_lex= table_list->select_lex;
bool keep_row_order= is_show_command(thd);
if (!(table= create_tmp_table_for_schema(thd, tmp_table_param, *schema_table,
(select_lex->options | thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS),
table_list->alias, !need_all_fieds, keep_row_order)))
select_lex= table_list->select_lex;
keep_row_order= is_show_command(thd);
if (!(table=
create_tmp_table_for_schema(thd, tmp_table_param, *schema_table,
(select_lex->options |
thd->variables.option_bits |
TMP_TABLE_ALL_COLUMNS),
table_list->alias, !need_all_fields,
keep_row_order)))
DBUG_RETURN(0);
my_bitmap_map* bitmaps=
(my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count));
my_bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count);
my_bitmap_init(&table->def_read_set, bitmaps, field_count);
table->read_set= &table->def_read_set;
bitmap_clear_all(table->read_set);
table_list->schema_table_param= tmp_table_param;
Expand Down
4 changes: 3 additions & 1 deletion sql/sql_union.cc
Expand Up @@ -344,6 +344,7 @@ select_unit::create_result_table(THD *thd_arg, List<Item> *column_types,
DBUG_ASSERT(table == 0);
tmp_table_param.init();
tmp_table_param.field_count= column_types->elements;
tmp_table_param.func_count= tmp_table_param.field_count;
tmp_table_param.bit_fields_as_long= bit_fields_as_long;
tmp_table_param.hidden_field_count= hidden;

Expand Down Expand Up @@ -384,7 +385,8 @@ select_union_recursive::create_result_table(THD *thd_arg,
return true;

incr_table_param.init();
incr_table_param.field_count= column_types->elements;
incr_table_param.field_count= incr_table_param.func_count=
column_types->elements;
incr_table_param.bit_fields_as_long= bit_fields_as_long;
if (! (incr_table= create_tmp_table(thd_arg, &incr_table_param, *column_types,
(ORDER*) 0, false, 1,
Expand Down
6 changes: 2 additions & 4 deletions sql/temporary_tables.cc
Expand Up @@ -921,9 +921,8 @@ bool THD::has_temporary_tables()
uint THD::create_tmp_table_def_key(char *key, const char *db,
const char *table_name)
{
DBUG_ENTER("THD::create_tmp_table_def_key");

uint key_length;
DBUG_ENTER("THD::create_tmp_table_def_key");

key_length= tdc_create_key(key, db, table_name);
int4store(key + key_length, variables.server_id);
Expand Down Expand Up @@ -1172,11 +1171,10 @@ TABLE *THD::open_temporary_table(TMP_TABLE_SHARE *share,
*/
bool THD::find_and_use_tmp_table(const TABLE_LIST *tl, TABLE **out_table)
{
DBUG_ENTER("THD::find_and_use_tmp_table");

char key[MAX_DBKEY_LENGTH];
uint key_length;
bool result;
DBUG_ENTER("THD::find_and_use_tmp_table");

key_length= create_tmp_table_def_key(key, tl->get_db_name(),
tl->get_table_name());
Expand Down
5 changes: 3 additions & 2 deletions storage/innobase/btr/btr0cur.cc
Expand Up @@ -1011,9 +1011,10 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode,
# ifdef UNIV_SEARCH_PERF_STAT
info->n_searches++;
# endif
bool ahi_enabled= btr_search_enabled && !index()->is_ibuf();
/* We do a dirty read of btr_search_enabled below,
and btr_search_guess_on_hash() will have to check it again. */
if (!btr_search_enabled);
if (!ahi_enabled);
else if (btr_search_guess_on_hash(index(), info, tuple, mode,
latch_mode, this, mtr))
{
Expand Down Expand Up @@ -1335,7 +1336,7 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode,

reached_latched_leaf:
#ifdef BTR_CUR_HASH_ADAPT
if (btr_search_enabled && !(tuple->info_bits & REC_INFO_MIN_REC_FLAG))
if (ahi_enabled && !(tuple->info_bits & REC_INFO_MIN_REC_FLAG))
{
if (page_cur_search_with_match_bytes(tuple, mode,
&up_match, &up_bytes,
Expand Down
2 changes: 2 additions & 0 deletions storage/innobase/include/trx0trx.h
Expand Up @@ -1109,6 +1109,8 @@ struct trx_t : ilist_node<>
ut_ad(!dict_operation);
ut_ad(!apply_online_log);
ut_ad(!is_not_inheriting_locks());
ut_ad(check_foreigns);
ut_ad(check_unique_secondary);
}

/** This has to be invoked on SAVEPOINT or at the end of a statement.
Expand Down

0 comments on commit 4ccb2be

Please sign in to comment.