Commit 05d767db authored by unknown's avatar unknown

merge of the fix for bug 27802 & 27216 to 5.1-opt


mysql-test/r/view.result:
  merge of the fix for bug 27802 to 5.1
sql/item_cmpfunc.h:
  merge of the fix for bug 27216 to 5.1
sql/sql_insert.cc:
  merge of the fix for bug 27216 to 5.1
sql/sql_lex.h:
  merge of the fix for bug 27802 to 5.1
sql/sql_select.cc:
  merge of the fix for bug 27802 to 5.1
sql/table.h:
  merge of the fix for bug 27802 to 5.1
parent baaff867
......@@ -3575,22 +3575,22 @@ PRIMARY KEY(a), KEY (b));
INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),();
CREATE VIEW v1 AS SELECT * FROM t1 FORCE KEY (PRIMARY,b) ORDER BY a;
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` FORCE INDEX (PRIMARY,`b`) order by `t1`.`a`
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` FORCE INDEX (PRIMARY) FORCE INDEX (`b`) order by `t1`.`a` latin1 latin1_swedish_ci
EXPLAIN SELECT * FROM v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 15
CREATE VIEW v2 AS SELECT * FROM t1 USE KEY () ORDER BY a;
SHOW CREATE VIEW v2;
View Create View
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` USE INDEX () order by `t1`.`a`
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` USE INDEX () order by `t1`.`a` latin1 latin1_swedish_ci
EXPLAIN SELECT * FROM v2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort
CREATE VIEW v3 AS SELECT * FROM t1 IGNORE KEY (b) ORDER BY a;
SHOW CREATE VIEW v3;
View Create View
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` IGNORE INDEX (`b`) order by `t1`.`a`
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` IGNORE INDEX (`b`) order by `t1`.`a` latin1 latin1_swedish_ci
EXPLAIN SELECT * FROM v3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort
......
......@@ -1108,6 +1108,7 @@ class Item_func_case :public Item_func
uint ncases;
Item_result cmp_type;
DTCollation cmp_collation;
enum_field_types cached_field_type;
cmp_item *cmp_items[5]; /* For all result types */
cmp_item *case_item;
public:
......@@ -1138,6 +1139,7 @@ class Item_func_case :public Item_func
uint decimal_precision() const;
table_map not_null_tables() const { return 0; }
enum Item_result result_type () const { return cached_result_type; }
enum_field_types field_type() const { return cached_field_type; }
const char *func_name() const { return "case"; }
void print(String *str);
Item *find_item(String *str);
......
......@@ -3315,7 +3315,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
if (item->result_type() != STRING_RESULT)
field= item->tmp_table_field(&tmp_table);
else
field= item->tmp_table_field_from_field_type(&tmp_table);
field= item->tmp_table_field_from_field_type(&tmp_table, 0);
else
field= create_tmp_field(thd, &tmp_table, item, item->type(),
(Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0,
......
......@@ -259,6 +259,8 @@ class Index_hint : public Sql_alloc
key_name.str= str;
key_name.length= length;
}
void print(THD *thd, String *str);
};
/*
......
......@@ -16044,9 +16044,9 @@ static void print_join(THD *thd, String *str, List<TABLE_LIST> *tables)
/**
@brief Print an index hint for a table
@brief Print an index hint
@details Prints out the USE|FORCE|IGNORE index hints for a table.
@details Prints out the USE|FORCE|IGNORE index hint.
@param thd the current thread
@param[out] str appends the index hint here
......@@ -16057,28 +16057,24 @@ static void print_join(THD *thd, String *str, List<TABLE_LIST> *tables)
*/
void
TABLE_LIST::print_index_hint(THD *thd, String *str,
const char *hint, uint32 hint_length,
List<String> indexes)
Index_hint::print(THD *thd, String *str)
{
List_iterator_fast<String> li(indexes);
String *idx;
bool first= 1;
str->append (' ');
str->append (hint, hint_length);
switch (type)
{
case INDEX_HINT_IGNORE: str->append(STRING_WITH_LEN("IGNORE INDEX")); break;
case INDEX_HINT_USE: str->append(STRING_WITH_LEN("USE INDEX")); break;
case INDEX_HINT_FORCE: str->append(STRING_WITH_LEN("FORCE INDEX")); break;
}
str->append (STRING_WITH_LEN(" ("));
while ((idx = li++))
if (key_name.length)
{
if (first)
first= 0;
else
str->append(',');
if (!my_strcasecmp (system_charset_info, idx->c_ptr_safe(),
primary_key_name))
if (thd && !my_strnncoll(system_charset_info,
(const uchar *)key_name.str, key_name.length,
(const uchar *)primary_key_name,
strlen(primary_key_name)))
str->append(primary_key_name);
else
append_identifier (thd, str, idx->ptr(), idx->length());
append_identifier(thd, str, key_name.str, key_name.length);
}
str->append(')');
}
......@@ -16152,16 +16148,17 @@ void TABLE_LIST::print(THD *thd, String *str)
append_identifier(thd, str, alias, strlen(alias));
}
if (use_index)
if (index_hints)
{
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);
List_iterator<Index_hint> it(*index_hints);
Index_hint *hint;
while ((hint= it++))
{
str->append (STRING_WITH_LEN(" "));
hint->print (thd, str);
}
}
}
}
......
......@@ -1161,8 +1161,6 @@ 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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment