diff options
author | Varun Gupta <varunraiko1803@gmail.com> | 2018-05-15 01:44:03 +0530 |
---|---|---|
committer | Varun Gupta <varunraiko1803@gmail.com> | 2018-05-16 11:40:11 +0530 |
commit | 6f4534e6220d9224dbd3226aba310c4ca58f6da3 (patch) | |
tree | 83894b9d53d23b4e720d9f3332624a2e2f17c77d /sql/sql_lex.cc | |
parent | d9f9cd1a102f17a1a23086585588d119ffff2578 (diff) | |
download | mariadb-git-6f4534e6220d9224dbd3226aba310c4ca58f6da3.tar.gz |
MDEV-14695: Assertion `n < m_size' failed in Bounds_checked_array<Element_type>::operator
In this issue we hit the assert because we are adding addition fields to the field JOIN::all_fields list. This
is done because HEAP tables can't index BIT fields so we need to use an additional hidden field for grouping because later it will be
converted to a LONG field. Original field will remain of the BIT type and will be returned. This happens when we convert DISTINCT to
GROUP BY.
The solution is to take into account the number of such hidden fields that would be added to the field
JOIN::all_fields list while calculating the size of the ref_pointer_array.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 3e36cac96b9..1752689b385 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2126,6 +2126,7 @@ void st_select_lex::init_query() select_n_having_items= 0; n_sum_items= 0; n_child_sum_items= 0; + hidden_bit_fields= 0; subquery_in_having= explicit_limit= 0; is_item_list_lookup= 0; first_execution= 1; @@ -2673,6 +2674,10 @@ ulong st_select_lex::get_table_join_options() bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) { + + if (!((options & SELECT_DISTINCT) && !group_list.elements)) + hidden_bit_fields= 0; + // find_order_in_list() may need some extra space, so multiply by two. order_group_num*= 2; @@ -2687,7 +2692,8 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) select_n_reserved + select_n_having_items + select_n_where_fields + - order_group_num) * 5; + order_group_num + + hidden_bit_fields) * 5; if (!ref_pointer_array.is_null()) { /* |