Some changes to separate charset and collation terms

This commit is contained in:
bar@bar.mysql.r18.ru 2003-01-04 14:12:20 +04:00
parent 259b79beac
commit a172e5ad2a
17 changed files with 76 additions and 10 deletions

View File

@ -49,6 +49,7 @@ typedef struct unicase_info_st {
#define MY_CS_INDEX 4 /* sets listed in the Index file */ #define MY_CS_INDEX 4 /* sets listed in the Index file */
#define MY_CS_LOADED 8 /* sets that are currently loaded */ #define MY_CS_LOADED 8 /* sets that are currently loaded */
#define MY_CS_BINSORT 16 /* if binary sort order */ #define MY_CS_BINSORT 16 /* if binary sort order */
#define MY_CS_PRIMARY 32 /* if primary collation */
#define MY_CHARSET_UNDEFINED 0 #define MY_CHARSET_UNDEFINED 0
#define MY_CHARSET_CURRENT (default_charset_info->number) #define MY_CHARSET_CURRENT (default_charset_info->number)
@ -65,6 +66,7 @@ typedef struct charset_info_st
{ {
uint number; uint number;
uint state; uint state;
const char *csname;
const char *name; const char *name;
const char *comment; const char *comment;
uchar *ctype; uchar *ctype;
@ -127,6 +129,7 @@ typedef struct charset_info_st
int (*l10tostr)(struct charset_info_st *, char *to, uint n, int radix, long int val); int (*l10tostr)(struct charset_info_st *, char *to, uint n, int radix, long int val);
int (*ll10tostr)(struct charset_info_st *, char *to, uint n, int radix, longlong val); int (*ll10tostr)(struct charset_info_st *, char *to, uint n, int radix, longlong val);
/* String-to-number convertion routines */
long (*strntol)(struct charset_info_st *, const char *s, uint l,char **e, int base); long (*strntol)(struct charset_info_st *, const char *s, uint l,char **e, int base);
ulong (*strntoul)(struct charset_info_st *, const char *s, uint l, char **e, int base); ulong (*strntoul)(struct charset_info_st *, const char *s, uint l, char **e, int base);
longlong (*strntoll)(struct charset_info_st *, const char *s, uint l, char **e, int base); longlong (*strntoll)(struct charset_info_st *, const char *s, uint l, char **e, int base);

View File

@ -165,8 +165,11 @@ static int cs_leave(MY_XML_PARSER *st,const char *attr, uint len)
{ {
struct my_cs_file_info *i = (struct my_cs_file_info *)st->user_data; struct my_cs_file_info *i = (struct my_cs_file_info *)st->user_data;
struct my_cs_file_section_st *s = cs_file_sec(attr,len); struct my_cs_file_section_st *s = cs_file_sec(attr,len);
int state = s ? s->state : 0;
if (s && (s->state == _CS_COLLATION) && !all_charsets[i->cs.number]) if (state == _CS_COLLATION)
{
if (!all_charsets[i->cs.number])
{ {
if (!(all_charsets[i->cs.number]= if (!(all_charsets[i->cs.number]=
(CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),i->myflags))) (CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),i->myflags)))
@ -175,6 +178,12 @@ static int cs_leave(MY_XML_PARSER *st,const char *attr, uint len)
} }
all_charsets[i->cs.number][0]=i->cs; all_charsets[i->cs.number][0]=i->cs;
} }
else
{
all_charsets[i->cs.number]->state |= i->cs.state;
}
i->cs.state=0;
}
return MY_XML_OK; return MY_XML_OK;
} }
@ -203,6 +212,16 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, uint len)
((char*)(i->cs.name))[len]='\0'; ((char*)(i->cs.name))[len]='\0';
} }
break; break;
case _CS_NAME:
if ((i->cs.csname = (char*) my_once_alloc(len+1,i->myflags)))
{
memcpy((char*)i->cs.csname,attr,len);
((char*)(i->cs.csname))[len]='\0';
}
break;
case _CS_FLAG:
if (!strncmp("primary",attr,len))
i->cs.state |= MY_CS_PRIMARY;
} }
return MY_XML_OK; return MY_XML_OK;
} }

View File

@ -1362,10 +1362,14 @@ int mysqld_show_charsets(THD *thd, const char *wild)
List<Item> field_list; List<Item> field_list;
CHARSET_INFO **cs; CHARSET_INFO **cs;
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
char flags[64];
DBUG_ENTER("mysqld_show_charsets"); DBUG_ENTER("mysqld_show_charsets");
field_list.push_back(new Item_empty_string("Name",30)); field_list.push_back(new Item_empty_string("CS_Name",30));
field_list.push_back(new Item_empty_string("COL_Name",30));
field_list.push_back(new Item_return_int("Id",11, FIELD_TYPE_SHORT)); field_list.push_back(new Item_return_int("Id",11, FIELD_TYPE_SHORT));
field_list.push_back(new Item_empty_string("Flags",30));
field_list.push_back(new Item_return_int("strx_maxlen",3, FIELD_TYPE_TINY)); field_list.push_back(new Item_return_int("strx_maxlen",3, FIELD_TYPE_TINY));
field_list.push_back(new Item_return_int("mb_maxlen",3, FIELD_TYPE_TINY)); field_list.push_back(new Item_return_int("mb_maxlen",3, FIELD_TYPE_TINY));
@ -1374,14 +1378,17 @@ int mysqld_show_charsets(THD *thd, const char *wild)
for (cs=all_charsets ; cs < all_charsets+255 ; cs++ ) for (cs=all_charsets ; cs < all_charsets+255 ; cs++ )
{ {
if (!cs[0]) if (cs[0] && !(wild && wild[0] &&
continue;
if (!(wild && wild[0] &&
wild_case_compare(system_charset_info,cs[0]->name,wild))) wild_case_compare(system_charset_info,cs[0]->name,wild)))
{ {
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(cs[0]->csname);
protocol->store(cs[0]->name); protocol->store(cs[0]->name);
protocol->store_short((longlong) cs[0]->number); protocol->store_short((longlong) cs[0]->number);
flags[0]='\0';
if (cs[0]->state & MY_CS_PRIMARY)
strcat(flags,"pri");
protocol->store(flags);
protocol->store_tiny((longlong) cs[0]->strxfrm_multiply); protocol->store_tiny((longlong) cs[0]->strxfrm_multiply);
protocol->store_tiny((longlong) cs[0]->mbmaxlen); protocol->store_tiny((longlong) cs[0]->mbmaxlen);
if (protocol->write()) if (protocol->write())

View File

@ -6219,6 +6219,7 @@ CHARSET_INFO my_charset_big5 =
{ {
1, /* number */ 1, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"big5", /* cs name */
"big5", /* name */ "big5", /* name */
"", /* comment */ "", /* comment */
ctype_big5, ctype_big5,

View File

@ -260,6 +260,7 @@ static CHARSET_INFO my_charset_bin_st =
{ {
63, /* number */ 63, /* number */
MY_CS_COMPILED|MY_CS_BINSORT,/* state */ MY_CS_COMPILED|MY_CS_BINSORT,/* state */
"binary", /* cs name */
"binary", /* name */ "binary", /* name */
"", /* comment */ "", /* comment */
ctype_bin, /* ctype */ ctype_bin, /* ctype */

View File

@ -597,6 +597,7 @@ CHARSET_INFO my_charset_czech =
{ {
2, /* number */ 2, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin2", /* cs name */
"czech", /* name */ "czech", /* name */
"", /* comment */ "", /* comment */
ctype_czech, ctype_czech,

View File

@ -8637,6 +8637,7 @@ CHARSET_INFO my_charset_euc_kr =
{ {
19, /* number */ 19, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"euc_kr", /* cs name */
"euc_kr", /* name */ "euc_kr", /* name */
"", /* comment */ "", /* comment */
ctype_euc_kr, ctype_euc_kr,

View File

@ -5687,6 +5687,7 @@ CHARSET_INFO my_charset_gb2312 =
{ {
24, /* number */ 24, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"gb2312", /* cs name */
"gb2312", /* name */ "gb2312", /* name */
"", /* comment */ "", /* comment */
ctype_gb2312, ctype_gb2312,

View File

@ -9874,6 +9874,7 @@ CHARSET_INFO my_charset_gbk =
{ {
28, /* number */ 28, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"gbk", /* cs name */
"gbk", /* name */ "gbk", /* name */
"", /* comment */ "", /* comment */
ctype_gbk, ctype_gbk,

View File

@ -415,6 +415,7 @@ CHARSET_INFO my_charset_latin1_de =
{ {
31, /* number */ 31, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin1", /* cs name */
"latin1_de", /* name */ "latin1_de", /* name */
"", /* comment */ "", /* comment */
ctype_latin1_de, ctype_latin1_de,

View File

@ -201,7 +201,7 @@ int my_wildcmp_mb(CHARSET_INFO *cs,
{ // Found w_many { // Found w_many
uchar cmp; uchar cmp;
const char* mb = wildstr; const char* mb = wildstr;
int mblen; int mblen=0;
wildstr++; wildstr++;
/* Remove any '%' and '_' from the wild search string */ /* Remove any '%' and '_' from the wild search string */

View File

@ -4461,6 +4461,7 @@ CHARSET_INFO my_charset_sjis =
{ {
13, /* number */ 13, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"sjis", /* cs name */
"sjis", /* name */ "sjis", /* name */
"", /* comment */ "", /* comment */
ctype_sjis, ctype_sjis,

View File

@ -689,6 +689,7 @@ CHARSET_INFO my_charset_tis620 =
{ {
18, /* number */ 18, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"tis620", /* cs name */
"tis620", /* name */ "tis620", /* name */
"", /* comment */ "", /* comment */
ctype_tis620, ctype_tis620,

View File

@ -8431,6 +8431,7 @@ CHARSET_INFO my_charset_ujis =
{ {
12, /* number */ 12, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"ujis", /* cs name */
"ujis", /* name */ "ujis", /* name */
"", /* comment */ "", /* comment */
ctype_ujis, ctype_ujis,

View File

@ -1959,6 +1959,7 @@ CHARSET_INFO my_charset_utf8 =
{ {
33, /* number */ 33, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"utf8", /* cs name */
"utf8", /* name */ "utf8", /* name */
"", /* comment */ "", /* comment */
ctype_utf8, /* ctype */ ctype_utf8, /* ctype */
@ -3025,6 +3026,7 @@ CHARSET_INFO my_charset_ucs2 =
{ {
35, /* number */ 35, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"ucs2", /* cs name */
"ucs2", /* name */ "ucs2", /* name */
"", /* comment */ "", /* comment */
ctype_ucs2, /* ctype */ ctype_ucs2, /* ctype */

View File

@ -623,6 +623,7 @@ CHARSET_INFO my_charset_win1250ch =
{ {
34, /* number */ 34, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"cp1250", /* cs name */
"win1250ch", /* name */ "win1250ch", /* name */
"", /* comment */ "", /* comment */
ctype_win1250ch, ctype_win1250ch,

View File

@ -2811,6 +2811,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
8, /* number */ 8, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin1", /* cs name */
"latin1", /* name */ "latin1", /* name */
"", /* comment */ "", /* comment */
ctype_latin1, ctype_latin1,
@ -2856,6 +2857,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
14, /* number */ 14, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"cp1251", /* cs name */
"cp1251", /* name */ "cp1251", /* name */
"", /* comment */ "", /* comment */
ctype_cp1251, ctype_cp1251,
@ -2900,6 +2902,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
29, /* number */ 29, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"cp1257", /* cs name */
"cp1257", /* name */ "cp1257", /* name */
"", /* comment */ "", /* comment */
ctype_cp1257, ctype_cp1257,
@ -2944,6 +2947,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
27, /* number */ 27, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin2", /* cs name */
"croat", /* name */ "croat", /* name */
"", /* comment */ "", /* comment */
ctype_croat, ctype_croat,
@ -2989,6 +2993,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
15, /* number */ 15, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin1", /* cs name */
"danish", /* name */ "danish", /* name */
"", /* comment */ "", /* comment */
ctype_danish, ctype_danish,
@ -3033,6 +3038,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
3, /* number */ 3, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"dec8", /* cs name */
"dec8", /* name */ "dec8", /* name */
"", /* comment */ "", /* comment */
ctype_dec8, ctype_dec8,
@ -3077,6 +3083,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
4, /* number */ 4, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"cp850", /* cs name */
"dos", /* name */ "dos", /* name */
"", /* comment */ "", /* comment */
ctype_dos, ctype_dos,
@ -3121,6 +3128,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
20, /* number */ 20, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin7", /* cs name */
"estonia", /* name */ "estonia", /* name */
"", /* comment */ "", /* comment */
ctype_estonia, ctype_estonia,
@ -3166,6 +3174,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
5, /* number */ 5, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin1", /* cs name */
"german1", /* name */ "german1", /* name */
"", /* comment */ "", /* comment */
ctype_german1, ctype_german1,
@ -3210,6 +3219,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
25, /* number */ 25, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"greek", /* cs name */
"greek", /* name */ "greek", /* name */
"", /* comment */ "", /* comment */
ctype_greek, ctype_greek,
@ -3254,6 +3264,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
16, /* number */ 16, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"hebrew", /* cs name */
"hebrew", /* name */ "hebrew", /* name */
"", /* comment */ "", /* comment */
ctype_hebrew, ctype_hebrew,
@ -3298,6 +3309,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
6, /* number */ 6, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"hp8", /* cs name */
"hp8", /* name */ "hp8", /* name */
"", /* comment */ "", /* comment */
ctype_hp8, ctype_hp8,
@ -3342,6 +3354,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
21, /* number */ 21, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin2", /* cs name */
"hungarian", /* name */ "hungarian", /* name */
"", /* comment */ "", /* comment */
ctype_hungarian, ctype_hungarian,
@ -3386,6 +3399,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
7, /* number */ 7, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"koi8_ru", /* cs name */
"koi8_ru", /* name */ "koi8_ru", /* name */
"", /* comment */ "", /* comment */
ctype_koi8_ru, ctype_koi8_ru,
@ -3430,6 +3444,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
22, /* number */ 22, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"koi8_ukr", /* cs name */
"koi8_ukr", /* name */ "koi8_ukr", /* name */
"", /* comment */ "", /* comment */
ctype_koi8_ukr, ctype_koi8_ukr,
@ -3475,6 +3490,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
9, /* number */ 9, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin2", /* cs name */
"latin2", /* name */ "latin2", /* name */
"", /* comment */ "", /* comment */
ctype_latin2, ctype_latin2,
@ -3519,6 +3535,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
30, /* number */ 30, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"latin5", /* cs name */
"latin5", /* name */ "latin5", /* name */
"", /* comment */ "", /* comment */
ctype_latin5, ctype_latin5,
@ -3564,6 +3581,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
10, /* number */ 10, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"swe7", /* cs name */
"swe7", /* name */ "swe7", /* name */
"", /* comment */ "", /* comment */
ctype_swe7, ctype_swe7,
@ -3609,6 +3627,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
11, /* number */ 11, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"ascii", /* cs name */
"usa7", /* name */ "usa7", /* name */
"", /* comment */ "", /* comment */
ctype_usa7, ctype_usa7,
@ -3653,6 +3672,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
26, /* number */ 26, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"cp1250", /* cs name */
"win1250", /* name */ "win1250", /* name */
"", /* comment */ "", /* comment */
ctype_win1250, ctype_win1250,
@ -3697,6 +3717,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
23, /* number */ 23, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"cp1251", /* cs name */
"win1251ukr", /* name */ "win1251ukr", /* name */
"", /* comment */ "", /* comment */
ctype_win1251ukr, ctype_win1251ukr,
@ -3741,6 +3762,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
32, /* number */ 32, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"armscii8", /* cs name */
"armscii8", /* name */ "armscii8", /* name */
"", /* comment */ "", /* comment */
ctype_armscii8, ctype_armscii8,
@ -3785,6 +3807,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
17, /* number */ 17, /* number */
MY_CS_COMPILED, /* state */ MY_CS_COMPILED, /* state */
"cp1251", /* cs name */
"win1251", /* name */ "win1251", /* name */
"", /* comment */ "", /* comment */
ctype_win1251, ctype_win1251,
@ -3828,6 +3851,7 @@ static CHARSET_INFO compiled_charsets[] = {
{ {
0, /* end-of-list marker */ 0, /* end-of-list marker */
0, /* state */ 0, /* state */
NullS, /* cs name */
NullS, /* name */ NullS, /* name */
NullS, /* comment */ NullS, /* comment */
NULL, NULL,