Commit e85df7fe authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-19702 Refactor Bitmap<N> to be based on ulonglong, not on uint32

Removed Field_map, since it was used only in a single function.

Fixed is_indexed_agg_distinct(), since it relied on initialization of
Bitmap in constructor.

Fixes MDEV-25888 in 10.4
parent 0b9a59bb
This diff is collapsed.
...@@ -7046,7 +7046,6 @@ void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array) ...@@ -7046,7 +7046,6 @@ void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array)
} }
} }
/** /**
Check for the presence of AGGFN(DISTINCT a) queries that may be subject Check for the presence of AGGFN(DISTINCT a) queries that may be subject
to loose index scan. to loose index scan.
...@@ -7084,7 +7083,6 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args) ...@@ -7084,7 +7083,6 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args)
{ {
Item_sum **sum_item_ptr; Item_sum **sum_item_ptr;
bool result= false; bool result= false;
Field_map first_aggdistinct_fields;
if (join->table_count != 1 || /* reference more than 1 table */ if (join->table_count != 1 || /* reference more than 1 table */
join->select_distinct || /* or a DISTINCT */ join->select_distinct || /* or a DISTINCT */
...@@ -7094,10 +7092,11 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args) ...@@ -7094,10 +7092,11 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args)
if (join->make_sum_func_list(join->all_fields, join->fields_list, true)) if (join->make_sum_func_list(join->all_fields, join->fields_list, true))
return false; return false;
Bitmap<MAX_FIELDS> first_aggdistinct_fields;
bool first_aggdistinct_fields_initialized= false;
for (sum_item_ptr= join->sum_funcs; *sum_item_ptr; sum_item_ptr++) for (sum_item_ptr= join->sum_funcs; *sum_item_ptr; sum_item_ptr++)
{ {
Item_sum *sum_item= *sum_item_ptr; Item_sum *sum_item= *sum_item_ptr;
Field_map cur_aggdistinct_fields;
Item *expr; Item *expr;
/* aggregate is not AGGFN(DISTINCT) or more than 1 argument to it */ /* aggregate is not AGGFN(DISTINCT) or more than 1 argument to it */
switch (sum_item->sum_func()) switch (sum_item->sum_func())
...@@ -7120,6 +7119,8 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args) ...@@ -7120,6 +7119,8 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args)
We don't worry about duplicates as these will be sorted out later in We don't worry about duplicates as these will be sorted out later in
get_best_group_min_max get_best_group_min_max
*/ */
Bitmap<MAX_FIELDS> cur_aggdistinct_fields;
cur_aggdistinct_fields.clear_all();
for (uint i= 0; i < sum_item->get_arg_count(); i++) for (uint i= 0; i < sum_item->get_arg_count(); i++)
{ {
expr= sum_item->get_arg(i); expr= sum_item->get_arg(i);
...@@ -7138,8 +7139,11 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args) ...@@ -7138,8 +7139,11 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args)
If there are multiple aggregate functions, make sure that they all If there are multiple aggregate functions, make sure that they all
refer to exactly the same set of columns. refer to exactly the same set of columns.
*/ */
if (first_aggdistinct_fields.is_clear_all()) if (!first_aggdistinct_fields_initialized)
first_aggdistinct_fields.merge(cur_aggdistinct_fields); {
first_aggdistinct_fields= cur_aggdistinct_fields;
first_aggdistinct_fields_initialized=true;
}
else if (first_aggdistinct_fields != cur_aggdistinct_fields) else if (first_aggdistinct_fields != cur_aggdistinct_fields)
return false; return false;
} }
......
...@@ -1193,9 +1193,6 @@ struct st_cond_statistic; ...@@ -1193,9 +1193,6 @@ struct st_cond_statistic;
#define CHECK_ROW_FOR_NULLS_TO_REJECT (1 << 0) #define CHECK_ROW_FOR_NULLS_TO_REJECT (1 << 0)
#define REJECT_ROW_DUE_TO_NULL_FIELDS (1 << 1) #define REJECT_ROW_DUE_TO_NULL_FIELDS (1 << 1)
/* Bitmap of table's fields */
typedef Bitmap<MAX_FIELDS> Field_map;
class SplM_opt_info; class SplM_opt_info;
struct vers_select_conds_t; struct vers_select_conds_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment