diff options
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/sql/item.cc b/sql/item.cc index 7599ae6486f..636cefb511b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -90,28 +90,32 @@ bool Item::check_cols(uint c) return 0; } -void Item::set_name(const char *str,uint length, CHARSET_INFO *cs) + +void Item::set_name(const char *str, uint length, CHARSET_INFO *cs) { if (!length) - name= (char*) str; // Empty string, used by AS - else { - while (length && !my_isgraph(cs,*str)) - { // Fix problem with yacc - length--; - str++; - } - if (length && !my_charset_same(cs, system_charset_info)) - { - String tmp; - tmp.copy(str, length, cs, system_charset_info); - name=sql_strmake(tmp.ptr(),min(tmp.length(),MAX_FIELD_WIDTH)); - } - else - name=sql_strmake(str,min(length,MAX_FIELD_WIDTH)); + /* Empty string, used by AS or internal function like last_insert_id() */ + name= (char*) str; + return; + } + while (length && !my_isgraph(cs,*str)) + { // Fix problem with yacc + length--; + str++; } + if (!my_charset_same(cs, system_charset_info)) + { + uint32 res_length; + name= sql_strmake_with_convert(str, length, cs, + MAX_ALIAS_NAME, system_charset_info, + &res_length); + } + else + name=sql_strmake(str, min(length,MAX_ALIAS_NAME)); } + /* This function is only called when comparing items in the WHERE clause */ @@ -1048,13 +1052,6 @@ inline uint char_val(char X) X-'a'+10); } -/* In MySQL 4.1 this will always return STRING_RESULT */ - -enum Item_result Item_varbinary::result_type () const -{ - return (current_thd->variables.new_mode) ? STRING_RESULT : INT_RESULT; -} - Item_varbinary::Item_varbinary(const char *str, uint str_length) { |