mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
merged bug 28702 5.0-opt->5.1-opt
mysql-test/r/view.result: Auto merged sql/sql_select.cc: Auto merged sql/sql_view.cc: Auto merged sql/table.h: Auto merged
This commit is contained in:
@@ -16043,6 +16043,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
|
||||
|
||||
@@ -16110,6 +16151,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