mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Bug #28702: VIEWs defined with USE/FORCE KEY ignore that request
When storing the VIEW the CREATE VIEW command is reconstructed from the parse tree. While constructing the command string the index hints specified should also be printed. Fixed by adding code to print the index hints when printing a table in the FROM clause.
This commit is contained in:
@ -15469,6 +15469,47 @@ static void print_join(THD *thd, String *str, List<TABLE_LIST> *tables)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief Print an index hint for a table
|
||||
|
||||
@details Prints out the USE|FORCE|IGNORE index hints for a table.
|
||||
|
||||
@param thd the current thread
|
||||
@param[out] str appends the index hint here
|
||||
@param hint what the hint is (as string : "USE INDEX"|
|
||||
"FORCE INDEX"|"IGNORE INDEX")
|
||||
@param hint_length the length of the string in 'hint'
|
||||
@param indexes a list of index names for the hint
|
||||
*/
|
||||
|
||||
void
|
||||
TABLE_LIST::print_index_hint(THD *thd, String *str,
|
||||
const char *hint, uint32 hint_length,
|
||||
List<String> indexes)
|
||||
{
|
||||
List_iterator_fast<String> li(indexes);
|
||||
String *idx;
|
||||
bool first= 1;
|
||||
|
||||
str->append (' ');
|
||||
str->append (hint, hint_length);
|
||||
str->append (STRING_WITH_LEN(" ("));
|
||||
while ((idx = li++))
|
||||
{
|
||||
if (first)
|
||||
first= 0;
|
||||
else
|
||||
str->append(',');
|
||||
if (!my_strcasecmp (system_charset_info, idx->c_ptr_safe(),
|
||||
primary_key_name))
|
||||
str->append(primary_key_name);
|
||||
else
|
||||
append_identifier (thd, str, idx->ptr(), idx->length());
|
||||
}
|
||||
str->append(')');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Print table as it should be in join list
|
||||
|
||||
@ -15536,6 +15577,17 @@ void TABLE_LIST::print(THD *thd, String *str)
|
||||
str->append(' ');
|
||||
append_identifier(thd, str, alias, strlen(alias));
|
||||
}
|
||||
|
||||
if (use_index)
|
||||
{
|
||||
if (force_index)
|
||||
print_index_hint(thd, str, STRING_WITH_LEN("FORCE INDEX"), *use_index);
|
||||
else
|
||||
print_index_hint(thd, str, STRING_WITH_LEN("USE INDEX"), *use_index);
|
||||
}
|
||||
if (ignore_index)
|
||||
print_index_hint (thd, str, STRING_WITH_LEN("IGNORE INDEX"), *ignore_index);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user