diff options
-rw-r--r-- | include/my_sys.h | 1 | ||||
-rw-r--r-- | sql/item.cc | 16 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 16 | ||||
-rw-r--r-- | sql/mysql_priv.h | 4 | ||||
-rw-r--r-- | sql/sql_string.cc | 3 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 15 |
6 files changed, 40 insertions, 15 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index 18d6115c75a..03a0ae70d6a 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -203,7 +203,6 @@ extern int (*fatal_error_handler_hook)(uint my_err, const char *str, /* charsets */ extern CHARSET_INFO *default_charset_info; -extern CHARSET_INFO *system_charset_info; extern CHARSET_INFO *all_charsets[256]; extern CHARSET_INFO compiled_charsets[]; diff --git a/sql/item.cc b/sql/item.cc index aed0a823603..b4d2d0670d8 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -199,10 +199,17 @@ bool Item::set_charset(CHARSET_INFO *cs1, enum coercion co1, { if (cs1 != cs2) { - CHARSET_INFO *bin= get_charset_by_csname(cs1->csname, MY_CS_BINSORT,MYF(0)); - if (!bin) - return 1; - set_charset(bin, COER_NOCOLL); + if (co1 == COER_EXPLICIT) + { + return 1; + } + else + { + CHARSET_INFO *bin= get_charset_by_csname(cs1->csname, MY_CS_BINSORT,MYF(0)); + if (!bin) + return 1; + set_charset(bin, COER_NOCOLL); + } } else set_charset(cs2, co2); @@ -987,6 +994,7 @@ Item_varbinary::Item_varbinary(const char *str, uint str_length) str+=2; } *ptr=0; // Keep purify happy + coercibility= COER_COERCIBLE; } longlong Item_varbinary::val_int() diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index da63e3bbf4b..ff6f4022877 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -111,7 +111,21 @@ bool Item_bool_func2::set_cmp_charset(CHARSET_INFO *cs1, enum coercion co1, if (cs1 == cs2) cmp_charset= cs1; else - return 1; + { + if (co1 == COER_COERCIBLE) + { + CHARSET_INFO *c= get_charset_by_csname(cs1->csname,MY_CS_PRIMARY,MYF(0)); + if (c) + { + cmp_charset= c; + return 0; + } + else + return 1; + } + else + return 1; + } } return 0; } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 61c5d308b4e..f68de23034a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -62,7 +62,9 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); #endif #endif -#define files_charset_info system_charset_info +extern CHARSET_INFO *system_charset_info; +extern CHARSET_INFO *files_charset_info; +extern CHARSET_INFO *national_charset_info; /*************************************************************************** Configuration parameters diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 54a76319be7..ffa272713de 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -29,6 +29,9 @@ #endif CHARSET_INFO *system_charset_info= &my_charset_utf8; +CHARSET_INFO *files_charset_info= &my_charset_utf8; +CHARSET_INFO *national_charset_info= &my_charset_utf8; + extern gptr sql_alloc(unsigned size); extern void sql_element_free(void *ptr); static uint32 diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 428af27ed3f..ce1a3dc10cd 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1134,10 +1134,10 @@ type: $$=FIELD_TYPE_STRING; } | nchar '(' NUM ')' { Lex->length=$3.str; $$=FIELD_TYPE_STRING; - Lex->charset=&my_charset_utf8; } + Lex->charset=national_charset_info; } | nchar { Lex->length=(char*) "1"; $$=FIELD_TYPE_STRING; - Lex->charset=&my_charset_utf8; } + Lex->charset=national_charset_info; } | BINARY '(' NUM ')' { Lex->length=$3.str; Lex->charset=&my_charset_bin; $$=FIELD_TYPE_STRING; } @@ -1145,7 +1145,7 @@ type: $$=FIELD_TYPE_VAR_STRING; } | nvarchar '(' NUM ')' { Lex->length=$3.str; $$=FIELD_TYPE_VAR_STRING; - Lex->charset= &my_charset_utf8; } + Lex->charset=national_charset_info; } | VARBINARY '(' NUM ')' { Lex->length=$3.str; Lex->charset=&my_charset_bin; $$=FIELD_TYPE_VAR_STRING; } @@ -3865,9 +3865,9 @@ text_literal: $$ = new Item_string($1.str,$1.length,cs); } | NCHAR_STRING - { $$= new Item_string($1.str,$1.length,&my_charset_utf8); } + { $$= new Item_string($1.str,$1.length,national_charset_info); } | UNDERSCORE_CHARSET TEXT_STRING - { $$ = new Item_string($2.str,$2.length,Lex->charset,Item::COER_IMPLICIT); } + { $$ = new Item_string($2.str,$2.length,Lex->charset); } | text_literal TEXT_STRING_db { ((Item_string*) $1)->append($2.str,$2.length); } ; @@ -3913,9 +3913,8 @@ literal: { Item *tmp= new Item_varbinary($2.str,$2.length); String *str= tmp ? tmp->val_str((String*) 0) : (String*) 0; - $$ = new Item_string(str ? str->ptr() : "", - str ? str->length() : 0, - Lex->charset,Item::COER_IMPLICIT); + $$ = new Item_string(str ? str->ptr() : "", str ? str->length() : 0, + Lex->charset); } | DATE_SYM text_literal { $$ = $2; } | TIME_SYM text_literal { $$ = $2; } |