diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-05-09 02:03:35 +0400 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-05-09 02:03:35 +0400 |
commit | 5ef2bdea81a68a5440235bb5c841fff5dcc2b2c7 (patch) | |
tree | faf6e2793eae5ff3a0ec48cebf47e8045db0a6ff /sql/sql_class.cc | |
parent | e94c1ab135e035dea4c2db9508d2d635b70bcf80 (diff) | |
parent | 721ec081901b661b9338a47b3144c6c41829165a (diff) | |
download | mariadb-git-5ef2bdea81a68a5440235bb5c841fff5dcc2b2c7.tar.gz |
Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:
Text conflict in mysql-test/r/grant.result
Text conflict in mysql-test/t/grant.test
Text conflict in mysys/mf_loadpath.c
Text conflict in sql/slave.cc
Text conflict in sql/sql_priv.h
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 914ef5c919a..1b5fdd509f9 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2086,9 +2086,21 @@ bool select_export::send_data(List<Item> &items) const char *from_end_pos; const char *error_pos; uint32 bytes; - bytes= well_formed_copy_nchars(write_cs, cvt_buff, sizeof(cvt_buff), + uint64 estimated_bytes= + ((uint64) res->length() / res->charset()->mbminlen + 1) * + write_cs->mbmaxlen + 1; + set_if_smaller(estimated_bytes, UINT_MAX32); + if (cvt_str.realloc((uint32) estimated_bytes)) + { + my_error(ER_OUTOFMEMORY, MYF(0), (uint32) estimated_bytes); + goto err; + } + + bytes= well_formed_copy_nchars(write_cs, (char *) cvt_str.ptr(), + cvt_str.alloced_length(), res->charset(), res->ptr(), res->length(), - sizeof(cvt_buff), + UINT_MAX32, // copy all input chars, + // i.e. ignore nchars parameter &well_formed_error_pos, &cannot_convert_error_pos, &from_end_pos); @@ -2106,6 +2118,15 @@ bool select_export::send_data(List<Item> &items) "string", printable_buff, item->name, row_count); } + else if (from_end_pos < res->ptr() + res->length()) + { + /* + result is longer than UINT_MAX32 and doesn't fit into String + */ + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED), + item->full_name(), row_count); + } cvt_str.length(bytes); res= &cvt_str; } |