Skip to content

Commit 4ccb2be

Browse files
committed
Merge 10.9 into 10.10
2 parents 0bf400a + 46a7603 commit 4ccb2be

21 files changed

+175
-102
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if (`select version() like '%valgrind%'`)
1+
if (`select version() like '%valgrind%' || version() like '%asan%'`)
22
{
3-
skip Does not run with binaries built with valgrind;
3+
skip Does not run with binaries built with valgrind or asan;
44
}

mysql-test/suite/sys_vars/t/innodb_log_checkpoint_now_basic.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--source include/have_innodb.inc
22
--source include/have_debug.inc
3+
# Valgrind builds may block on this one
4+
--source include/not_valgrind.inc
35

46
SET @start_global_value = @@global.innodb_log_checkpoint_now;
57
SELECT @start_global_value;

mysys/mulalloc.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include "mysys_priv.h"
1818
#include <stdarg.h>
1919

20+
#ifndef DBUG_OFF
21+
/* Put a protected barrier after every element when using my_multi_malloc() */
22+
#define ALLOC_BARRIER
23+
#endif
24+
2025
/*
2126
Malloc many pointers at the same time
2227
Only ptr1 can be free'd, and doing this will free all
@@ -45,6 +50,9 @@ void* my_multi_malloc(PSI_memory_key key, myf myFlags, ...)
4550
{
4651
length=va_arg(args,uint);
4752
tot_length+=ALIGN_SIZE(length);
53+
#ifdef ALLOC_BARRIER
54+
tot_length+= ALIGN_SIZE(1);
55+
#endif
4856
}
4957
va_end(args);
5058

@@ -58,6 +66,10 @@ void* my_multi_malloc(PSI_memory_key key, myf myFlags, ...)
5866
*ptr=res;
5967
length=va_arg(args,uint);
6068
res+=ALIGN_SIZE(length);
69+
#ifdef ALLOC_BARRIER
70+
TRASH_FREE(res, ALIGN_SIZE(1));
71+
res+= ALIGN_SIZE(1);
72+
#endif
6173
}
6274
va_end(args);
6375
DBUG_RETURN((void*) start);
@@ -89,6 +101,9 @@ void *my_multi_malloc_large(PSI_memory_key key, myf myFlags, ...)
89101
{
90102
length=va_arg(args,ulonglong);
91103
tot_length+=ALIGN_SIZE(length);
104+
#ifdef ALLOC_BARRIER
105+
tot_length+= ALIGN_SIZE(1);
106+
#endif
92107
}
93108
va_end(args);
94109

@@ -102,6 +117,10 @@ void *my_multi_malloc_large(PSI_memory_key key, myf myFlags, ...)
102117
*ptr=res;
103118
length=va_arg(args,ulonglong);
104119
res+=ALIGN_SIZE(length);
120+
#ifdef ALLOC_BARRIER
121+
TRASH_FREE(res, ALIGN_SIZE(1));
122+
res+= ALIGN_SIZE(1);
123+
#endif
105124
}
106125
va_end(args);
107126
DBUG_RETURN((void*) start);

mysys/my_alloc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
#undef EXTRA_DEBUG
2929
#define EXTRA_DEBUG
3030

31+
#ifndef DBUG_OFF
32+
/* Put a protected barrier after every element when using multi_alloc_root() */
33+
#define ALLOC_BARRIER
34+
#endif
35+
3136
/* data packed in MEM_ROOT -> min_malloc */
3237

3338
/* Don't allocate too small blocks */
@@ -396,6 +401,9 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
396401
{
397402
length= va_arg(args, uint);
398403
tot_length+= ALIGN_SIZE(length);
404+
#ifdef ALLOC_BARRIER
405+
tot_length+= ALIGN_SIZE(1);
406+
#endif
399407
}
400408
va_end(args);
401409

@@ -409,6 +417,10 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
409417
*ptr= res;
410418
length= va_arg(args, uint);
411419
res+= ALIGN_SIZE(length);
420+
#ifdef ALLOC_BARRIER
421+
TRASH_FREE(res, ALIGN_SIZE(1));
422+
res+= ALIGN_SIZE(1);
423+
#endif
412424
}
413425
va_end(args);
414426
DBUG_RETURN((void*) start);

sql/opt_subselect.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,6 +4186,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
41864186
}
41874187

41884188
sjm->sjm_table_param.field_count= subq_select->item_list.elements;
4189+
sjm->sjm_table_param.func_count= sjm->sjm_table_param.field_count;
41894190
sjm->sjm_table_param.force_not_null_cols= TRUE;
41904191

