1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge branch 'mysql-5.1' into mysql-5.5

This commit is contained in:
Sreeharsha Ramanavarapu
2015-07-10 07:54:55 +05:30
11 changed files with 173 additions and 47 deletions

View File

@@ -1805,21 +1805,17 @@ LEX_STRING *THD::make_lex_string(LEX_STRING *lex_str,
/*
Convert a string to another character set
SYNOPSIS
convert_string()
to Store new allocated string here
to_cs New character set for allocated string
from String to convert
from_length Length of string to convert
from_cs Original character set
@param to Store new allocated string here
@param to_cs New character set for allocated string
@param from String to convert
@param from_length Length of string to convert
@param from_cs Original character set
NOTES
to will be 0-terminated to make it easy to pass to system funcs
@note to will be 0-terminated to make it easy to pass to system funcs
RETURN
0 ok
1 End of memory.
In this case to->str will point to 0 and to->length will be 0.
@retval false ok
@retval true End of memory.
In this case to->str will point to 0 and to->length will be 0.
*/
bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
@@ -1828,15 +1824,26 @@ bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
{
DBUG_ENTER("convert_string");
size_t new_length= to_cs->mbmaxlen * from_length;
uint dummy_errors;
uint errors= 0;
if (!(to->str= (char*) alloc(new_length+1)))
{
to->length= 0; // Safety fix
DBUG_RETURN(1); // EOM
}
to->length= copy_and_convert((char*) to->str, new_length, to_cs,
from, from_length, from_cs, &dummy_errors);
from, from_length, from_cs, &errors);
to->str[to->length]=0; // Safety
if (errors != 0)
{
char printable_buff[32];
convert_to_printable(printable_buff, sizeof(printable_buff),
from, from_length, from_cs, 6);
push_warning_printf(this, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_INVALID_CHARACTER_STRING,
ER_THD(this, ER_INVALID_CHARACTER_STRING),
from_cs->csname, printable_buff);
}
DBUG_RETURN(0);
}