Commit 362a340d authored by unknown's avatar unknown

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.


mysql-test/r/strict.result:
  fix (Bugs #8295 and #8296: varchar and varbinary conversion)
mysql-test/r/type_blob.result:
  fix (Bugs #8295 and #8296: varchar and varbinary conversion)
mysql-test/t/strict.test:
  fix (Bugs #8295 and #8296: varchar and varbinary conversion)
sql/sql_table.cc:
  fix (Bugs #8295 and #8296: varchar and varbinary conversion):
  1. fon't convert datatypes if it's strict mode;
  2. better warning.
parent c572e469
......@@ -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
......@@ -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:
......
......@@ -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));
......@@ -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);
......
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