Commit 80b0baa7 authored by unknown's avatar unknown
Browse files

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 9b8e0274
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1235,3 +1235,17 @@ show columns from t2;
Field	Type	Null	Key	Default	Extra
a	varchar(3)	YES		NULL	
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;
+11 −0
Original line number Diff line number Diff line
@@ -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;
show columns from t2;
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;
+2 −2
Original line number Diff line number Diff line
@@ -3099,8 +3099,8 @@ Field *Item_type_holder::make_field_by_type(TABLE *table)
                         enum_set_typelib, collation.collation);
  case MYSQL_TYPE_VAR_STRING:
    table->db_create_options|= HA_OPTION_PACK_RECORD;
    return new Field_string(max_length, maybe_null, name, table,
                            collation.collation);
    fld_type= MYSQL_TYPE_STRING;
    break;
  default:
    break;
  }