summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorSreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com>2015-07-10 07:52:00 +0530
committerSreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com>2015-07-10 07:52:00 +0530
commit33a2e5abd86727155b629246445d508bb2cd02c0 (patch)
treeab6748eb9bb0ef8338ba3843e3b30f93f81fceeb /sql/sql_class.cc
parent8f87d6cd41042fe931305a60718d6aa1015a9ccc (diff)
downloadmariadb-git-33a2e5abd86727155b629246445d508bb2cd02c0.tar.gz
Bug #20238729: ILLEGALLY CRAFTED UTF8 SELECT PROVIDES NO
WARNINGS Backporting to 5.1 and 5.5
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc38
1 files changed, 22 insertions, 16 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index d71da6403ae..39d6316a512 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1313,21 +1313,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,
@@ -1336,15 +1332,25 @@ 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_UNKNOWN_ERROR,
+ "Can't convert the character string from %s to %s: '%.64s'",
+ from_cs->csname, to_cs->csname, printable_buff);
+ }
+
DBUG_RETURN(0);
}