From a3e83048a36b20481155315d1026c6d91da8ecef Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Feb 2008 13:30:33 +0300 Subject: Fix for Bug#30217: Views: changes in metadata behaviour between 5.0 and 5.1. The problem was that in the patch for Bug#11986 it was decided to store original query in UTF8 encoding for the INFORMATION_SCHEMA. This approach however turned out to be quite difficult to implement properly. The main problem is to preserve the same IS-output after dump/restore. So, the fix is to rollback to the previous functionality, but also to fix it to support multi-character-set-queries properly. The idea is to generate INFORMATION_SCHEMA-query from the item-tree after parsing view declaration. The IS-query should: - be completely in UTF8; - not contain character set introducers. For more information, see WL4052. mysql-test/include/ddl_i18n.check_views.inc: Add a test case for Bug#30217. mysql-test/r/ddl_i18n_koi8r.result: Update result file. mysql-test/r/ddl_i18n_utf8.result: Update result file. mysql-test/r/information_schema.result: Update result file. mysql-test/r/information_schema_db.result: Update result file. mysql-test/r/mysqldump.result: Update result file. mysql-test/r/show_check.result: Update result file. mysql-test/t/ddl_i18n_koi8r.test: Add a test case for Bug#30217. mysql-test/t/ddl_i18n_utf8.test: Add a test case for Bug#30217. mysql-test/t/mysqldump.test: Add a test case for Bug#30217. sql/ha_ndbcluster.cc: Add a parameter to print(). sql/item.cc: 1. Add a parameter to print(). 2. Item_string::print(): - Do not append character set introducer to the text literal if we're building a query for INFORMATION_SCHEMA; - Convert text literal to UTF8 if we're building a query for INFORMATION_SCHEMA. sql/item.h: Add a parameter to print(). sql/item_cmpfunc.cc: Add a parameter to print(). sql/item_cmpfunc.h: Add a parameter to print(). sql/item_func.cc: Add a parameter to print(). sql/item_func.h: Add a parameter to print(). sql/item_geofunc.h: Add a parameter to print(). sql/item_row.cc: Add a parameter to print(). sql/item_row.h: Add a parameter to print(). sql/item_strfunc.cc: Add a parameter to print(). sql/item_strfunc.h: Add a parameter to print(). sql/item_subselect.cc: Add a parameter to print(). sql/item_subselect.h: Add a parameter to print(). sql/item_sum.cc: Add a parameter to print(). sql/item_sum.h: Add a parameter to print(). sql/item_timefunc.cc: Add a parameter to print(). sql/item_timefunc.h: Add a parameter to print(). sql/mysql_priv.h: Add a parameter to print(). sql/sp_head.cc: Add a parameter to print(). sql/sql_lex.cc: Add a parameter to print(). sql/sql_lex.h: Add a parameter to print(). sql/sql_parse.cc: Add a parameter to print(). sql/sql_select.cc: Add a parameter to print(). sql/sql_show.cc: Add a parameter to print(). sql/sql_test.cc: Add a parameter to print(). sql/sql_view.cc: Build INFORMATION_SCHEMA query from Item-tree. sql/sql_yacc.yy: Build INFORMATION_SCHEMA query from Item-tree. sql/table.h: Add a parameter to print(). --- sql/item_subselect.cc | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'sql/item_subselect.cc') diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 46b8d2e46cc..7b68d258d29 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -306,10 +306,10 @@ void Item_subselect::update_used_tables() } -void Item_subselect::print(String *str) +void Item_subselect::print(String *str, enum_query_type query_type) { str->append('('); - engine->print(str); + engine->print(str, query_type); str->append(')'); } @@ -391,10 +391,10 @@ void Item_maxmin_subselect::cleanup() } -void Item_maxmin_subselect::print(String *str) +void Item_maxmin_subselect::print(String *str, enum_query_type query_type) { str->append(max?"":"", 5); - Item_singlerow_subselect::print(str); + Item_singlerow_subselect::print(str, query_type); } @@ -630,10 +630,10 @@ Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex): } -void Item_exists_subselect::print(String *str) +void Item_exists_subselect::print(String *str, enum_query_type query_type) { str->append(STRING_WITH_LEN("exists")); - Item_subselect::print(str); + Item_subselect::print(str, query_type); } @@ -1553,16 +1553,16 @@ err: } -void Item_in_subselect::print(String *str) +void Item_in_subselect::print(String *str, enum_query_type query_type) { if (transformed) str->append(STRING_WITH_LEN("")); else { - left_expr->print(str); + left_expr->print(str, query_type); str->append(STRING_WITH_LEN(" in ")); } - Item_subselect::print(str); + Item_subselect::print(str, query_type); } @@ -1587,18 +1587,18 @@ Item_allany_subselect::select_transformer(JOIN *join) } -void Item_allany_subselect::print(String *str) +void Item_allany_subselect::print(String *str, enum_query_type query_type) { if (transformed) str->append(STRING_WITH_LEN("")); else { - left_expr->print(str); + left_expr->print(str, query_type); str->append(' '); str->append(func->symbol(all)); str->append(all ? " all " : " any ", 5); } - Item_subselect::print(str); + Item_subselect::print(str, query_type); } @@ -2384,22 +2384,24 @@ table_map subselect_union_engine::upper_select_const_tables() } -void subselect_single_select_engine::print(String *str) +void subselect_single_select_engine::print(String *str, + enum_query_type query_type) { - select_lex->print(thd, str); + select_lex->print(thd, str, query_type); } -void subselect_union_engine::print(String *str) +void subselect_union_engine::print(String *str, enum_query_type query_type) { - unit->print(str); + unit->print(str, query_type); } -void subselect_uniquesubquery_engine::print(String *str) +void subselect_uniquesubquery_engine::print(String *str, + enum_query_type query_type) { str->append(STRING_WITH_LEN("(")); - tab->ref.items[0]->print(str); + tab->ref.items[0]->print(str, query_type); str->append(STRING_WITH_LEN(" in ")); str->append(tab->table->s->table_name.str, tab->table->s->table_name.length); KEY *key_info= tab->table->key_info+ tab->ref.key; @@ -2408,16 +2410,17 @@ void subselect_uniquesubquery_engine::print(String *str) if (cond) { str->append(STRING_WITH_LEN(" where ")); - cond->print(str); + cond->print(str, query_type); } str->append(')'); } -void subselect_indexsubquery_engine::print(String *str) +void subselect_indexsubquery_engine::print(String *str, + enum_query_type query_type) { str->append(STRING_WITH_LEN("(")); - tab->ref.items[0]->print(str); + tab->ref.items[0]->print(str, query_type); str->append(STRING_WITH_LEN(" in ")); str->append(tab->table->s->table_name.str, tab->table->s->table_name.length); KEY *key_info= tab->table->key_info+ tab->ref.key; @@ -2428,12 +2431,12 @@ void subselect_indexsubquery_engine::print(String *str) if (cond) { str->append(STRING_WITH_LEN(" where ")); - cond->print(str); + cond->print(str, query_type); } if (having) { str->append(STRING_WITH_LEN(" having ")); - having->print(str); + having->print(str, query_type); } str->append(')'); } -- cgit v1.2.1