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_LOADED 8 /* sets that are currently loaded */
#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_CURRENT (default_charset_info->number)
@ -65,6 +66,7 @@ typedef struct charset_info_st
{
uint number;
uint state;
const char *csname;
const char *name;
const char *comment;
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 (*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);
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);

View File

@ -165,15 +165,24 @@ 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_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]=
(CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),i->myflags)))
if (!all_charsets[i->cs.number])
{
return MY_XML_ERROR;
if (!(all_charsets[i->cs.number]=
(CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),i->myflags)))
{
return MY_XML_ERROR;
}
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;
}
@ -203,6 +212,16 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, uint len)
((char*)(i->cs.name))[len]='\0';
}
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;
}

View File

@ -1362,10 +1362,14 @@ int mysqld_show_charsets(THD *thd, const char *wild)
List<Item> field_list;
CHARSET_INFO **cs;
Protocol *protocol= thd->protocol;
char flags[64];
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_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("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++ )
{
if (!cs[0])
continue;
if (!(wild && wild[0] &&
if (cs[0] && !(wild && wild[0] &&
wild_case_compare(system_charset_info,cs[0]->name,wild)))
{
protocol->prepare_for_resend();
protocol->store(cs[0]->csname);
protocol->store(cs[0]->name);
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]->mbmaxlen);
if (protocol->write())

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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