diff options
author | unknown <gkodinov/kgeorge@magare.gmz> | 2007-09-26 14:22:48 +0300 |
---|---|---|
committer | unknown <gkodinov/kgeorge@magare.gmz> | 2007-09-26 14:22:48 +0300 |
commit | c89bc705a9e300d12a64dffe4df89ec3564d76a0 (patch) | |
tree | 6b147f71d5f5a02afe4727b26ecc5e2a410eaa2b /sql | |
parent | e4cbbcf8a970b854bfbc34f77571afdb0b247814 (diff) | |
parent | ca448acc25f6502140a68942b2d6d043d3482708 (diff) | |
download | mariadb-git-c89bc705a9e300d12a64dffe4df89ec3564d76a0.tar.gz |
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
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 52 | ||||
-rw-r--r-- | sql/table.h | 2 |
2 files changed, 54 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b77bb719e1e..83eb597041a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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); + } } diff --git a/sql/table.h b/sql/table.h index 6554b6ed578..89d92b1be13 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1161,6 +1161,8 @@ struct TABLE_LIST private: bool prep_check_option(THD *thd, uint8 check_opt_type); bool prep_where(THD *thd, Item **conds, bool no_where_clause); + void print_index_hint(THD *thd, String *str, const char *hint, + uint32 hint_length, List<String>); /* Cleanup for re-execution in a prepared statement or a stored procedure. |