From 033faf7256604c5ba2edec8ddc846f663488cd16 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Aug 2005 16:19:53 +0400 Subject: Fix bug #12537 UNION produces longtext instead of varchar Item::tmp_table_field_from_field_type() and create_tmp_field_from_item() was converting string field to blob depending on byte-wise length instead of character length, which results in converting valid varchar string with length == 86 to longtext. Made that functions above take into account max width of character when converting string fields to blobs. sql/item.cc: Fix bug #12537 UNION produces longtext instead of varchar Item::tmp_table_field_from_field_type() now taking into account max char width when creating tmp field for string fields. sql/sql_select.cc: Fix bug #12537 UNION produces longtext instead of varchar create_tmp_field_from_item()now taking into account max char width when creating tmp field for string fields. mysql-test/r/create.result: Test case for bug #12537 UNION produces longtext instead of varchar mysql-test/t/create.test: Test case for bug #12537 UNION produces longtext instead of varchar --- mysql-test/t/create.test | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 3b4b86a3df3..55321a81f5e 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -492,6 +492,15 @@ create table t1(t1.name int); 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 # -- cgit v1.2.1