Commit 152f7518 authored by ramil@mysql.com's avatar ramil@mysql.com

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.
parent 7ca3f018
...@@ -1232,3 +1232,8 @@ INSERT INTO t1 VALUES (DEFAULT,1); ...@@ -1232,3 +1232,8 @@ INSERT INTO t1 VALUES (DEFAULT,1);
Warnings: Warnings:
Warning 1364 Field 'i' doesn't have a default value Warning 1364 Field 'i' doesn't have a default value
DROP TABLE t1; 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
...@@ -9,7 +9,7 @@ d mediumtext YES NULL ...@@ -9,7 +9,7 @@ d mediumtext YES NULL
e longtext YES NULL e longtext YES NULL
CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000)); CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000));
Warnings: 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 Note 1246 Converting column 'c' from VARCHAR to TEXT
CREATE TABLE t4 (c varchar(65530) character set utf8 not null); CREATE TABLE t4 (c varchar(65530) character set utf8 not null);
Warnings: Warnings:
......
...@@ -1083,3 +1083,13 @@ INSERT INTO t1 SET j = 1, i = DEFAULT; ...@@ -1083,3 +1083,13 @@ INSERT INTO t1 SET j = 1, i = DEFAULT;
INSERT INTO t1 SET j = 1, i = DEFAULT(i); INSERT INTO t1 SET j = 1, i = DEFAULT(i);
INSERT INTO t1 VALUES (DEFAULT,1); INSERT INTO t1 VALUES (DEFAULT,1);
DROP TABLE t1; 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));
...@@ -1345,7 +1345,8 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field) ...@@ -1345,7 +1345,8 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field)
/* Convert long VARCHAR columns to TEXT or BLOB */ /* Convert long VARCHAR columns to TEXT or BLOB */
char warn_buff[MYSQL_ERRMSG_SIZE]; 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, my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), sql_field->field_name,
MAX_FIELD_VARCHARLENGTH / sql_field->charset->mbmaxlen); MAX_FIELD_VARCHARLENGTH / sql_field->charset->mbmaxlen);
...@@ -1354,7 +1355,7 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field) ...@@ -1354,7 +1355,7 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field)
sql_field->sql_type= FIELD_TYPE_BLOB; sql_field->sql_type= FIELD_TYPE_BLOB;
sql_field->flags|= BLOB_FLAG; sql_field->flags|= BLOB_FLAG;
sprintf(warn_buff, ER(ER_AUTO_CONVERT), sql_field->field_name, 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"); (sql_field->charset == &my_charset_bin) ? "BLOB" : "TEXT");
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_AUTO_CONVERT, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_AUTO_CONVERT,
warn_buff); warn_buff);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment