Commit 00c1c19e authored by unknown's avatar unknown
Browse files

Bug#18908: ERROR 1406 (22001): Data too long for column :: using utf8

Problem: Too confusing error message when cannot convert
between string and column character sets on INSERT and UPDATE.
Fix: producing a better error message, instead of "Data too long"
in such cases
Additional changes: Adding "DROP TABLE IF EXISTS" into several
tests to be safe against failures in previous tests. 


mysql-test/include/strict_autoinc.inc:
  Adding DROP TABLE to be safe against previous tests failure.
mysql-test/r/ctype_recoding.result:
  Fixing test results
mysql-test/r/ctype_utf8.result:
  Fixing test results
mysql-test/r/fulltext.result:
  Fixing test results
mysql-test/r/strict_autoinc_1myisam.result:
  Adding DROP TABLE to be safe against previous tests failure.
mysql-test/r/strict_autoinc_2innodb.result:
  Adding DROP TABLE to be safe against previous tests failure.
mysql-test/r/strict_autoinc_3heap.result:
  Adding DROP TABLE to be safe against previous tests failure.
mysql-test/r/strict_autoinc_4bdb.result:
  Adding DROP TABLE to be safe against previous tests failure.
mysql-test/r/strict_autoinc_5ndb.result:
  Adding DROP TABLE to be safe against previous tests failure.
sql/field.cc:
  - producing better error messages than
    "DATA TRUNCATED" or "DATA TOO LONG" (in strict mode)
    in case of "not well formed source" and
    "cannot convert to field character set"
  - Performance improvements: copying directly to
    the target, instead of using an intermediate
    String.
  - Moving duplicate code into report_data_too_long() function.
sql/sql_string.cc:
  Adding a new function to convert strings between character sets,
  but not more than "nchar" characters - a helper function for
  Field_string::store(), Field_varstring::store() and Field_blob::store().
sql/sql_string.h:
  Adding new function prototype.
parent 2bfeecca
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@
44ec850ac2k4y2Omgr92GiWPBAVKGQ
44edb86b1iE5knJ97MbliK_3lCiAXA
44f33f3aj5KW5qweQeekY1LU0E9ZCg
452c6c6dAjuNghfc1ObZ_UQ5SCl85g
+4 −0
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@
# Test for strict-mode autoincrement
#

--disable_warnings
drop table if exists t1;
--enable_warnings

set @org_mode=@@sql_mode;
eval create table t1
(
+2 −2
Original line number Diff line number Diff line
@@ -171,8 +171,8 @@ create table t1 (a char(10) character set koi8r, b text character set koi8r);
insert into t1 values ('test','test');
insert into t1 values ('','');
Warnings:
Warning	1265	Data truncated for column 'a' at row 1
Warning	1265	Data truncated for column 'b' at row 1
Warning	1366	Incorrect string value: '\xCA\xC3\xD5\xCB' for column 'a' at row 1
Warning	1366	Incorrect string value: '\xCA\xC3\xD5\xCB' for column 'b' at row 1
drop table t1;
set names koi8r;
create table t1 (a char(10) character set cp1251);
+3 −3
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ drop table t1;
create table t1 (s1 char(10) character set utf8);
insert into t1 values (0x41FF);
Warnings:
Warning	1265	Data truncated for column 's1' at row 1
Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
select hex(s1) from t1;
hex(s1)
41
@@ -205,7 +205,7 @@ drop table t1;
create table t1 (s1 varchar(10) character set utf8);
insert into t1 values (0x41FF);
Warnings:
Warning	1265	Data truncated for column 's1' at row 1
Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
select hex(s1) from t1;
hex(s1)
41
@@ -213,7 +213,7 @@ drop table t1;
create table t1 (s1 text character set utf8);
insert into t1 values (0x41FF);
Warnings:
Warning	1265	Data truncated for column 's1' at row 1
Warning	1366	Incorrect string value: '\xFF' for column 's1' at row 1
select hex(s1) from t1;
hex(s1)
41
+4 −4
Original line number Diff line number Diff line
@@ -372,10 +372,10 @@ t collation(t) FORMAT(MATCH t AGAINST ('Osnabruck'),6)
aus Osnabrck	utf8_general_ci	1.591140
alter table t1 modify t varchar(200) collate latin1_german2_ci not null;
Warnings:
Warning	1265	Data truncated for column 't' at row 3
Warning	1265	Data truncated for column 't' at row 4
Warning	1265	Data truncated for column 't' at row 5
Warning	1265	Data truncated for column 't' at row 6
Warning	1366	Incorrect string value: '\xD0\xAD\xD1\x82\xD0\xBE...' for column 't' at row 3
Warning	1366	Incorrect string value: '\xD0\x9E\xD1\x82\xD0\xBB...' for column 't' at row 4
Warning	1366	Incorrect string value: '\xD0\x9D\xD0\xB5 \xD0...' for column 't' at row 5
Warning	1366	Incorrect string value: '\xD0\xB8 \xD0\xB1\xD1...' for column 't' at row 6
SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrck');
t	collation(t)
aus Osnabrck	latin1_german2_ci
Loading