Commit fb33da5f authored by unknown's avatar unknown
Browse files

Bug#25815 Data truncated for column TEXT

Problem: "Data truncated" warning was incorrectly generated
when storing a Japanese character encoded in utf8
into a cp932 column.
Reason: Incorrect wrong warning condition
compared the original length of the character in bytes
(which is 3 in utf8) to the converted length of the
character in bytes (which is 2 in cp932).
Fix: use "how many bytes were scanned from input" instead
of "how many bytes were put to the column" in the condition.


mysql-test/r/ctype_cp932.result:
  Adding test case
mysql-test/t/ctype_cp932.test:
  Adding test case
sql/field.cc:
  Change warning condition from:
  "if number of bytes written to destination is less than full source length"
  to
  "if number of bytes read from source is less than full source length"
parent 501bf6de
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -11353,3 +11353,15 @@ a
a
a
drop table t1;
set names utf8;
create table t1 (a text) default character set cp932;
insert into t1 values (_utf8 0xE38182);
show warnings;
Level	Code	Message
select * from t1;
a

select hex(a) from t1;
hex(a)
82A0
drop table t1;
+11 −0
Original line number Diff line number Diff line
@@ -413,3 +413,14 @@ select * from t1;
insert into t1 values ('abc');
select * from t1;
drop table t1;

#
# Bug#25815 Data truncated for column TEXT
#
set names utf8;
create table t1 (a text) default character set cp932;
insert into t1 values (_utf8 0xE38182);
show warnings;
select * from t1;
select hex(a) from t1;
drop table t1;
+1 −1
Original line number Diff line number Diff line
@@ -7024,7 +7024,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
                              cannot_convert_error_pos, from + length))
    return 2;

  if (copy_length < length)
  if (from_end_pos < from + length)
  {
    report_data_too_long(this);
    return 2;