diff options
author | ramil@mysql.com <> | 2005-05-12 15:56:04 +0500 |
---|---|---|
committer | ramil@mysql.com <> | 2005-05-12 15:56:04 +0500 |
commit | 152f751831028afcaa8e5c613f5e271ec23369b9 (patch) | |
tree | 74fb1f2fcec48922e11ae91e1bf428a2256752c8 | |
parent | 7ca3f018e70215f20c7ed48f48335fbe6c6237cd (diff) | |
download | mariadb-git-152f751831028afcaa8e5c613f5e271ec23369b9.tar.gz |
fix (Bug #8295 and #8296: varchar and varbinary conversion)
select, gis & gis-tree tests fails at the moment, but
I will push this CS because it was tested before and I'm absolutely
sure it's right.
-rw-r--r-- | mysql-test/r/strict.result | 5 | ||||
-rw-r--r-- | mysql-test/r/type_blob.result | 2 | ||||
-rw-r--r-- | mysql-test/t/strict.test | 10 | ||||
-rw-r--r-- | sql/sql_table.cc | 5 |
4 files changed, 19 insertions, 3 deletions
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 7d1b6b67fd2..79be7a1923a 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -1232,3 +1232,8 @@ INSERT INTO t1 VALUES (DEFAULT,1); Warnings: Warning 1364 Field 'i' doesn't have a default value DROP TABLE t1; +set @@sql_mode='traditional'; +create table t1(a varchar(65537)); +ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead +create table t1(a varbinary(65537)); +ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 6f437ddbe0d..67a011231be 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -9,7 +9,7 @@ d mediumtext YES NULL e longtext YES NULL CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000)); Warnings: -Note 1246 Converting column 'b' from VARCHAR to BLOB +Note 1246 Converting column 'b' from VARBINARY to BLOB Note 1246 Converting column 'c' from VARCHAR to TEXT CREATE TABLE t4 (c varchar(65530) character set utf8 not null); Warnings: diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index 333ec40b1b9..298653b554a 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -1083,3 +1083,13 @@ INSERT INTO t1 SET j = 1, i = DEFAULT; INSERT INTO t1 SET j = 1, i = DEFAULT(i); INSERT INTO t1 VALUES (DEFAULT,1); DROP TABLE t1; + +# +# Bugs #8295 and #8296: varchar and varbinary conversion +# + +set @@sql_mode='traditional'; +--error 1074 +create table t1(a varchar(65537)); +--error 1074 +create table t1(a varbinary(65537)); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index bbe7c53147b..ad0a0baae2d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1345,7 +1345,8 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field) /* Convert long VARCHAR columns to TEXT or BLOB */ char warn_buff[MYSQL_ERRMSG_SIZE]; - if (sql_field->def) + if (sql_field->def || (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | + MODE_STRICT_ALL_TABLES))) { my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), sql_field->field_name, MAX_FIELD_VARCHARLENGTH / sql_field->charset->mbmaxlen); @@ -1354,7 +1355,7 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field) sql_field->sql_type= FIELD_TYPE_BLOB; sql_field->flags|= BLOB_FLAG; sprintf(warn_buff, ER(ER_AUTO_CONVERT), sql_field->field_name, - "VARCHAR", + (sql_field->charset == &my_charset_bin) ? "VARBINARY" : "VARCHAR", (sql_field->charset == &my_charset_bin) ? "BLOB" : "TEXT"); push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_AUTO_CONVERT, warn_buff); |