summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-09-26 19:06:54 +0300
committerunknown <gkodinov/kgeorge@magare.gmz>2007-09-26 19:06:54 +0300
commitbc25c6cafbb9e8c3b849f8077cd9bd487e000551 (patch)
tree72aa6cfe7d2fc332845cce73577dd273ccaa5f64
parentc89bc705a9e300d12a64dffe4df89ec3564d76a0 (diff)
downloadmariadb-git-bc25c6cafbb9e8c3b849f8077cd9bd487e000551.tar.gz
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
-rw-r--r--mysql-test/r/view.result12
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_select.cc51
-rw-r--r--sql/table.h2
6 files changed, 35 insertions, 36 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 3fe42a0ff80..93b91370d86 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -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
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 1a64f9c4211..e9aeef7fc3e 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -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 @@ public:
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);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 4bac5f9c9da..459eefbf760 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -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,
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 08104769704..d866dde50ef 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -259,6 +259,8 @@ public:
key_name.str= str;
key_name.length= length;
}
+
+ void print(THD *thd, String *str);
};
/*
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 83eb597041a..eccd44f2654 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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);
+ }
+ }
}
}
diff --git a/sql/table.h b/sql/table.h
index 89d92b1be13..6554b6ed578 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -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.