Below is the list of changes that have just been committed into a local
5.1 repository of kaa. When kaa does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-04-23 09:52:53+04:00, kaa@kaamos.(none) +4 -0
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.
mysql-test/r/type_blob.result@stripped, 2008-04-23 09:52:52+04:00, kaa@kaamos.(none) +18 -0
Added a test case for bug #33969.
mysql-test/r/type_ranges.result@stripped, 2008-04-23 09:52:52+04:00, kaa@kaamos.(none) +2 -2
Fixed a test that relied on the old behavior.
mysql-test/t/type_blob.test@stripped, 2008-04-23 09:52:52+04:00, kaa@kaamos.(none) +20 -0
Added a test case for bug #33969.
sql/item.cc@stripped, 2008-04-23 09:52:52+04:00, kaa@kaamos.(none) +1 -1
Use a different constructor for Field_blob in
Item::make_string_field() so that set_packlength is set to adjust the
type of the TEXT/BLOB field being created.
diff -Nrup a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
--- a/mysql-test/r/type_blob.result 2008-02-12 22:09:14 +03:00
+++ b/mysql-test/r/type_blob.result 2008-04-23 09:52:52 +04:00
@@ -822,3 +822,21 @@ LENGTH(c) CHAR_LENGTH(c)
65535 65535
DROP TABLE t;
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
diff -Nrup a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result
--- a/mysql-test/r/type_ranges.result 2007-11-13 16:22:36 +03:00
+++ b/mysql-test/r/type_ranges.result 2008-04-23 09:52:52 +04:00
@@ -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;
diff -Nrup a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
--- a/mysql-test/t/type_blob.test 2007-11-23 12:53:27 +03:00
+++ b/mysql-test/t/type_blob.test 2008-04-23 09:52:52 +04:00
@@ -448,3 +448,23 @@ SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
DROP TABLE t;
--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
diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc 2008-03-12 11:21:09 +03:00
+++ b/sql/item.cc 2008-04-23 09:52:52 +04:00
@@ -4519,7 +4519,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))
| Thread |
|---|
| • bk commit into 5.1 tree (kaa:1.2562) BUG#33969 | Alexey Kopytov | 23 Apr |