summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extra/comp_err.c2
-rw-r--r--include/m_ctype.h1
-rw-r--r--mysys/charset.c68
-rw-r--r--sql/derror.cc18
-rw-r--r--sql/sql_show.cc14
5 files changed, 57 insertions, 46 deletions
diff --git a/extra/comp_err.c b/extra/comp_err.c
index 1803b93ff8c..07369aa565e 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -71,14 +71,12 @@ int main(int argc,char *argv[])
goto end;
}
-#ifdef NEEDS_FIXES
if (!(csnum= get_charset_number(charset_name, MY_CS_PRIMARY)))
{
fprintf(stderr,"Unknown character '%s' in '%s'\n",charset_name, *argv);
fclose(from);
goto end;
}
-#endif
if (remember_rows(from,'}') < 0) /* Remember rows */
{
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 603bb3cc2e5..a15fe3097cc 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -63,6 +63,7 @@ typedef struct unicase_info_st
#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */
#define MY_CS_UNICODE 128 /* is a charset is full unicode */
#define MY_CS_NONTEXT 256 /* if a charset is not sprintf() compatible */
+#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
#define MY_CHARSET_UNDEFINED 0
diff --git a/mysys/charset.c b/mysys/charset.c
index e8406173b33..a485835b636 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -226,7 +226,6 @@ static my_bool create_fromuni(CHARSET_INFO *cs)
static void simple_cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from)
{
to->number= from->number ? from->number : to->number;
- to->state|= from->state;
if (from->csname)
to->csname= my_once_strdup(from->csname,MYF(MY_WME));
@@ -282,8 +281,6 @@ static int add_collation(CHARSET_INFO *cs)
{
if (!all_charsets[cs->number])
{
- if (cs->state & MY_CS_COMPILED)
- goto clear;
if (!(all_charsets[cs->number]=
(CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),MYF(0))))
return MY_XML_ERROR;
@@ -296,6 +293,8 @@ static int add_collation(CHARSET_INFO *cs)
if (cs->binary_number == cs->number)
cs->state |= MY_CS_BINSORT;
+ all_charsets[cs->number]->state|= cs->state;
+
if (!(all_charsets[cs->number]->state & MY_CS_COMPILED))
{
simple_cs_init_functions(all_charsets[cs->number]);
@@ -304,15 +303,14 @@ static int add_collation(CHARSET_INFO *cs)
{
all_charsets[cs->number]->state |= MY_CS_LOADED;
}
+ all_charsets[cs->number]->state|= MY_CS_AVAILABLE;
}
else
{
CHARSET_INFO *dst= all_charsets[cs->number];
- dst->state |= cs->state;
if (cs->comment)
dst->comment= my_once_strdup(cs->comment,MYF(MY_WME));
}
-clear:
cs->number= 0;
cs->primary_number= 0;
cs->binary_number= 0;
@@ -389,77 +387,79 @@ char *get_charsets_dir(char *buf)
CHARSET_INFO *all_charsets[256];
CHARSET_INFO *default_charset_info = &my_charset_latin1;
-#define MY_ADD_CHARSET(x) all_charsets[(x)->number]=(x)
+static void add_compiled_collation(CHARSET_INFO *cs)
+{
+ all_charsets[cs->number]= cs;
+ cs->state|= MY_CS_AVAILABLE;
+}
static my_bool init_compiled_charsets(myf flags __attribute__((unused)))
{
CHARSET_INFO *cs;
- MY_ADD_CHARSET(&my_charset_bin);
+ add_compiled_collation(&my_charset_bin);
- MY_ADD_CHARSET(&my_charset_latin1);
- MY_ADD_CHARSET(&my_charset_latin1_bin);
- MY_ADD_CHARSET(&my_charset_latin1_german2_ci);
+ add_compiled_collation(&my_charset_latin1);
+ add_compiled_collation(&my_charset_latin1_bin);
+ add_compiled_collation(&my_charset_latin1_german2_ci);
#ifdef HAVE_CHARSET_big5
- MY_ADD_CHARSET(&my_charset_big5_chinese_ci);
- MY_ADD_CHARSET(&my_charset_big5_bin);
+ add_compiled_collation(&my_charset_big5_chinese_ci);
+ add_compiled_collation(&my_charset_big5_bin);
#endif
#ifdef HAVE_CHARSET_cp1250
- MY_ADD_CHARSET(&my_charset_cp1250_czech_ci);
+ add_compiled_collation(&my_charset_cp1250_czech_ci);
#endif
#ifdef HAVE_CHARSET_latin2
- MY_ADD_CHARSET(&my_charset_latin2_czech_ci);
+ add_compiled_collation(&my_charset_latin2_czech_ci);
#endif
#ifdef HAVE_CHARSET_euckr
- MY_ADD_CHARSET(&my_charset_euckr_korean_ci);
- MY_ADD_CHARSET(&my_charset_euckr_bin);
+ add_compiled_collation(&my_charset_euckr_korean_ci);
+ add_compiled_collation(&my_charset_euckr_bin);
#endif
#ifdef HAVE_CHARSET_gb2312
- MY_ADD_CHARSET(&my_charset_gb2312_chinese_ci);
- MY_ADD_CHARSET(&my_charset_gb2312_bin);
+ add_compiled_collation(&my_charset_gb2312_chinese_ci);
+ add_compiled_collation(&my_charset_gb2312_bin);
#endif
#ifdef HAVE_CHARSET_gbk
- MY_ADD_CHARSET(&my_charset_gbk_chinese_ci);
- MY_ADD_CHARSET(&my_charset_gbk_bin);
+ add_compiled_collation(&my_charset_gbk_chinese_ci);
+ add_compiled_collation(&my_charset_gbk_bin);
#endif
#ifdef HAVE_CHARSET_sjis
- MY_ADD_CHARSET(&my_charset_sjis_japanese_ci);
- MY_ADD_CHARSET(&my_charset_sjis_bin);
+ add_compiled_collation(&my_charset_sjis_japanese_ci);
+ add_compiled_collation(&my_charset_sjis_bin);
#endif
#ifdef HAVE_CHARSET_tis620
- MY_ADD_CHARSET(&my_charset_tis620_thai_ci);
- MY_ADD_CHARSET(&my_charset_tis620_bin);
+ add_compiled_collation(&my_charset_tis620_thai_ci);
+ add_compiled_collation(&my_charset_tis620_bin);
#endif
#ifdef HAVE_CHARSET_ucs2
- MY_ADD_CHARSET(&my_charset_ucs2_general_ci);
- MY_ADD_CHARSET(&my_charset_ucs2_bin);
+ add_compiled_collation(&my_charset_ucs2_general_ci);
+ add_compiled_collation(&my_charset_ucs2_bin);
#endif
#ifdef HAVE_CHARSET_ujis
- MY_ADD_CHARSET(&my_charset_ujis_japanese_ci);
- MY_ADD_CHARSET(&my_charset_ujis_bin);
+ add_compiled_collation(&my_charset_ujis_japanese_ci);
+ add_compiled_collation(&my_charset_ujis_bin);
#endif
#ifdef HAVE_CHARSET_utf8
- MY_ADD_CHARSET(&my_charset_utf8_general_ci);
- MY_ADD_CHARSET(&my_charset_utf8_bin);
+ add_compiled_collation(&my_charset_utf8_general_ci);
+ add_compiled_collation(&my_charset_utf8_bin);
#endif
/* Copy compiled charsets */
for (cs=compiled_charsets; cs->name; cs++)
- {
- all_charsets[cs->number]=cs;
- }
+ add_compiled_collation(cs);
return FALSE;
}
@@ -570,7 +570,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
cs= all_charsets[cs_number];
- if (cs && !(cs->state & (MY_CS_COMPILED | MY_CS_LOADED)))
+ if (cs && !(cs->state & MY_CS_COMPILED) && !(cs->state & MY_CS_LOADED))
{
strxmov(get_charsets_dir(buf), cs->csname, ".xml", NullS);
my_read_charset_file(buf,flags);
diff --git a/sql/derror.cc b/sql/derror.cc
index 1a98b9ce371..a35893be4fc 100644
--- a/sql/derror.cc
+++ b/sql/derror.cc
@@ -67,10 +67,18 @@ static void read_texts(const char *file_name,const char ***point,
goto err; /* purecov: inspected */
textcount=head[4];
+ if (!head[30])
+ {
+ sql_print_error("No character set information in '%s'. \
+You probably haven't reinstalled the latest file version.",name);
+ goto err1;
+ }
+
if (!(cset= get_charset(head[30],MYF(MY_WME))))
{
- funktpos= 3;
- goto err;
+ sql_print_error("Character set #%d is not supported for messagefile '%s'",
+ (int)head[30],name);
+ goto err1;
}
length=uint2korr(head+6); count=uint2korr(head+8);
@@ -112,9 +120,6 @@ Check that the above file is the right version for this program!",
err:
switch (funktpos) {
- case 3:
- buff="Character set is not supported for messagefile '%s'";
- break;
case 2:
buff="Not enough memory for messagefile '%s'";
break;
@@ -125,9 +130,10 @@ err:
buff="Can't find messagefile '%s'";
break;
}
+ sql_print_error(buff,name);
+err1:
if (file != FERR)
VOID(my_close(file,MYF(MY_WME)));
- sql_print_error(buff,name);
unireg_abort(1);
} /* read_texts */
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 8ea78e702e5..8ed4d6d7324 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1497,11 +1497,15 @@ int mysqld_show_collations(THD *thd, const char *wild)
for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ )
{
CHARSET_INFO **cl;
+ if (!cs[0] || !(cs[0]->state & MY_CS_AVAILABLE) ||
+ !(cs[0]->state & MY_CS_PRIMARY))
+ continue;
for ( cl= all_charsets; cl < all_charsets+255 ;cl ++)
{
- if (!cs[0] || !cl[0] || !my_charset_same(cs[0],cl[0]) || !(cs[0]->state & MY_CS_PRIMARY))
+ if (!cl[0] || !(cl[0]->state & MY_CS_AVAILABLE) ||
+ !my_charset_same(cs[0],cl[0]))
continue;
- if (cs[0] && !(wild && wild[0] &&
+ if (!(wild && wild[0] &&
wild_case_compare(system_charset_info,cl[0]->name,wild)))
{
if (write_collation(protocol, cl[0]))
@@ -1545,8 +1549,10 @@ int mysqld_show_charsets(THD *thd, const char *wild)
for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ )
{
- if (cs[0] && (cs[0]->state & MY_CS_PRIMARY) && !(wild && wild[0] &&
- wild_case_compare(system_charset_info,cs[0]->name,wild)))
+ if (cs[0] && (cs[0]->state & MY_CS_PRIMARY) &&
+ (cs[0]->state & MY_CS_AVAILABLE) &&
+ !(wild && wild[0] &&
+ wild_case_compare(system_charset_info,cs[0]->csname,wild)))
{
if (write_charset(protocol, cs[0]))
goto err;