From 3891d43617e82dcb1a1ecdf876fa2094d672cb79 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Feb 2008 02:33:21 +0400 Subject: Fixed bug#30059. Server handles truncation for assignment of too-long values into CHAR/VARCHAR/TEXT columns in a different ways when the truncated characters are spaces: 1. CHAR(N) columns silently ignore end-space truncation; 2. TEXT columns post a truncation warning/error in the non-strict/strict mode. 3. VARCHAR columns always post a truncation note in any mode. Space truncation processing has been synchronised over CHAR/VARCHAR/TEXT columns: current behavior of VARCHAR columns has been propagated as standard. Binary-encoded string/BLOB columns are not affected. mysql-test/r/heap.result: Updated test case for bug#30059. mysql-test/r/innodb.result: Updated test case for bug#30059. mysql-test/r/myisam.result: Updated test case for bug#30059. mysql-test/r/strict.result: Updated test case for bug#30059. mysql-test/r/type_binary.result: Updated test case for bug#30059. mysql-test/r/warnings.result: Added test case for bug#30059. mysql-test/t/warnings.test: Added test case for bug#30059. sql/field.cc: Fixed bug#30059. The report_data_too_long function was replaced with the Field_longstr::report_if_important_data method. The Field_string::store and the Field_blob::store methods was synchronized with the Field_varstring::store method. Changes: 1. to CHAR(N): posting of space truncation note has been added in both (strict and non-strict) modes; 2. to BLOBs: a check for space truncation has been added, a warning in the non-strict mode and an error message in the strict mode have been replaced with a truncation note. Similar parts of Field_string::store, Field_blob::store and Field_varstring::store have been moved to the Field_longstr::report_if_important_data method. sql/field.h: Fixed bug#30059. The Field_longstr::report_if_important_data method has been declared. --- mysql-test/r/warnings.result | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'mysql-test/r/warnings.result') diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index 9ce1f9c825d..e74f92205aa 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -298,4 +298,42 @@ DROP TABLE t3; DROP PROCEDURE sp1; DROP PROCEDURE sp2; DROP PROCEDURE sp3; +create table t1 (c_char char(255), c_varchar varchar(255), c_tinytext tinytext); +create table t2 (c_tinyblob tinyblob); +set @c = repeat(' ', 256); +set @q = repeat('q', 256); +set sql_mode = ''; +insert into t1 values(@c, @c, @c); +Warnings: +Note 1265 Data truncated for column 'c_char' at row 1 +Note 1265 Data truncated for column 'c_varchar' at row 1 +Note 1265 Data truncated for column 'c_tinytext' at row 1 +insert into t2 values(@c); +Warnings: +Warning 1265 Data truncated for column 'c_tinyblob' at row 1 +insert into t1 values(@q, @q, @q); +Warnings: +Warning 1265 Data truncated for column 'c_char' at row 1 +Warning 1265 Data truncated for column 'c_varchar' at row 1 +Warning 1265 Data truncated for column 'c_tinytext' at row 1 +insert into t2 values(@q); +Warnings: +Warning 1265 Data truncated for column 'c_tinyblob' at row 1 +set sql_mode = 'traditional'; +insert into t1 values(@c, @c, @c); +Warnings: +Note 1265 Data truncated for column 'c_char' at row 1 +Note 1265 Data truncated for column 'c_varchar' at row 1 +Note 1265 Data truncated for column 'c_tinytext' at row 1 +insert into t2 values(@c); +ERROR 22001: Data too long for column 'c_tinyblob' at row 1 +insert into t1 values(@q, NULL, NULL); +ERROR 22001: Data too long for column 'c_char' at row 1 +insert into t1 values(NULL, @q, NULL); +ERROR 22001: Data too long for column 'c_varchar' at row 1 +insert into t1 values(NULL, NULL, @q); +ERROR 22001: Data too long for column 'c_tinytext' at row 1 +insert into t2 values(@q); +ERROR 22001: Data too long for column 'c_tinyblob' at row 1 +drop table t1, t2; End of 5.0 tests -- cgit v1.2.1