1. Some optimization when conversion is not needed.
2. One now must pass length argument into append(const char *str, uint length), length is not calculated internally anymore.
This commit is contained in:
parent
115e769be2
commit
3f8996f88d
@ -9261,7 +9261,9 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
{
|
{
|
||||||
if (tmp1.length())
|
if (tmp1.length())
|
||||||
tmp1.append(',');
|
tmp1.append(',');
|
||||||
tmp1.append(table->key_info[j].name, 0, system_charset_info);
|
tmp1.append(table->key_info[j].name,
|
||||||
|
strlen(table->key_info[j].name),
|
||||||
|
system_charset_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9281,7 +9283,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
{
|
{
|
||||||
if (tmp2.length())
|
if (tmp2.length())
|
||||||
tmp2.append(',');
|
tmp2.append(',');
|
||||||
tmp2.append((*ref)->name(), 0, system_charset_info);
|
tmp2.append((*ref)->name(), strlen((*ref)->name()),
|
||||||
|
system_charset_info);
|
||||||
}
|
}
|
||||||
item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),cs));
|
item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),cs));
|
||||||
}
|
}
|
||||||
|
@ -1207,7 +1207,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
|
|||||||
{
|
{
|
||||||
List<Item> field_list;
|
List<Item> field_list;
|
||||||
char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], *end, *alias;
|
char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], *end, *alias;
|
||||||
String type(tmp, sizeof(tmp),&my_charset_bin);
|
String type(tmp, sizeof(tmp), system_charset_info);
|
||||||
Field **ptr,*field;
|
Field **ptr,*field;
|
||||||
uint primary_key;
|
uint primary_key;
|
||||||
KEY *key_info;
|
KEY *key_info;
|
||||||
@ -1254,7 +1254,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
|
|||||||
type.set(tmp, sizeof(tmp),&my_charset_bin);
|
type.set(tmp, sizeof(tmp),&my_charset_bin);
|
||||||
|
|
||||||
field->sql_type(type);
|
field->sql_type(type);
|
||||||
packet->append(type.ptr(),type.length());
|
packet->append(type.ptr(), type.length(), system_charset_info);
|
||||||
|
|
||||||
if (field->has_charset() && !limited_mysql_mode && !foreign_db_mode)
|
if (field->has_charset() && !limited_mysql_mode && !foreign_db_mode)
|
||||||
{
|
{
|
||||||
@ -1313,7 +1313,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
|
|||||||
else if (field->maybe_null())
|
else if (field->maybe_null())
|
||||||
packet->append("NULL", 4); // Null as default
|
packet->append("NULL", 4); // Null as default
|
||||||
else
|
else
|
||||||
packet->append(tmp,0);
|
packet->append(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foreign_db_mode && !limited_mysql_mode &&
|
if (!foreign_db_mode && !limited_mysql_mode &&
|
||||||
|
@ -416,16 +416,18 @@ bool String::append(const String &s)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Append a latin1 string to the a string of the current character set
|
Append an ASCII string to the a string of the current character set
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
bool String::append(const char *s,uint32 arg_length)
|
bool String::append(const char *s,uint32 arg_length)
|
||||||
{
|
{
|
||||||
if (!arg_length) // Default argument
|
if (!arg_length)
|
||||||
if (!(arg_length= (uint32) strlen(s)))
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
if (str_charset->mbmaxlen > 1)
|
/*
|
||||||
|
For an ASCII incompatible string, e.g. UCS-2, we need to convert
|
||||||
|
*/
|
||||||
|
if (str_charset->mbminlen > 1)
|
||||||
{
|
{
|
||||||
uint32 add_length=arg_length * str_charset->mbmaxlen;
|
uint32 add_length=arg_length * str_charset->mbmaxlen;
|
||||||
if (realloc(str_length+ add_length))
|
if (realloc(str_length+ add_length))
|
||||||
@ -434,6 +436,10 @@ bool String::append(const char *s,uint32 arg_length)
|
|||||||
s, arg_length, &my_charset_latin1);
|
s, arg_length, &my_charset_latin1);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
For an ASCII compatinble string we can just append.
|
||||||
|
*/
|
||||||
if (realloc(str_length+arg_length))
|
if (realloc(str_length+arg_length))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
memcpy(Ptr+str_length,s,arg_length);
|
memcpy(Ptr+str_length,s,arg_length);
|
||||||
@ -442,30 +448,37 @@ bool String::append(const char *s,uint32 arg_length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Append a 0-terminated ASCII string
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool String::append(const char *s)
|
||||||
|
{
|
||||||
|
return append(s, strlen(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Append a string in the given charset to the string
|
Append a string in the given charset to the string
|
||||||
with character set recoding
|
with character set recoding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs)
|
bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs)
|
||||||
{
|
{
|
||||||
uint32 dummy_offset;
|
uint32 dummy_offset;
|
||||||
uint32 add_length;
|
|
||||||
|
|
||||||
if (!arg_length && !(arg_length= (uint32)strlen(s)))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
add_length= arg_length * str_charset->mbmaxlen;
|
|
||||||
if (realloc(str_length + add_length))
|
|
||||||
return TRUE;
|
|
||||||
if (needs_conversion(arg_length, cs, str_charset, &dummy_offset))
|
if (needs_conversion(arg_length, cs, str_charset, &dummy_offset))
|
||||||
{
|
{
|
||||||
|
uint32 add_length= arg_length / cs->mbminlen * str_charset->mbmaxlen;
|
||||||
|
if (realloc(str_length + add_length))
|
||||||
|
return TRUE;
|
||||||
str_length+= copy_and_convert(Ptr+str_length, add_length, str_charset,
|
str_length+= copy_and_convert(Ptr+str_length, add_length, str_charset,
|
||||||
s, arg_length, cs);
|
s, arg_length, cs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (realloc(str_length + arg_length))
|
||||||
|
return TRUE;
|
||||||
memcpy(Ptr + str_length, s, arg_length);
|
memcpy(Ptr + str_length, s, arg_length);
|
||||||
str_length+= arg_length;
|
str_length+= arg_length;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,8 @@ public:
|
|||||||
bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom,
|
bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom,
|
||||||
CHARSET_INFO *csto);
|
CHARSET_INFO *csto);
|
||||||
bool append(const String &s);
|
bool append(const String &s);
|
||||||
bool append(const char *s,uint32 arg_length=0);
|
bool append(const char *s);
|
||||||
|
bool append(const char *s,uint32 arg_length);
|
||||||
bool append(const char *s,uint32 arg_length, CHARSET_INFO *cs);
|
bool append(const char *s,uint32 arg_length, CHARSET_INFO *cs);
|
||||||
bool append(IO_CACHE* file, uint32 arg_length);
|
bool append(IO_CACHE* file, uint32 arg_length);
|
||||||
bool append_with_prefill(const char *s, uint32 arg_length,
|
bool append_with_prefill(const char *s, uint32 arg_length,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user