diff options
author | unknown <bar@bar.mysql.r18.ru> | 2003-09-17 16:22:58 +0500 |
---|---|---|
committer | unknown <bar@bar.mysql.r18.ru> | 2003-09-17 16:22:58 +0500 |
commit | 34fc9b2b568ee9cac49f208d6b046f60907ec544 (patch) | |
tree | 298ca40ac1fef653ffff869aec7c52ecfd043b43 | |
parent | abd0afa368e259da0d63d13bfdc6c0ded1f3edd5 (diff) | |
download | mariadb-git-34fc9b2b568ee9cac49f208d6b046f60907ec544.tar.gz |
Charset number is now stored into error.sys by comp_err and loaded by mysqld.
-rw-r--r-- | extra/comp_err.c | 14 | ||||
-rw-r--r-- | include/my_sys.h | 4 | ||||
-rw-r--r-- | mysys/charset.c | 39 | ||||
-rw-r--r-- | sql/derror.cc | 11 | ||||
-rw-r--r-- | sql/share/Makefile.am | 2 |
5 files changed, 49 insertions, 21 deletions
diff --git a/extra/comp_err.c b/extra/comp_err.c index 175dc246f5f..2ec4240392f 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -42,11 +42,12 @@ static int copy_rows(FILE *to); int main(int argc,char *argv[]) { + uint csnum= 0; int i,error,files,length; uchar head[32]; FILE *from,*to; MY_INIT(argv[0]); - + get_options(&argc,&argv); error=1; row_count=files=0; @@ -70,6 +71,13 @@ int main(int argc,char *argv[]) goto end; } + 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; + } + if (remember_rows(from,'}') < 0) /* Remember rows */ { fprintf(stderr,"Can't find textrows in '%s'\n",*argv); @@ -100,7 +108,8 @@ int main(int argc,char *argv[]) { int2store(head+10+i+i,file_row_pos[i]); } - + head[30]= csnum; + fseek(to,0l,0); if (fwrite(head,1,32,to) != 32) goto end; @@ -144,7 +153,6 @@ static void get_options(register int *argc,register char **argv[]) printf("%s (Compile errormessage) Ver 1.3\n",progname); break; case 'C': - printf("pos=%s\n", pos+1); charsets_dir= pos+1; *(pos--)= '\0'; break; diff --git a/include/my_sys.h b/include/my_sys.h index 47a039baddd..6f04b766aec 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -209,8 +209,10 @@ extern CHARSET_INFO *default_charset_info; extern CHARSET_INFO *all_charsets[256]; extern CHARSET_INFO compiled_charsets[]; -extern uint get_charset_number(const char *cs_name); +extern uint get_charset_number(const char *cs_name, uint cs_flags); +extern uint get_collation_number(const char *name); extern const char *get_charset_name(uint cs_number); + extern CHARSET_INFO *get_charset(uint cs_number, myf flags); extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags); extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, diff --git a/mysys/charset.c b/mysys/charset.c index 7a82f8780a0..58ce8f5b2fe 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -278,7 +278,7 @@ static my_bool simple_cs_is_full(CHARSET_INFO *cs) static int add_collation(CHARSET_INFO *cs) { - if (cs->name && (cs->number || (cs->number=get_charset_number(cs->name)))) + if (cs->name && (cs->number || (cs->number=get_collation_number(cs->name)))) { if (!all_charsets[cs->number]) { @@ -513,7 +513,7 @@ void free_charsets(void) } -uint get_charset_number(const char *charset_name) +uint get_collation_number(const char *name) { CHARSET_INFO **cs; if (init_available_charsets(MYF(0))) /* If it isn't initialized */ @@ -522,12 +522,27 @@ uint get_charset_number(const char *charset_name) for (cs= all_charsets; cs < all_charsets+255; ++cs) { if ( cs[0] && cs[0]->name && - !my_strcasecmp(&my_charset_latin1, cs[0]->name, charset_name)) + !my_strcasecmp(&my_charset_latin1, cs[0]->name, name)) return cs[0]->number; } return 0; /* this mimics find_type() */ } +uint get_charset_number(const char *charset_name, uint cs_flags) +{ + CHARSET_INFO **cs; + if (init_available_charsets(MYF(0))) /* If it isn't initialized */ + return 0; + + for (cs= all_charsets; cs < all_charsets+255; ++cs) + { + if ( cs[0] && cs[0]->csname && (cs[0]->state & cs_flags) && + !my_strcasecmp(&my_charset_latin1, cs[0]->csname, charset_name)) + return cs[0]->number; + } + return 0; +} + const char *get_charset_name(uint charset_number) { @@ -593,7 +608,7 @@ CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags) CHARSET_INFO *cs; (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ - cs_number=get_charset_number(cs_name); + cs_number=get_collation_number(cs_name); cs= cs_number ? get_internal_charset(cs_number,flags) : NULL; if (!cs && (flags & MY_WME)) @@ -611,23 +626,15 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name, uint cs_flags, myf flags) { - CHARSET_INFO *cs=NULL; - CHARSET_INFO **css; + uint cs_number; + CHARSET_INFO *cs; DBUG_ENTER("get_charset_by_csname"); DBUG_PRINT("enter",("name: '%s'", cs_name)); (void) init_available_charsets(MYF(0)); /* If it isn't initialized */ - for (css= all_charsets; css < all_charsets+255; ++css) - { - if ( css[0] && (css[0]->state & cs_flags) && - css[0]->csname && !my_strcasecmp(&my_charset_latin1, - css[0]->csname, cs_name)) - { - cs= css[0]->number ? get_internal_charset(css[0]->number,flags) : NULL; - break; - } - } + cs_number= get_charset_number(cs_name, cs_flags); + cs= cs_number ? get_internal_charset(cs_number, flags) : NULL; if (!cs && (flags & MY_WME)) { diff --git a/sql/derror.cc b/sql/derror.cc index 7ebe6e4b3c5..1a98b9ce371 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -49,6 +49,7 @@ static void read_texts(const char *file_name,const char ***point, char name[FN_REFLEN]; const char *buff; uchar head[32],*pos; + CHARSET_INFO *cset; DBUG_ENTER("read_texts"); *point=0; // If something goes wrong @@ -65,6 +66,13 @@ static void read_texts(const char *file_name,const char ***point, head[2] != 2 || head[3] != 1) goto err; /* purecov: inspected */ textcount=head[4]; + + if (!(cset= get_charset(head[30],MYF(MY_WME)))) + { + funktpos= 3; + goto err; + } + length=uint2korr(head+6); count=uint2korr(head+8); if (count < error_messages) @@ -104,6 +112,9 @@ 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; diff --git a/sql/share/Makefile.am b/sql/share/Makefile.am index 35202ff4722..662159a9c63 100644 --- a/sql/share/Makefile.am +++ b/sql/share/Makefile.am @@ -30,7 +30,7 @@ install-data-local: fix_errors: for lang in @AVAILABLE_LANGUAGES@; \ do \ - ../../extra/comp_err $(srcdir)/$$lang/errmsg.txt $(srcdir)/$$lang/errmsg.sys; \ + ../../extra/comp_err -C$(srcdir)/charsets/ $(srcdir)/$$lang/errmsg.txt $(srcdir)/$$lang/errmsg.sys; \ done # Don't update the files from bitkeeper |