Commit 34514477 authored by unknown's avatar unknown

fixed problem with long string results of expressions in UNIONS (BUG#10025)


mysql-test/r/union.result:
  test for Bug #10025
mysql-test/t/union.test:
  test for Bug #10025
sql/item.cc:
  set HA_OPTION_PACK_RECORD and change type to MYSQL_TYPE_STRING, to allow correct field creation in case of length more then 255 (creation STRING field with length more then 255)
parent 8ec1ffc6
...@@ -1235,3 +1235,17 @@ show columns from t2; ...@@ -1235,3 +1235,17 @@ show columns from t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a varchar(3) YES NULL a varchar(3) YES NULL
drop table t2, t1; drop table t2, t1;
CREATE TABLE t1 (a mediumtext);
CREATE TABLE t2 (b varchar(20));
INSERT INTO t1 VALUES ('a'),('b');
SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2;
left(a,100000000)
a
b
create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`left(a,100000000)` longtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop tables t1,t2,t3;
...@@ -742,3 +742,14 @@ create table t2 select a from t1 union select c from t1; ...@@ -742,3 +742,14 @@ create table t2 select a from t1 union select c from t1;
create table t2 select a from t1 union select b from t1; create table t2 select a from t1 union select b from t1;
show columns from t2; show columns from t2;
drop table t2, t1; drop table t2, t1;
#
# correct conversion long string to TEXT (BUG#10025)
#
CREATE TABLE t1 (a mediumtext);
CREATE TABLE t2 (b varchar(20));
INSERT INTO t1 VALUES ('a'),('b');
SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2;
create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2;
show create table t3;
drop tables t1,t2,t3;
...@@ -3099,8 +3099,8 @@ Field *Item_type_holder::make_field_by_type(TABLE *table) ...@@ -3099,8 +3099,8 @@ Field *Item_type_holder::make_field_by_type(TABLE *table)
enum_set_typelib, collation.collation); enum_set_typelib, collation.collation);
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
table->db_create_options|= HA_OPTION_PACK_RECORD; table->db_create_options|= HA_OPTION_PACK_RECORD;
return new Field_string(max_length, maybe_null, name, table, fld_type= MYSQL_TYPE_STRING;
collation.collation); break;
default: default:
break; break;
} }
......
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