1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge branch '11.0' into 11.1

This commit is contained in:
Sergei Golubchik
2023-12-19 20:11:54 +01:00
672 changed files with 27790 additions and 5130 deletions

View File

@@ -2724,7 +2724,7 @@ SQL_SELECT::test_quick_select(THD *thd,
bool ordered_output,
bool remove_false_parts_of_where,
bool only_single_index_range_scan,
bool suppress_unusable_key_notes)
Item_func::Bitmap note_unusable_keys)
{
uint idx;
Item *notnull_cond= NULL;
@@ -2810,9 +2810,9 @@ SQL_SELECT::test_quick_select(THD *thd,
param.max_key_parts= 0;
param.remove_false_where_parts= remove_false_parts_of_where;
param.force_default_mrr= ordered_output;
param.note_unusable_keys= (!suppress_unusable_key_notes &&
thd->give_notes_for_unusable_keys());
param.note_unusable_keys= thd->give_notes_for_unusable_keys() ?
note_unusable_keys :
Item_func::BITMAP_NONE;
param.possible_keys.clear_all();
thd->no_errors=1; // Don't warn about NULL
@@ -4117,7 +4117,7 @@ bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond)
range_par->remove_jump_scans= FALSE;
range_par->real_keynr[0]= 0;
range_par->alloced_sel_args= 0;
range_par->note_unusable_keys= 0;
range_par->note_unusable_keys= Item_func::BITMAP_NONE;
thd->no_errors=1; // Don't warn about NULL
thd->mem_root=&alloc;
@@ -9036,9 +9036,11 @@ Item_func_like::get_mm_leaf(RANGE_OPT_PARAM *param,
if (field->result_type() == STRING_RESULT &&
field->charset() != compare_collation())
{
if (param->note_unusable_keys)
if (param->note_unusable_keys & BITMAP_LIKE)
field->raise_note_cannot_use_key_part(param->thd, keynr, key_part->part,
func_name_cstring(), value,
func_name_cstring(),
compare_collation(),
value,
Data_type_compatibility::
INCOMPATIBLE_COLLATION);
DBUG_RETURN(0);
@@ -9054,9 +9056,11 @@ Item_func_like::get_mm_leaf(RANGE_OPT_PARAM *param,
field->type_handler() == &type_handler_enum ||
field->type_handler() == &type_handler_set)
{
if (param->note_unusable_keys)
if (param->note_unusable_keys & BITMAP_LIKE)
field->raise_note_cannot_use_key_part(param->thd, keynr, key_part->part,
func_name_cstring(), value,
func_name_cstring(),
compare_collation(),
value,
Data_type_compatibility::
INCOMPATIBLE_DATA_TYPE);
DBUG_RETURN(0);
@@ -9161,7 +9165,8 @@ Field::can_optimize_scalar_range(const RANGE_OPT_PARAM *param,
TODO: Perhaps we also need to raise a similar note when
a partition could not be used (when using_real_indexes==false).
*/
if (param->using_real_indexes && param->note_unusable_keys)
if (param->using_real_indexes && param->note_unusable_keys &&
(param->note_unusable_keys & cond->bitmap_bit()))
{
DBUG_ASSERT(keynr < table->s->keys);
/*
@@ -9175,6 +9180,7 @@ Field::can_optimize_scalar_range(const RANGE_OPT_PARAM *param,
*/
raise_note_cannot_use_key_part(param->thd, keynr, key_part->part,
scalar_comparison_op_to_lex_cstring(op),
cond->compare_collation(),
value, compat);
}
return compat;
@@ -15623,13 +15629,6 @@ int QUICK_GROUP_MIN_MAX_SELECT::init()
{
if (group_prefix) /* Already initialized. */
return 0;
/*
We allocate one byte more to serve the case when the last field in
the buffer is compared using uint3korr (e.g. a Field_newdate field)
*/
if (!(last_prefix= (uchar*) alloc_root(&alloc, group_prefix_len+1)))
return 1;
/*
We may use group_prefix to store keys with all select fields, so allocate
enough space for it.
@@ -15886,8 +15885,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_key_stat()
QUICK_GROUP_MIN_MAX_SELECT::reset()
DESCRIPTION
Initialize the index chosen for access and find and store the prefix
of the last group. The method is expensive since it performs disk access.
Initialize the index chosen for access.
RETURN
0 OK
@@ -15910,12 +15908,6 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void)
}
if (quick_prefix_select && quick_prefix_select->reset())
DBUG_RETURN(1);
result= file->ha_index_last(record);
if (result == HA_ERR_END_OF_FILE)
DBUG_RETURN(0);
/* Save the prefix of the last group. */
key_copy(last_prefix, record, index_info, group_prefix_len);
DBUG_RETURN(0);
}
@@ -15961,34 +15953,20 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next()
#else
int result;
#endif
int is_last_prefix= 0;
DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::get_next");
/*
Loop until a group is found that satisfies all query conditions or the last
group is reached.
Loop until a group is found that satisfies all query conditions or
there are no satisfying groups left
*/
do
{
result= next_prefix();
/*
Check if this is the last group prefix. Notice that at this point
this->record contains the current prefix in record format.
*/
if (!result)
{
is_last_prefix= key_cmp(index_info->key_part, last_prefix,
group_prefix_len);
DBUG_ASSERT(is_last_prefix <= 0);
}
else
{
if (result == HA_ERR_KEY_NOT_FOUND)
continue;
if (result != 0)
break;
}
/*
At this point this->record contains the current prefix in record format.
*/
if (have_min)
{
min_res= next_min();
@@ -16017,8 +15995,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next()
HA_READ_KEY_EXACT);
result= have_min ? min_res : have_max ? max_res : result;
} while ((result == HA_ERR_KEY_NOT_FOUND || result == HA_ERR_END_OF_FILE) &&
is_last_prefix != 0);
} while (result == HA_ERR_KEY_NOT_FOUND || result == HA_ERR_END_OF_FILE);
if (result == HA_ERR_KEY_NOT_FOUND)
result= HA_ERR_END_OF_FILE;