Commit 7e05bc77 authored by unknown's avatar unknown

MY_CS_NONTEXT flag for sprintf() incompatible charsets (ucs2 if the only one now)

Some default_charset_info were removed
parent 1aa1d970
...@@ -62,9 +62,9 @@ typedef struct unicase_info_st ...@@ -62,9 +62,9 @@ typedef struct unicase_info_st
#define MY_CS_PRIMARY 32 /* if primary collation */ #define MY_CS_PRIMARY 32 /* if primary collation */
#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */ #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_UNICODE 128 /* is a charset is full unicode */
#define MY_CS_NONTEXT 256 /* if a charset is not sprintf() compatible */
#define MY_CHARSET_UNDEFINED 0 #define MY_CHARSET_UNDEFINED 0
#define MY_CHARSET_CURRENT (default_charset_info->number)
typedef struct my_uni_idx_st typedef struct my_uni_idx_st
......
...@@ -441,7 +441,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -441,7 +441,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
mi_int2store(share.state.header.base_info_length,MI_BASE_INFO_SIZE); mi_int2store(share.state.header.base_info_length,MI_BASE_INFO_SIZE);
mi_int2store(share.state.header.base_pos,base_pos); mi_int2store(share.state.header.base_pos,base_pos);
share.state.header.language= (ci->language ? share.state.header.language= (ci->language ?
ci->language : MY_CHARSET_CURRENT); ci->language : default_charset_info->number);
share.state.header.max_block_size=max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH; share.state.header.max_block_size=max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH;
share.state.dellink = HA_OFFSET_ERROR; share.state.dellink = HA_OFFSET_ERROR;
......
...@@ -99,7 +99,7 @@ static int run_test(const char *filename) ...@@ -99,7 +99,7 @@ static int run_test(const char *filename)
keyinfo[0].seg[0].length=key_length; keyinfo[0].seg[0].length=key_length;
keyinfo[0].seg[0].null_bit= null_fields ? 2 : 0; keyinfo[0].seg[0].null_bit= null_fields ? 2 : 0;
keyinfo[0].seg[0].null_pos=0; keyinfo[0].seg[0].null_pos=0;
keyinfo[0].seg[0].language=MY_CHARSET_CURRENT; keyinfo[0].seg[0].language= default_charset_info->number;
if (pack_seg & HA_BLOB_PART) if (pack_seg & HA_BLOB_PART)
{ {
keyinfo[0].seg[0].bit_start=4; /* Length of blob length */ keyinfo[0].seg[0].bit_start=4; /* Length of blob length */
...@@ -122,7 +122,7 @@ static int run_test(const char *filename) ...@@ -122,7 +122,7 @@ static int run_test(const char *filename)
uniqueseg[i].start=start; uniqueseg[i].start=start;
start+=recinfo[i+1].length; start+=recinfo[i+1].length;
uniqueseg[i].length=recinfo[i+1].length; uniqueseg[i].length=recinfo[i+1].length;
uniqueseg[i].language=MY_CHARSET_CURRENT; uniqueseg[i].language= default_charset_info->number;
} }
uniqueseg[0].type= key_type; uniqueseg[0].type= key_type;
uniqueseg[0].null_bit= null_fields ? 2 : 0; uniqueseg[0].null_bit= null_fields ? 2 : 0;
......
...@@ -87,7 +87,7 @@ int main(int argc, char *argv[]) ...@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
keyinfo[0].seg[0].start=0; keyinfo[0].seg[0].start=0;
keyinfo[0].seg[0].length=6; keyinfo[0].seg[0].length=6;
keyinfo[0].seg[0].type=HA_KEYTYPE_TEXT; keyinfo[0].seg[0].type=HA_KEYTYPE_TEXT;
keyinfo[0].seg[0].language=MY_CHARSET_CURRENT; keyinfo[0].seg[0].language= default_charset_info->number;
keyinfo[0].seg[0].flag=(uint8) pack_seg; keyinfo[0].seg[0].flag=(uint8) pack_seg;
keyinfo[0].seg[0].null_bit=0; keyinfo[0].seg[0].null_bit=0;
keyinfo[0].seg[0].null_pos=0; keyinfo[0].seg[0].null_pos=0;
...@@ -124,7 +124,7 @@ int main(int argc, char *argv[]) ...@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
keyinfo[3].seg[0].start=0; keyinfo[3].seg[0].start=0;
keyinfo[3].seg[0].length=reclength-(use_blob ? 8 : 0); keyinfo[3].seg[0].length=reclength-(use_blob ? 8 : 0);
keyinfo[3].seg[0].type=HA_KEYTYPE_TEXT; keyinfo[3].seg[0].type=HA_KEYTYPE_TEXT;
keyinfo[3].seg[0].language=MY_CHARSET_CURRENT; keyinfo[3].seg[0].language=default_charset_info->number;
keyinfo[3].seg[0].flag=(uint8) pack_seg; keyinfo[3].seg[0].flag=(uint8) pack_seg;
keyinfo[3].seg[0].null_bit=0; keyinfo[3].seg[0].null_bit=0;
keyinfo[3].seg[0].null_pos=0; keyinfo[3].seg[0].null_pos=0;
...@@ -135,7 +135,7 @@ int main(int argc, char *argv[]) ...@@ -135,7 +135,7 @@ int main(int argc, char *argv[])
keyinfo[4].seg[0].start=0; keyinfo[4].seg[0].start=0;
keyinfo[4].seg[0].length=5; keyinfo[4].seg[0].length=5;
keyinfo[4].seg[0].type=HA_KEYTYPE_TEXT; keyinfo[4].seg[0].type=HA_KEYTYPE_TEXT;
keyinfo[4].seg[0].language=MY_CHARSET_CURRENT; keyinfo[4].seg[0].language=default_charset_info->number;
keyinfo[4].seg[0].flag=0; keyinfo[4].seg[0].flag=0;
keyinfo[4].seg[0].null_bit=0; keyinfo[4].seg[0].null_bit=0;
keyinfo[4].seg[0].null_pos=0; keyinfo[4].seg[0].null_pos=0;
...@@ -146,7 +146,7 @@ int main(int argc, char *argv[]) ...@@ -146,7 +146,7 @@ int main(int argc, char *argv[])
keyinfo[5].seg[0].start=0; keyinfo[5].seg[0].start=0;
keyinfo[5].seg[0].length=4; keyinfo[5].seg[0].length=4;
keyinfo[5].seg[0].type=HA_KEYTYPE_TEXT; keyinfo[5].seg[0].type=HA_KEYTYPE_TEXT;
keyinfo[5].seg[0].language=MY_CHARSET_CURRENT; keyinfo[5].seg[0].language=default_charset_info->number;
keyinfo[5].seg[0].flag=pack_seg; keyinfo[5].seg[0].flag=pack_seg;
keyinfo[5].seg[0].null_bit=0; keyinfo[5].seg[0].null_bit=0;
keyinfo[5].seg[0].null_pos=0; keyinfo[5].seg[0].null_pos=0;
......
...@@ -98,7 +98,7 @@ int run_test(const char *filename) ...@@ -98,7 +98,7 @@ int run_test(const char *filename)
keyinfo[0].seg[i].length=key_length; keyinfo[0].seg[i].length=key_length;
keyinfo[0].seg[i].null_bit= null_fields ? 2 : 0; keyinfo[0].seg[i].null_bit= null_fields ? 2 : 0;
keyinfo[0].seg[i].null_pos=0; keyinfo[0].seg[i].null_pos=0;
keyinfo[0].seg[i].language=MY_CHARSET_CURRENT; keyinfo[0].seg[i].language=default_charset_info->number;
} }
......
...@@ -96,7 +96,7 @@ int run_test(const char *filename) ...@@ -96,7 +96,7 @@ int run_test(const char *filename)
keyinfo[0].seg[0].length=1; /* Spatial ignores it anyway */ keyinfo[0].seg[0].length=1; /* Spatial ignores it anyway */
keyinfo[0].seg[0].null_bit= null_fields ? 2 : 0; keyinfo[0].seg[0].null_bit= null_fields ? 2 : 0;
keyinfo[0].seg[0].null_pos=0; keyinfo[0].seg[0].null_pos=0;
keyinfo[0].seg[0].language=MY_CHARSET_CURRENT; keyinfo[0].seg[0].language=default_charset_info->number;
keyinfo[0].seg[0].bit_start=4; /* Long BLOB */ keyinfo[0].seg[0].bit_start=4; /* Long BLOB */
......
...@@ -335,7 +335,7 @@ bool Field::optimize_range(uint idx) ...@@ -335,7 +335,7 @@ bool Field::optimize_range(uint idx)
void Field_null::sql_type(String &res) const void Field_null::sql_type(String &res) const
{ {
res.set_latin1("null", 4); res.set_ascii("null", 4);
} }
...@@ -856,7 +856,7 @@ String *Field_decimal::val_str(String *val_buffer __attribute__((unused)), ...@@ -856,7 +856,7 @@ String *Field_decimal::val_str(String *val_buffer __attribute__((unused)),
if (field_length < tmp_length) // Error in data if (field_length < tmp_length) // Error in data
val_ptr->length(0); val_ptr->length(0);
else else
val_ptr->set_latin1((const char*) str, field_length-tmp_length); val_ptr->set_ascii((const char*) str, field_length-tmp_length);
return val_ptr; return val_ptr;
} }
...@@ -2389,7 +2389,7 @@ void Field_float::sql_type(String &res) const ...@@ -2389,7 +2389,7 @@ void Field_float::sql_type(String &res) const
{ {
if (dec == NOT_FIXED_DEC) if (dec == NOT_FIXED_DEC)
{ {
res.set_latin1("float", 5); res.set_ascii("float", 5);
} }
else else
{ {
...@@ -2647,7 +2647,7 @@ void Field_double::sql_type(String &res) const ...@@ -2647,7 +2647,7 @@ void Field_double::sql_type(String &res) const
CHARSET_INFO *cs=res.charset(); CHARSET_INFO *cs=res.charset();
if (dec == NOT_FIXED_DEC) if (dec == NOT_FIXED_DEC)
{ {
res.set_latin1("double",6); res.set_ascii("double",6);
} }
else else
{ {
...@@ -2987,7 +2987,7 @@ void Field_timestamp::sort_string(char *to,uint length __attribute__((unused))) ...@@ -2987,7 +2987,7 @@ void Field_timestamp::sort_string(char *to,uint length __attribute__((unused)))
void Field_timestamp::sql_type(String &res) const void Field_timestamp::sql_type(String &res) const
{ {
res.set_latin1("timestamp", 9); res.set_ascii("timestamp", 9);
} }
...@@ -3186,7 +3186,7 @@ void Field_time::sort_string(char *to,uint length __attribute__((unused))) ...@@ -3186,7 +3186,7 @@ void Field_time::sort_string(char *to,uint length __attribute__((unused)))
void Field_time::sql_type(String &res) const void Field_time::sql_type(String &res) const
{ {
res.set_latin1("time", 4); res.set_ascii("time", 4);
} }
/**************************************************************************** /****************************************************************************
...@@ -3467,7 +3467,7 @@ void Field_date::sort_string(char *to,uint length __attribute__((unused))) ...@@ -3467,7 +3467,7 @@ void Field_date::sort_string(char *to,uint length __attribute__((unused)))
void Field_date::sql_type(String &res) const void Field_date::sql_type(String &res) const
{ {
res.set_latin1("date", 4); res.set_ascii("date", 4);
} }
/**************************************************************************** /****************************************************************************
...@@ -3637,7 +3637,7 @@ void Field_newdate::sort_string(char *to,uint length __attribute__((unused))) ...@@ -3637,7 +3637,7 @@ void Field_newdate::sort_string(char *to,uint length __attribute__((unused)))
void Field_newdate::sql_type(String &res) const void Field_newdate::sql_type(String &res) const
{ {
res.set_latin1("date", 4); res.set_ascii("date", 4);
} }
...@@ -3870,7 +3870,7 @@ void Field_datetime::sort_string(char *to,uint length __attribute__((unused))) ...@@ -3870,7 +3870,7 @@ void Field_datetime::sort_string(char *to,uint length __attribute__((unused)))
void Field_datetime::sql_type(String &res) const void Field_datetime::sql_type(String &res) const
{ {
res.set_latin1("datetime", 8); res.set_ascii("datetime", 8);
} }
/**************************************************************************** /****************************************************************************
...@@ -4615,7 +4615,7 @@ void Field_blob::sql_type(String &res) const ...@@ -4615,7 +4615,7 @@ void Field_blob::sql_type(String &res) const
case 3: str="medium"; length= 6; break; case 3: str="medium"; length= 6; break;
case 4: str="long"; length=4; break; case 4: str="long"; length=4; break;
} }
res.set_latin1(str,length); res.set_ascii(str,length);
if (charset() == &my_charset_bin) if (charset() == &my_charset_bin)
res.append("blob"); res.append("blob");
else else
......
...@@ -1452,7 +1452,7 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, I ...@@ -1452,7 +1452,7 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, I
Field *field=field_arg->field; Field *field=field_arg->field;
/* charset doesn't matter here, it's to avoid sigsegv only */ /* charset doesn't matter here, it's to avoid sigsegv only */
set_field(new Field_null(0,0,Field::NONE,field->field_name,field->table, set_field(new Field_null(0,0,Field::NONE,field->field_name,field->table,
default_charset_info)); &my_charset_bin));
} }
return 0; return 0;
} }
......
...@@ -324,7 +324,7 @@ Item *create_func_current_user() ...@@ -324,7 +324,7 @@ Item *create_func_current_user()
length= (uint) (strxmov(buff, thd->priv_user, "@", thd->priv_host, NullS) - length= (uint) (strxmov(buff, thd->priv_user, "@", thd->priv_host, NullS) -
buff); buff);
return new Item_string(NullS, thd->memdup(buff, length), length, return new Item_string(NullS, thd->memdup(buff, length), length,
default_charset_info); system_charset_info);
} }
Item *create_func_quarter(Item* a) Item *create_func_quarter(Item* a)
......
...@@ -141,7 +141,7 @@ String *Item_func_geometry_type::val_str(String *str) ...@@ -141,7 +141,7 @@ String *Item_func_geometry_type::val_str(String *str)
return 0; return 0;
str->copy(geom.get_class_info()->m_name, str->copy(geom.get_class_info()->m_name,
strlen(geom.get_class_info()->m_name), strlen(geom.get_class_info()->m_name),
default_charset_info); default_charset());
return str; return str;
} }
......
...@@ -2257,7 +2257,7 @@ String *Item_func_hex::val_str(String *str) ...@@ -2257,7 +2257,7 @@ String *Item_func_hex::val_str(String *str)
if ((null_value= args[0]->null_value)) if ((null_value= args[0]->null_value))
return 0; return 0;
ptr= longlong2str(dec,ans,16); ptr= longlong2str(dec,ans,16);
if (str->copy(ans,(uint32) (ptr-ans),default_charset_info)) if (str->copy(ans,(uint32) (ptr-ans),default_charset()))
return &empty_string; // End of memory return &empty_string; // End of memory
return str; return str;
} }
...@@ -2366,7 +2366,7 @@ String* Item_func_export_set::val_str(String* str) ...@@ -2366,7 +2366,7 @@ String* Item_func_export_set::val_str(String* str)
} }
break; break;
case 3: case 3:
sep_buf.set(",", 1, default_charset_info); sep_buf.set(",", 1, default_charset());
sep = &sep_buf; sep = &sep_buf;
} }
null_value=0; null_value=0;
......
...@@ -623,7 +623,7 @@ check_connections(THD *thd) ...@@ -623,7 +623,7 @@ check_connections(THD *thd)
memcpy(end,thd->scramble,SCRAMBLE_LENGTH+1); memcpy(end,thd->scramble,SCRAMBLE_LENGTH+1);
end+=SCRAMBLE_LENGTH +1; end+=SCRAMBLE_LENGTH +1;
int2store(end,client_flags); int2store(end,client_flags);
end[2]=(char) MY_CHARSET_CURRENT; end[2]=(char) default_charset_info->number;
int2store(end+3,thd->server_status); int2store(end+3,thd->server_status);
bzero(end+5,13); bzero(end+5,13);
end+=18; end+=18;
......
...@@ -265,9 +265,9 @@ bool String::copy(const char *str, uint32 arg_length, ...@@ -265,9 +265,9 @@ bool String::copy(const char *str, uint32 arg_length,
*/ */
bool String::set_latin1(const char *str, uint32 arg_length) bool String::set_ascii(const char *str, uint32 arg_length)
{ {
if (str_charset->mbmaxlen == 1) if (!(str_charset->state & MY_CS_NONTEXT))
{ {
set(str, arg_length, str_charset); set(str, arg_length, str_charset);
return 0; return 0;
......
...@@ -117,7 +117,7 @@ class String ...@@ -117,7 +117,7 @@ class String
Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0; Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0;
str_charset=cs; str_charset=cs;
} }
bool set_latin1(const char *str, uint32 arg_length); bool set_ascii(const char *str, uint32 arg_length);
inline void set_quick(char *str,uint32 arg_length, CHARSET_INFO *cs) inline void set_quick(char *str,uint32 arg_length, CHARSET_INFO *cs)
{ {
if (!alloced) if (!alloced)
......
...@@ -2863,15 +2863,15 @@ key_usage_list2: ...@@ -2863,15 +2863,15 @@ key_usage_list2:
key_usage_list2 ',' ident key_usage_list2 ',' ident
{ Select->select_lex()-> { Select->select_lex()->
interval_list.push_back(new String((const char*) $3.str, $3.length, interval_list.push_back(new String((const char*) $3.str, $3.length,
default_charset_info)); } system_charset_info)); }
| ident | ident
{ Select->select_lex()-> { Select->select_lex()->
interval_list.push_back(new String((const char*) $1.str, $1.length, interval_list.push_back(new String((const char*) $1.str, $1.length,
default_charset_info)); } system_charset_info)); }
| PRIMARY_SYM | PRIMARY_SYM
{ Select->select_lex()-> { Select->select_lex()->
interval_list.push_back(new String("PRIMARY", 7, interval_list.push_back(new String("PRIMARY", 7,
default_charset_info)); }; system_charset_info)); };
using_list: using_list:
ident ident
...@@ -3756,7 +3756,7 @@ opt_describe_column: ...@@ -3756,7 +3756,7 @@ opt_describe_column:
/* empty */ {} /* empty */ {}
| text_string { Lex->wild= $1; } | text_string { Lex->wild= $1; }
| ident | ident
{ Lex->wild= new String((const char*) $1.str,$1.length,default_charset_info); }; { Lex->wild= new String((const char*) $1.str,$1.length,system_charset_info); };
/* flush things */ /* flush things */
...@@ -4829,7 +4829,7 @@ column_list: ...@@ -4829,7 +4829,7 @@ column_list:
column_list_id: column_list_id:
ident ident
{ {
String *new_str = new String((const char*) $1.str,$1.length,default_charset_info); String *new_str = new String((const char*) $1.str,$1.length,system_charset_info);
List_iterator <LEX_COLUMN> iter(Lex->columns); List_iterator <LEX_COLUMN> iter(Lex->columns);
class LEX_COLUMN *point; class LEX_COLUMN *point;
LEX *lex=Lex; LEX *lex=Lex;
......
...@@ -1042,7 +1042,7 @@ static MY_CHARSET_HANDLER my_charset_handler= ...@@ -1042,7 +1042,7 @@ static MY_CHARSET_HANDLER my_charset_handler=
CHARSET_INFO my_charset_ucs2_general_ci= CHARSET_INFO my_charset_ucs2_general_ci=
{ {
35,0,0, /* number */ 35,0,0, /* number */
MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM|MY_CS_UNICODE, /* state */ MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONTEXT,
"ucs2", /* cs name */ "ucs2", /* cs name */
"ucs2_general_ci", /* name */ "ucs2_general_ci", /* name */
"", /* comment */ "", /* comment */
...@@ -1065,7 +1065,7 @@ CHARSET_INFO my_charset_ucs2_general_ci= ...@@ -1065,7 +1065,7 @@ CHARSET_INFO my_charset_ucs2_general_ci=
CHARSET_INFO my_charset_ucs2_bin= CHARSET_INFO my_charset_ucs2_bin=
{ {
90,0,0, /* number */ 90,0,0, /* number */
MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE, /* state */ MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE|MY_CS_NONTEXT,
"ucs2", /* cs name */ "ucs2", /* cs name */
"ucs2_bin", /* name */ "ucs2_bin", /* name */
"", /* comment */ "", /* comment */
......
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