Commit c6efa7a8 authored by mysql@home.(none)'s avatar mysql@home.(none)

New function my_charset_same()

parent 5c6c54c0
...@@ -65,6 +65,7 @@ monty@work.mysql.com ...@@ -65,6 +65,7 @@ monty@work.mysql.com
mwagner@cash.mwagner.org mwagner@cash.mwagner.org
mwagner@evoq.mwagner.org mwagner@evoq.mwagner.org
mwagner@work.mysql.com mwagner@work.mysql.com
mysql@home.(none)
nick@mysql.com nick@mysql.com
nick@nick.leippe.com nick@nick.leippe.com
papa@gbichot.local papa@gbichot.local
......
...@@ -199,6 +199,7 @@ extern CHARSET_INFO my_charset_latin1_de; ...@@ -199,6 +199,7 @@ extern CHARSET_INFO my_charset_latin1_de;
extern CHARSET_INFO my_charset_sjis; extern CHARSET_INFO my_charset_sjis;
extern CHARSET_INFO my_charset_tis620; extern CHARSET_INFO my_charset_tis620;
extern CHARSET_INFO my_charset_ucs2; extern CHARSET_INFO my_charset_ucs2;
extern CHARSET_INFO my_charset_ucse;
extern CHARSET_INFO my_charset_ujis; extern CHARSET_INFO my_charset_ujis;
extern CHARSET_INFO my_charset_utf8; extern CHARSET_INFO my_charset_utf8;
extern CHARSET_INFO my_charset_win1250ch; extern CHARSET_INFO my_charset_win1250ch;
......
...@@ -215,6 +215,7 @@ extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, ...@@ -215,6 +215,7 @@ extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
extern void free_charsets(void); extern void free_charsets(void);
extern char *list_charsets(myf want_flags); /* my_free() this string... */ extern char *list_charsets(myf want_flags); /* my_free() this string... */
extern char *get_charsets_dir(char *buf); extern char *get_charsets_dir(char *buf);
extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
/* statistics */ /* statistics */
......
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
- Setting server default character set - Setting server default character set
*/ */
my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2)
{
return ((cs1 == cs2) || !strcmp(cs1->csname,cs2->csname));
}
static void set_max_sort_char(CHARSET_INFO *cs) static void set_max_sort_char(CHARSET_INFO *cs)
{ {
......
...@@ -136,7 +136,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -136,7 +136,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
} }
else if ((*arg)->coercibility < coercibility) else if ((*arg)->coercibility < coercibility)
{ {
if (strcmp(charset()->csname,(*arg)->charset()->csname)) if (!my_charset_same(charset(),(*arg)->charset()))
{ {
set_charset(&my_charset_bin); set_charset(&my_charset_bin);
coercibility= COER_NOCOLL; coercibility= COER_NOCOLL;
......
...@@ -2216,7 +2216,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables, ...@@ -2216,7 +2216,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables,
return 1; return 1;
} }
if (strcmp(args[0]->charset()->csname,set_collation->csname)) if (!my_charset_same(args[0]->charset(),set_collation))
{ {
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
set_collation->name,args[0]->charset()->csname); set_collation->name,args[0]->charset()->csname);
......
...@@ -1284,7 +1284,7 @@ attribute: ...@@ -1284,7 +1284,7 @@ attribute:
| COMMENT_SYM text_literal { Lex->comment= $2; } | COMMENT_SYM text_literal { Lex->comment= $2; }
| COLLATE_SYM collation_name | COLLATE_SYM collation_name
{ {
if (Lex->charset && strcmp(Lex->charset->csname,$2->csname)) if (Lex->charset && !my_charset_same(Lex->charset,$2))
{ {
net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
$2->name,Lex->charset->csname); $2->name,Lex->charset->csname);
...@@ -4250,7 +4250,7 @@ option_value: ...@@ -4250,7 +4250,7 @@ option_value:
CHARSET_INFO *cs= $2 ? $2 : thd->db_charset; CHARSET_INFO *cs= $2 ? $2 : thd->db_charset;
CHARSET_INFO *cl= $3 ? $3 : cs; CHARSET_INFO *cl= $3 ? $3 : cs;
if ((cl != cs) && strcmp(cs->csname,cl->csname)) if (!my_charset_same(cs,cl))
{ {
net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
cl->name,cs->csname); cl->name,cs->csname);
...@@ -4279,7 +4279,7 @@ option_value: ...@@ -4279,7 +4279,7 @@ option_value:
YYABORT; YYABORT;
} }
} }
else if ((cl != cs) && strcmp(cs->csname,cl->csname)) else if (!my_charset_same(cs,cl))
{ {
net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
cl->name,cs->csname); cl->name,cs->csname);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment