Commit 770e9b4b authored by unknown's avatar unknown
Browse files

Fix for bug#20208

A better fix for bug#10025.

Fixed test case plus added new tests.

After fixing Bug#20208 "Blobs greater than 8K are being truncated to 8K"
the fix to bug#10025 "Misleading error with COLLATE mediumtext and UNION"
became more accurate. Earlier mediumtext got converted to longtext,
although mediumtext was enough to contain the results. Now it converts
correctly to mediumtext, if the length does not exceed that and if none
of the original fields were type longtext.

Type longtext still converts correctly to type longtext, as the extra
tests prove.


mysql-test/r/union.result:
  Fixed an earlier test case plus added two new tests.
mysql-test/t/union.test:
  Fixed an earlier test case plus added two new tests.
parent 207fd3fa
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -1283,10 +1283,39 @@ 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)` mediumtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop tables t1,t2,t3;
CREATE TABLE t1 (a longtext);
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;
SELECT @tmp_max:= @@max_allowed_packet;
@tmp_max:= @@max_allowed_packet
1048576
SET max_allowed_packet=25000000;
CREATE TABLE t1 (a mediumtext);
CREATE TABLE t2 (b varchar(20));
INSERT INTO t1 VALUES ('a');
CREATE TABLE t3 SELECT REPEAT(a,20000000) AS a FROM t1 UNION SELECT b FROM t2;
SHOW CREATE TABLE t3;
Table	Create Table
t3	CREATE TABLE `t3` (
  `a` longtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLES t1,t2,t3;
SET max_allowed_packet:= @tmp_max;
create table t1 ( id int not null auto_increment, primary key (id), col1 int);
insert into t1 (col1) values (2),(3),(4),(5),(6);
select 99 union all select id from t1 order by 1;
+30 −0
Original line number Diff line number Diff line
@@ -774,6 +774,7 @@ drop table t1,t2;
#
# 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');
@@ -782,6 +783,35 @@ create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2;
show create table t3;
drop tables t1,t2,t3;

#
# Extended fix to Bug#10025 - the test above should result to mediumtext
# and the one below to longtext. Earlier above test resulted to longtext
# type also.
#

CREATE TABLE t1 (a longtext);
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;

#
# Testing here that mediumtext converts into longtext if the result
# exceeds mediumtext maximum length
#

SELECT @tmp_max:= @@max_allowed_packet;
SET max_allowed_packet=25000000;
CREATE TABLE t1 (a mediumtext);
CREATE TABLE t2 (b varchar(20));
INSERT INTO t1 VALUES ('a');
CREATE TABLE t3 SELECT REPEAT(a,20000000) AS a FROM t1 UNION SELECT b FROM t2;
SHOW CREATE TABLE t3;
DROP TABLES t1,t2,t3;
SET max_allowed_packet:= @tmp_max;

#
# Bug #10032 Bug in parsing UNION with ORDER BY when one node does not use FROM
#