Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1796 05/03/10 17:08:45 ramil@stripped +3 -0
a fix (bug #9029 Traditional: Wrong SQLSTATE returned for string truncation).
sql/field.cc
1.240 05/03/10 17:08:40 ramil@stripped +16 -4
a fix (bug #9029 Traditional: Wrong SQLSTATE returned for string truncation).
Should issue ER_DATA_TOO_LONG in 'traditional' mode when data truncated.
mysql-test/t/strict.test
1.17 05/03/10 17:08:40 ramil@stripped +25 -2
a fix (bug #9029 Traditional: Wrong SQLSTATE returned for string truncation).
mysql-test/r/strict.result
1.18 05/03/10 17:08:40 ramil@stripped +21 -2
a fix (bug #9029 Traditional: Wrong SQLSTATE returned for string truncation).
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: ramil
# Host: gw.mysql.r18.ru
# Root: /usr/home/ram/work/5.0.b9029
--- 1.239/sql/field.cc 2005-03-07 20:53:47 +04:00
+++ 1.240/sql/field.cc 2005-03-10 17:08:40 +04:00
@@ -5332,7 +5332,7 @@
uint32 not_used, copy_length;
char buff[STRING_BUFFER_USUAL_SIZE];
String tmpstr(buff,sizeof(buff), &my_charset_bin);
- enum MYSQL_ERROR::enum_warning_level level= MYSQL_ERROR::WARN_LEVEL_WARN;
+ bool lost_only_spaces= FALSE;
/* Convert character set if necessary */
if (String::needs_conversion(length, cs, field_charset, ¬_used))
@@ -5370,11 +5370,18 @@
then don't reset level to NOTE.
*/
if (from == end && !error)
- level= MYSQL_ERROR::WARN_LEVEL_NOTE;
+ lost_only_spaces= TRUE;
error= 1;
}
if (error)
- set_warning(level, WARN_DATA_TRUNCATED, 1);
+ {
+ if (lost_only_spaces)
+ set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
+ else if (table->in_use->abort_on_warning)
+ set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
+ else
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ }
return error;
}
@@ -5971,7 +5978,12 @@
bmove(ptr+packlength,(char*) &from,sizeof(char*));
}
if (error)
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ {
+ if (table->in_use->abort_on_warning)
+ set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
+ else
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ }
return 0;
}
--- 1.17/mysql-test/r/strict.result 2005-02-22 20:30:36 +04:00
+++ 1.18/mysql-test/r/strict.result 2005-03-10 17:08:40 +04:00
@@ -906,14 +906,14 @@
INSERT INTO t1 (col1) VALUES ('hellobob');
ERROR 22001: Data too long for column 'col1' at row 1
INSERT INTO t1 (col2) VALUES ('hellobob');
-ERROR 01000: Data truncated for column 'col2' at row 1
+ERROR 22001: Data too long for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES ('hello ');
Warnings:
Note 1265 Data truncated for column 'col2' at row 1
UPDATE t1 SET col1 ='hellobob' WHERE col1 ='he';
ERROR 22001: Data too long for column 'col1' at row 2
UPDATE t1 SET col2 ='hellobob' WHERE col2 ='he';
-ERROR 01000: Data truncated for column 'col2' at row 2
+ERROR 22001: Data too long for column 'col2' at row 2
INSERT IGNORE INTO t1 VALUES ('hellobob', 'hellobob');
Warnings:
Warning 1265 Data truncated for column 'col1' at row 1
@@ -1011,3 +1011,22 @@
3
99
DROP TABLE t1;
+set sql_mode='traditional';
+create table t1 (charcol char(255), varcharcol varchar(255),
+binarycol binary(255), varbinarycol varbinary(255), tinytextcol tinytext,
+tinyblobcol tinyblob);
+insert into t1 (charcol) values (repeat('x',256));
+ERROR 22001: Data too long for column 'charcol' at row 1
+insert into t1 (varcharcol) values (repeat('x',256));
+ERROR 22001: Data too long for column 'varcharcol' at row 1
+insert into t1 (binarycol) values (repeat('x',256));
+ERROR 22001: Data too long for column 'binarycol' at row 1
+insert into t1 (varbinarycol) values (repeat('x',256));
+ERROR 22001: Data too long for column 'varbinarycol' at row 1
+insert into t1 (tinytextcol) values (repeat('x',256));
+ERROR 22001: Data too long for column 'tinytextcol' at row 1
+insert into t1 (tinyblobcol) values (repeat('x',256));
+ERROR 22001: Data too long for column 'tinyblobcol' at row 1
+select * from t1;
+charcol varcharcol binarycol varbinarycol tinytextcol tinyblobcol
+drop table t1;
--- 1.16/mysql-test/t/strict.test 2005-02-22 20:30:36 +04:00
+++ 1.17/mysql-test/t/strict.test 2005-03-10 17:08:40 +04:00
@@ -868,12 +868,12 @@
INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello ', 'hello ');
--error 1406
INSERT INTO t1 (col1) VALUES ('hellobob');
---error 1265
+--error 1406
INSERT INTO t1 (col2) VALUES ('hellobob');
INSERT INTO t1 (col2) VALUES ('hello ');
--error 1406
UPDATE t1 SET col1 ='hellobob' WHERE col1 ='he';
---error 1265
+--error 1406
UPDATE t1 SET col2 ='hellobob' WHERE col2 ='he';
INSERT IGNORE INTO t1 VALUES ('hellobob', 'hellobob');
UPDATE IGNORE t1 SET col2 ='hellotrudy' WHERE col2 ='he';
@@ -939,3 +939,26 @@
INSERT IGNORE INTO t1 () values ();
SELECT * FROM t1;
DROP TABLE t1;
+
+#
+# Bug #9029 Traditional: Wrong SQLSTATE returned for string truncation
+#
+
+set sql_mode='traditional';
+create table t1 (charcol char(255), varcharcol varchar(255),
+binarycol binary(255), varbinarycol varbinary(255), tinytextcol tinytext,
+tinyblobcol tinyblob);
+--error 1406
+insert into t1 (charcol) values (repeat('x',256));
+--error 1406
+insert into t1 (varcharcol) values (repeat('x',256));
+--error 1406
+insert into t1 (binarycol) values (repeat('x',256));
+--error 1406
+insert into t1 (varbinarycol) values (repeat('x',256));
+--error 1406
+insert into t1 (tinytextcol) values (repeat('x',256));
+--error 1406
+insert into t1 (tinyblobcol) values (repeat('x',256));
+select * from t1;
+drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (ramil:1.1796) BUG#9029 | ramil | 10 Mar |