List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:November 21 2009 5:31pm
Subject:bzr commit into mysql-5.6-next-mr-bugfixing branch
(Alexey.Kopytov:2898) Bug#33969
View as plain text  
#At file:///data/src/bzr/mysql-next-mr-bugfixing/ based on revid:alexey.kopytov@stripped

 2898 Alexey Kopytov	2009-11-21
      Backport of the fix for bug #33969: Updating a text field via a
      left join 
      
      When creating a temporary TEXT/BLOB field from an Item in
      Item::make_string_field(), the field's type was unconditionally
      set to the one corresponding to the maximum length (i.e.
      LONGTEXT/ LONGBLOB). This resulted in problems when exactly the
      same TEXT/BLOB is type required in cases like CREATE ... SELECT
      or creating internal temporary tables for joins. 
      
      Fixed by calling a different constructor for Field_blob so that
      an appropriate type is used depending on the Item's max_length
      value.

    modified:
      mysql-test/r/type_blob.result
      mysql-test/r/type_ranges.result
      mysql-test/t/type_blob.test
      sql/item.cc
=== modified file 'mysql-test/r/type_blob.result'
--- a/mysql-test/r/type_blob.result	2009-07-01 12:36:40 +0000
+++ b/mysql-test/r/type_blob.result	2009-11-21 17:31:00 +0000
@@ -974,3 +974,21 @@ ERROR 42000: Display width out of range 
 explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
 ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
 End of 5.0 tests
+CREATE TABLE t1(id INT NOT NULL);
+CREATE TABLE t2(id INT NOT NULL, c TEXT NOT NULL);
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1, '');
+UPDATE t2 SET c = REPEAT('1', 70000);
+Warnings:
+Warning	1265	Data truncated for column 'c' at row 1
+SELECT LENGTH(c) FROM t2;
+LENGTH(c)
+65535
+UPDATE t1 LEFT JOIN t2 USING(id) SET t2.c = REPEAT('1', 70000) WHERE t1.id = 1;
+Warnings:
+Warning	1265	Data truncated for column 'c' at row 1
+SELECT LENGTH(c) FROM t2;
+LENGTH(c)
+65535
+DROP TABLE t1, t2;
+End of 5.1 tests

=== modified file 'mysql-test/r/type_ranges.result'
--- a/mysql-test/r/type_ranges.result	2007-11-13 13:24:48 +0000
+++ b/mysql-test/r/type_ranges.result	2009-11-21 17:31:00 +0000
@@ -276,8 +276,8 @@ t1	int(1)	NULL	NO		0		#	
 t2	varchar(1)	latin1_swedish_ci	NO				#	
 t3	varchar(256)	latin1_swedish_ci	NO				#	
 t4	varbinary(256)	NULL	NO				#	
-t5	longtext	latin1_swedish_ci	NO		NULL		#	
-t6	longblob	NULL	NO		NULL		#	
+t5	text	latin1_swedish_ci	NO		NULL		#	
+t6	blob	NULL	NO		NULL		#	
 t7	char(0)	latin1_swedish_ci	NO				#	
 t8	binary(0)	NULL	NO				#	
 select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2;

=== modified file 'mysql-test/t/type_blob.test'
--- a/mysql-test/t/type_blob.test	2008-05-30 09:12:07 +0000
+++ b/mysql-test/t/type_blob.test	2009-11-21 17:31:00 +0000
@@ -612,3 +612,23 @@ explain select convert(1, binary(4294967
 explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
 
 --echo End of 5.0 tests
+
+#
+# Bug #33969: Updating a text field via a left join
+#
+
+CREATE TABLE t1(id INT NOT NULL);
+CREATE TABLE t2(id INT NOT NULL, c TEXT NOT NULL);
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1, '');
+
+UPDATE t2 SET c = REPEAT('1', 70000);
+SELECT LENGTH(c) FROM t2;
+
+UPDATE t1 LEFT JOIN t2 USING(id) SET t2.c = REPEAT('1', 70000) WHERE t1.id = 1;
+SELECT LENGTH(c) FROM t2;
+
+DROP TABLE t1, t2;
+
+--echo End of 5.1 tests

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2009-11-06 14:20:27 +0000
+++ b/sql/item.cc	2009-11-21 17:31:00 +0000
@@ -5025,7 +5025,7 @@ Field *Item::make_string_field(TABLE *ta
   DBUG_ASSERT(collation.collation);
   if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB)
     field= new Field_blob(max_length, maybe_null, name,
-                          collation.collation);
+                          collation.collation, TRUE);
   /* Item_type_holder holds the exact type, do not change it */
   else if (max_length > 0 &&
       (type() != Item::TYPE_HOLDER || field_type() != MYSQL_TYPE_STRING))


Attachment: [text/bzr-bundle] bzr/alexey.kopytov@sun.com-20091121173100-y2tes8oz94zpqnnh.bundle
Thread
bzr commit into mysql-5.6-next-mr-bugfixing branch(Alexey.Kopytov:2898) Bug#33969Alexey Kopytov21 Nov