summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorGleb Shchepa <gshchepa@mysql.com>2010-05-07 00:41:37 +0400
committerGleb Shchepa <gshchepa@mysql.com>2010-05-07 00:41:37 +0400
commitbd2a517b2381465eb2cf366fb5d4ad08d6770708 (patch)
treea947e154dfe6fb69c896b08add4f0bf0ee891961 /sql/sql_class.cc
parentaddd0a3e67164037149140b71c027272ecbaee49 (diff)
downloadmariadb-git-bd2a517b2381465eb2cf366fb5d4ad08d6770708.tar.gz
Bug #53088: mysqldump with -T & --default-character-set set
truncates text/blob to 766 chars mysqldump and SELECT ... INTO OUTFILE truncated long BLOB/TEXT values to size of 766 bytes (MAX_FIELD_WIDTH or 255 * 3 + 1). The select_export::send_data method has been modified to reallocate a conversion buffer for long field data. mysql-test/r/mysqldump.result: Test case for bug #53088. mysql-test/r/outfile_loaddata.result: Test case for bug #53088. mysql-test/t/mysqldump.test: Test case for bug #53088. mysql-test/t/outfile_loaddata.test: Test case for bug #53088. sql/sql_class.cc: Bug #53088: mysqldump with -T & --default-character-set set truncates text/blob to 766 chars The select_export::send_data method has been modified to reallocate a conversion buffer for long field data.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2633f03f2d6..b639e590bbc 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1998,9 +1998,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);
@@ -2018,6 +2030,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;
}