MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:<gshchepa Date:June 29 2007 9:09pm
Subject:bk commit into 5.0 tree (gshchepa:1.2508) BUG#29205
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum 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, 2007-06-30 02:09:50+05:00, gshchepa@stripped +3 -0
  Fixed bug #29205.
  When a UNION statement forced conversion of an UTF8
  charset value to a binary charset value, the byte
  length of the result values was truncated to the
  CHAR_LENGTH of the original UTF8 value.

  mysql-test/r/ctype_utf8.result@stripped, 2007-06-30 02:08:56+05:00, gshchepa@stripped +37 -0
    Updated test case for bug #29205.

  mysql-test/t/ctype_utf8.test@stripped, 2007-06-30 02:08:55+05:00, gshchepa@stripped +25 -0
    Updated test case for bug #29205.

  sql/item.cc@stripped, 2007-06-30 02:07:41+05:00, gshchepa@stripped +9 -3
    Fixed bug #29205.
    The calculation of data length was modified in
    the Item_type_holder::join_types method to take into
    account possible conversion of a multibyte charset
    value to a binary charset value, when each
    multibyte character is converted into a sequence
    of bytes (not to a single byte of binary charset).

diff -Nrup a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
--- a/mysql-test/r/ctype_utf8.result	2007-04-13 10:05:52 +05:00
+++ b/mysql-test/r/ctype_utf8.result	2007-06-30 02:08:56 +05:00
@@ -1657,3 +1657,40 @@ colA	colB	colA	colB
 1	foo	1	foo
 2	foo bar	2	foo bar
 DROP TABLE t1, t2;
+SELECT 'н1234567890' UNION SELECT _binary '1';
+н1234567890
+н1234567890
+1
+SELECT 'н1234567890' UNION SELECT 1;
+н1234567890
+н1234567890
+1
+SELECT '1' UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+SELECT 1 UNION SELECT 'н1234567890';
+1
+1
+н1234567890
+CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8;
+CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT);
+INSERT INTO t1 (c) VALUES ('н1234567890');
+INSERT INTO t2 (b, i) VALUES ('1', 1);
+SELECT c FROM t1 UNION SELECT b FROM t2;
+c
+н1234567890
+1
+SELECT c FROM t1 UNION SELECT i FROM t2;
+c
+н1234567890
+1
+SELECT b FROM t2 UNION SELECT c FROM t1;
+b
+1
+н1234567890
+SELECT i FROM t2 UNION SELECT c FROM t1;
+i
+1
+н1234567890
+DROP TABLE t1, t2;
diff -Nrup a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
--- a/mysql-test/t/ctype_utf8.test	2007-04-13 10:05:52 +05:00
+++ b/mysql-test/t/ctype_utf8.test	2007-06-30 02:08:55 +05:00
@@ -1338,3 +1338,28 @@ INSERT INTO t2 (colA, colB) VALUES (1, '
 SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
 WHERE t1.colA < 3;
 DROP TABLE t1, t2;
+
+#
+# Bug#29205: truncation of UTF8 values when the UNION statement
+# forces collation to the binary charset
+#
+
+SELECT 'н1234567890' UNION SELECT _binary '1';
+SELECT 'н1234567890' UNION SELECT 1;
+
+SELECT '1' UNION SELECT 'н1234567890';
+SELECT 1 UNION SELECT 'н1234567890';
+
+CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8;
+CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT);
+
+INSERT INTO t1 (c) VALUES ('н1234567890');
+INSERT INTO t2 (b, i) VALUES ('1', 1);
+
+SELECT c FROM t1 UNION SELECT b FROM t2;
+SELECT c FROM t1 UNION SELECT i FROM t2;
+
+SELECT b FROM t2 UNION SELECT c FROM t1;
+SELECT i FROM t2 UNION SELECT c FROM t1;
+
+DROP TABLE t1, t2;
diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc	2007-06-22 03:25:20 +05:00
+++ b/sql/item.cc	2007-06-30 02:07:41 +05:00
@@ -6595,9 +6595,15 @@ bool Item_type_holder::join_types(THD *t
       expansion of the size of the values because of character set
       conversions.
      */
-    max_length= max(old_max_chars * collation.collation->mbmaxlen,
-                    display_length(item) / item->collation.collation->mbmaxlen *
-                    collation.collation->mbmaxlen);
+    if (collation.collation != &my_charset_bin)
+    {
+      max_length= max(old_max_chars * collation.collation->mbmaxlen,
+                      display_length(item) /
+                      item->collation.collation->mbmaxlen *
+                      collation.collation->mbmaxlen);
+    }
+    else
+      set_if_bigger(max_length, display_length(item));
     break;
   }
   case REAL_RESULT:
Thread
bk commit into 5.0 tree (gshchepa:1.2508) BUG#29205gshchepa29 Jun