summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/create.result7
-rw-r--r--mysql-test/t/create.test9
-rw-r--r--sql/sql_select.cc2
3 files changed, 18 insertions, 0 deletions
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 82a5ccc3e82..c75dfa9c3db 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -596,6 +596,13 @@ ERROR 42000: Incorrect database name 'xyz'
create table t1(t1.name int);
create table t2(test.t2.name int);
drop table t1,t2;
+CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8);
+CREATE TABLE t2 AS SELECT LEFT(f1,86) AS f2 FROM t1 UNION SELECT LEFT(f1,86)
+AS f2 FROM t1;
+DESC t2;
+Field Type Null Key Default Extra
+f2 varchar(86) YES NULL
+DROP TABLE t1,t2;
create database mysqltest;
use mysqltest;
drop database mysqltest;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index bc281d1e027..5cd92fbc21e 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -504,6 +504,15 @@ create table t2(test.t2.name int);
drop table t1,t2;
#
+# Bug #12537: UNION produces longtext instead of varchar
+#
+CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8);
+CREATE TABLE t2 AS SELECT LEFT(f1,86) AS f2 FROM t1 UNION SELECT LEFT(f1,86)
+AS f2 FROM t1;
+DESC t2;
+DROP TABLE t1,t2;
+
+#
# Bug#11028: Crash on create table like
#
create database mysqltest;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d4fa5c56842..246076ac285 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7953,6 +7953,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
item->name, table, item->unsigned_flag);
break;
case STRING_RESULT:
+ DBUG_ASSERT(item->collation.collation);
+
enum enum_field_types type;
/*
DATE/TIME fields have STRING_RESULT result type. To preserve