summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index fa93a11d2fa..a179ab93373 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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
@@ -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,
@@ -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));
@@ -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=
@@ -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;
@@ -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;
@@ -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;
/*
@@ -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()
@@ -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;