41914192
if (!(sjm->table= create_tmp_table(thd, &sjm->sjm_table_param,
@@ -5801,14 +5802,14 @@ TABLE *create_dummy_tmp_table(THD *thd)
58015802
DBUG_ENTER("create_dummy_tmp_table");
58025803
TABLE *table;
58035804
TMP_TABLE_PARAM sjm_table_param;
5804-
sjm_table_param.init();
5805-
sjm_table_param.field_count= 1;
58065805
List<Item> sjm_table_cols;
58075806
const LEX_CSTRING dummy_name= { STRING_WITH_LEN("dummy") };
58085807
Item *column_item= new (thd->mem_root) Item_int(thd, 1);
58095808
if (!column_item)
58105809
DBUG_RETURN(NULL);
58115810

5811+
sjm_table_param.init();
5812+
sjm_table_param.field_count= sjm_table_param.func_count= 1;
58125813
sjm_table_cols.push_back(column_item, thd->mem_root);
58135814
if (!(table= create_tmp_table(thd, &sjm_table_param,
58145815
sjm_table_cols, (ORDER*) 0,

sql/select_handler.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,19 @@ select_handler::~select_handler()
5151

5252
TABLE *select_handler::create_tmp_table(THD *thd, SELECT_LEX *select)
5353
{
54-
DBUG_ENTER("select_handler::create_tmp_table");
5554
List<Item> types;
5655
TMP_TABLE_PARAM tmp_table_param;
56+
TABLE *table;
57+
DBUG_ENTER("select_handler::create_tmp_table");
58+
5759
if (select->master_unit()->join_union_item_types(thd, types, 1))
5860
DBUG_RETURN(NULL);
5961
tmp_table_param.init();
60-
tmp_table_param.field_count= types.elements;
61-
62-
TABLE *table= ::create_tmp_table(thd, &tmp_table_param, types,
63-
(ORDER *) 0, false, 0,
64-
TMP_TABLE_ALL_COLUMNS, 1,
65-
&empty_clex_str, true, false);
62+
tmp_table_param.field_count= tmp_table_param.func_count= types.elements;
63+
table= ::create_tmp_table(thd, &tmp_table_param, types,
64+
(ORDER *) 0, false, 0,
65+
TMP_TABLE_ALL_COLUMNS, 1,
66+
&empty_clex_str, true, false);
6667
DBUG_RETURN(table);
6768
}
6869

sql/sql_class.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,6 +4286,7 @@ create_result_table(THD *thd_arg, List<Item> *column_types,
42864286
{
42874287
DBUG_ASSERT(table == 0);
42884288
tmp_table_param.field_count= column_types->elements;
4289+
tmp_table_param.func_count= tmp_table_param.field_count;
42894290
tmp_table_param.bit_fields_as_long= bit_fields_as_long;
42904291

42914292
if (! (table= create_tmp_table(thd_arg, &tmp_table_param, *column_types,

sql/sql_class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6278,6 +6278,7 @@ class TMP_TABLE_PARAM :public Sql_alloc
62786278
@see opt_sum_query, count_field_types
62796279
*/
62806280
uint sum_func_count;
6281+
uint copy_func_count; // Allocated copy fields
62816282
uint hidden_field_count;
62826283
uint group_parts,group_length,group_null_parts;
62836284

sql/sql_expression_cache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void Expression_cache_tmptable::init()
114114

115115
cache_table_param.init();
116116
/* dependent items and result */
117-
cache_table_param.field_count= items.elements;
117+
cache_table_param.field_count= cache_table_param.func_count= items.elements;
118118
/* postpone table creation to index description */
119119
cache_table_param.skip_create_table= 1;
120120

sql/sql_select.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3546,7 +3546,8 @@ bool JOIN::make_aggr_tables_info()
35463546

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

35673568
if (!(curr_tab->tmp_table_param= new TMP_TABLE_PARAM(tmp_table_param)))
35683569
DBUG_RETURN(1);
3570+
curr_tab->tmp_table_param->func_count= all_fields.elements;
35693571
TABLE* table= create_tmp_table(thd, curr_tab->tmp_table_param,
35703572
all_fields,
35713573
NULL, distinct,
@@ -19600,6 +19602,7 @@ TABLE *Create_tmp_table::start(THD *thd,
1960019602
*/
1960119603
if (param->precomputed_group_by)
1960219604
copy_func_count+= param->sum_func_count;
19605+
param->copy_func_count= copy_func_count;
1960319606

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

19808-
The test for item->marker == 4 is ensure we don't create a group-by
19809-
key over a bit field as heap tables can't handle that.
19811+
The test for item->marker == MARKER_NULL_KEY is ensure we
19812+
don't create a group-by key over a bit field as heap tables
19813+
can't handle that.
1981019814
*/
1981119815
DBUG_ASSERT(!param->schema_table);
1981219816
Field *new_field=
@@ -19873,6 +19877,7 @@ bool Create_tmp_table::add_fields(THD *thd,
1987319877
new_field->flags|= FIELD_PART_OF_TMP_UNIQUE;
1987419878
}
1987519879
}
19880+
1987619881
DBUG_ASSERT(fieldnr == m_field_count[other] + m_field_count[distinct]);
1987719882
DBUG_ASSERT(m_blob_count == m_blobs_count[other] + m_blobs_count[distinct]);
1987819883
share->fields= fieldnr;
@@ -19881,6 +19886,8 @@ bool Create_tmp_table::add_fields(THD *thd,
1988119886
share->blob_field[m_blob_count]= 0; // End marker
1988219887
copy_func[0]= 0; // End marker
1988319888
param->func_count= (uint) (copy_func - param->items_to_copy);
19889+
DBUG_ASSERT(param->func_count <= param->copy_func_count);
19890+
1988419891
share->column_bitmap_size= bitmap_buffer_size(share->fields);
1988519892

1988619893
thd->mem_root= mem_root_save;
@@ -27337,6 +27344,11 @@ bool JOIN::rollup_init()
2733727344
Item **ref_array;
2733827345

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

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

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

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

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

0 commit comments

Comments
 (0)