diff options
author | unknown <anozdrin/alik@quad.> | 2008-02-22 13:30:33 +0300 |
---|---|---|
committer | unknown <anozdrin/alik@quad.> | 2008-02-22 13:30:33 +0300 |
commit | a3e83048a36b20481155315d1026c6d91da8ecef (patch) | |
tree | 3addb17d5ad1fc4ed36a5cfc04608c6864c99630 /sql/item.cc | |
parent | ffd88cb2bd1bb31a85036a422145b325a36d629e (diff) | |
download | mariadb-git-a3e83048a36b20481155315d1026c6d91da8ecef.tar.gz |
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().
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 98 |
1 files changed, 62 insertions, 36 deletions
diff --git a/sql/item.cc b/sql/item.cc index 10c1c58aea8..f997518ac07 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -442,9 +442,10 @@ uint Item::decimal_precision() const } -void Item::print_item_w_name(String *str) +void Item::print_item_w_name(String *str, enum_query_type query_type) { - print(str); + print(str, query_type); + if (name) { THD *thd= current_thd; @@ -1128,7 +1129,7 @@ Item_splocal::this_item_addr(THD *thd, Item **) } -void Item_splocal::print(String *str) +void Item_splocal::print(String *str, enum_query_type) { str->reserve(m_name.length+8); str->append(m_name.str, m_name.length); @@ -1182,7 +1183,7 @@ Item_case_expr::this_item_addr(THD *thd, Item **) } -void Item_case_expr::print(String *str) +void Item_case_expr::print(String *str, enum_query_type) { if (str->reserve(MAX_INT_WIDTH + sizeof("case_expr@"))) return; /* purecov: inspected */ @@ -1276,12 +1277,12 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref) } -void Item_name_const::print(String *str) +void Item_name_const::print(String *str, enum_query_type query_type) { str->append(STRING_WITH_LEN("NAME_CONST(")); - name_item->print(str); + name_item->print(str, query_type); str->append(','); - value_item->print(str); + value_item->print(str, query_type); str->append(')'); } @@ -1298,12 +1299,12 @@ public: const char *table_name_arg, const char *field_name_arg) :Item_ref(context_arg, item, table_name_arg, field_name_arg) {} - void print (String *str) + virtual inline void print (String *str, enum_query_type query_type) { if (ref) - (*ref)->print(str); + (*ref)->print(str, query_type); else - Item_ident::print(str); + Item_ident::print(str, query_type); } }; @@ -1455,7 +1456,9 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) set(dt); } else - ; // Do nothing + { + // Do nothing + } } else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && left_is_superset(this, &dt)) @@ -1872,7 +1875,7 @@ const char *Item_ident::full_name() const return tmp; } -void Item_ident::print(String *str) +void Item_ident::print(String *str, enum_query_type query_type) { THD *thd= current_thd; char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME]; @@ -2134,7 +2137,7 @@ String *Item_int::val_str(String *str) return str; } -void Item_int::print(String *str) +void Item_int::print(String *str, enum_query_type query_type) { // my_charset_bin is good enough for numbers str_value.set(value, &my_charset_bin); @@ -2165,7 +2168,7 @@ String *Item_uint::val_str(String *str) } -void Item_uint::print(String *str) +void Item_uint::print(String *str, enum_query_type query_type) { // latin1 is good enough for numbers str_value.set((ulonglong) value, default_charset()); @@ -2257,7 +2260,7 @@ String *Item_decimal::val_str(String *result) return result; } -void Item_decimal::print(String *str) +void Item_decimal::print(String *str, enum_query_type query_type) { my_decimal2string(E_DEC_FATAL_ERROR, &decimal_value, 0, 0, 0, &str_value); str->append(str_value); @@ -2310,16 +2313,39 @@ my_decimal *Item_float::val_decimal(my_decimal *decimal_value) } -void Item_string::print(String *str) +void Item_string::print(String *str, enum_query_type query_type) { - if (is_cs_specified()) + if (query_type == QT_ORDINARY && is_cs_specified()) { str->append('_'); str->append(collation.collation->csname); } str->append('\''); - str_value.print(str); + + if (query_type == QT_ORDINARY || + my_charset_same(str_value.charset(), system_charset_info)) + { + str_value.print(str); + } + else + { + THD *thd= current_thd; + LEX_STRING utf8_lex_str; + + thd->convert_string(&utf8_lex_str, + system_charset_info, + str_value.c_ptr_safe(), + str_value.length(), + str_value.charset()); + + String utf8_str(utf8_lex_str.str, + utf8_lex_str.length, + system_charset_info); + + utf8_str.print(str); + } + str->append('\''); } @@ -3086,7 +3112,7 @@ Item_param::eq(const Item *arg, bool binary_cmp) const /* End of Item_param related */ -void Item_param::print(String *str) +void Item_param::print(String *str, enum_query_type query_type) { if (state == NO_VALUE) { @@ -4799,7 +4825,7 @@ int Item_float::save_in_field(Field *field, bool no_conversions) } -void Item_float::print(String *str) +void Item_float::print(String *str, enum_query_type query_type) { if (presentation) { @@ -4917,7 +4943,7 @@ warn: } -void Item_hex_string::print(String *str) +void Item_hex_string::print(String *str, enum_query_type query_type) { char *end= (char*) str_value.ptr() + str_value.length(), *ptr= end - min(str_value.length(), sizeof(longlong)); @@ -5179,7 +5205,7 @@ Item *Item_field::update_value_transformer(uchar *select_arg) } -void Item_field::print(String *str) +void Item_field::print(String *str, enum_query_type query_type) { if (field && field->table->const_table) { @@ -5191,7 +5217,7 @@ void Item_field::print(String *str) str->append('\''); return; } - Item_ident::print(str); + Item_ident::print(str, query_type); } @@ -5531,7 +5557,7 @@ void Item_ref::cleanup() } -void Item_ref::print(String *str) +void Item_ref::print(String *str, enum_query_type query_type) { if (ref) { @@ -5542,10 +5568,10 @@ void Item_ref::print(String *str) append_identifier(thd, str, name, (uint) strlen(name)); } else - (*ref)->print(str); + (*ref)->print(str, query_type); } else - Item_ident::print(str); + Item_ident::print(str, query_type); } @@ -5735,11 +5761,11 @@ Item *Item_ref::get_tmp_table_item(THD *thd) } -void Item_ref_null_helper::print(String *str) +void Item_ref_null_helper::print(String *str, enum_query_type query_type) { str->append(STRING_WITH_LEN("<ref_null_helper>(")); if (ref) - (*ref)->print(str); + (*ref)->print(str, query_type); else str->append('?'); str->append(')'); @@ -5931,7 +5957,7 @@ error: } -void Item_default_value::print(String *str) +void Item_default_value::print(String *str, enum_query_type query_type) { if (!arg) { @@ -5939,7 +5965,7 @@ void Item_default_value::print(String *str) return; } str->append(STRING_WITH_LEN("default(")); - arg->print(str); + arg->print(str, query_type); str->append(')'); } @@ -6075,10 +6101,10 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items) return FALSE; } -void Item_insert_value::print(String *str) +void Item_insert_value::print(String *str, enum_query_type query_type) { str->append(STRING_WITH_LEN("values(")); - arg->print(str); + arg->print(str, query_type); str->append(')'); } @@ -6199,7 +6225,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items) } -void Item_trigger_field::print(String *str) +void Item_trigger_field::print(String *str, enum_query_type query_type) { str->append((row_version == NEW_ROW) ? "NEW" : "OLD", 3); str->append('.'); @@ -6389,13 +6415,13 @@ Item_cache* Item_cache::get_cache(const Item *item) } -void Item_cache::print(String *str) +void Item_cache::print(String *str, enum_query_type query_type) { str->append(STRING_WITH_LEN("<cache>(")); if (example) - example->print(str); + example->print(str, query_type); else - Item::print(str); + Item::print(str, query_type); str->append(')'); } |