mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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.
This commit is contained in:
@ -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
|
||||
(
|
||||
|
@ -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 ('<27><><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>');
|
||||
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);
|
||||
|
@ -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
|
||||
|
@ -372,10 +372,10 @@ t collation(t) FORMAT(MATCH t AGAINST ('Osnabruck'),6)
|
||||
aus Osnabr<62>ck 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 ('Osnabr<62>ck');
|
||||
t collation(t)
|
||||
aus Osnabr<62>ck latin1_german2_ci
|
||||
|
@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
Reference in New Issue
Block a user