mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-37292 Hint NO_INDEX() disables all indexes if none of given index names is resolved
When a hint has a list of index names, for example, `NO_INDEX(t1 idx1, idx2)` there is a possibility that some or all of the listed index names will not be resolved. If none of them are resolved, the hint becomes a table-level hint, for example, `NO_INDEX(t1)`, which erroneously disables all indexes of `t1` instead of disabling only some of them. This commit addresses this issue by adding an additional check: a hint containing a list of index names is considered resolved only when at least one of the listed names is resolved successfully.
This commit is contained in:
committed by
Sergei Golubchik
parent
c329c43be7
commit
893761b35c
@@ -552,14 +552,6 @@ bool Opt_hints_table::fix_key_hints(TABLE *table)
|
||||
fixing the child objects.
|
||||
*/
|
||||
set_fixed();
|
||||
if (is_specified(INDEX_HINT_ENUM))
|
||||
global_index_map.set_fixed();
|
||||
if (is_specified(JOIN_INDEX_HINT_ENUM))
|
||||
join_index_map.set_fixed();
|
||||
if (is_specified(GROUP_INDEX_HINT_ENUM))
|
||||
group_index_map.set_fixed();
|
||||
if (is_specified(ORDER_INDEX_HINT_ENUM))
|
||||
order_index_map.set_fixed();
|
||||
|
||||
/* Make sure that adjustment is called only once. */
|
||||
DBUG_ASSERT(keyinfo_array.size() == 0);
|
||||
@@ -582,6 +574,26 @@ bool Opt_hints_table::fix_key_hints(TABLE *table)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Fixing compound index hints. A compound hint is fixed in two cases:
|
||||
- it is a table-level hint, i.e. does not have a list of index names
|
||||
(like ORDER_INDEX(t1);
|
||||
- it has a list of index names, and at least one of listed
|
||||
index names is resolved successfully. So, NO_INDEX(t1 bad_idx) does not
|
||||
become a table-level hint NO_INDEX(t1) if `bad_idx` cannnot be resolved.
|
||||
*/
|
||||
for (opt_hints_enum
|
||||
hint_type : { INDEX_HINT_ENUM, JOIN_INDEX_HINT_ENUM,
|
||||
GROUP_INDEX_HINT_ENUM, ORDER_INDEX_HINT_ENUM })
|
||||
{
|
||||
if (is_specified(hint_type))
|
||||
{
|
||||
Opt_hints_key_bitmap *bitmap= get_key_hint_bitmap(hint_type);
|
||||
if (bitmap->is_table_level() || bitmap->bits_set() > 0)
|
||||
bitmap->set_fixed();
|
||||
}
|
||||
}
|
||||
|
||||
if (are_children_fully_fixed())
|
||||
return false;
|
||||
|
||||
|
Reference in New Issue
Block a user