MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:eugene Date:June 6 2006 9:10pm
Subject:bk commit into 5.0 tree (evgen:1.2162) BUG#15962
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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
  1.2162 06/06/07 01:10:23 evgen@stripped +3 -0
  Fixed bug#15962: CONCAT() in UNION may lead to a data trucation.
  
  To calculate its max_length the CONCAT() function is simply sums max_lengths
  of its arguments but when the collation of an argument differs from the 
  collation of the CONCAT() max_length will be wrong. This may lead to a data
  truncation when a tmp table is used, in UNIONS for example.
  
  The Item_func_concat::fix_length_and_dec() function now recalculates the 
  max_length of an argument when the mbmaxlen of the argument differs from the
  mbmaxlen of the CONCAT().

  sql/item_strfunc.cc
    1.267 06/06/07 01:07:31 evgen@stripped +8 -1
    Fixed bug#15962: CONCAT() in UNION may lead to a data trucation.
    The Item_func_concat::fix_length_and_dec() function now recalculates the 
    max_length of an argument when the mbmaxlen of the argument differs from the
    mbmaxlen of the CONCAT().

  mysql-test/r/func_concat.result
    1.9 06/06/07 01:06:30 evgen@stripped +7 -0
    Added test case for bug#15962:CONCAT() in UNION may lead to a data trucation.

  mysql-test/t/func_concat.test
    1.11 06/06/07 01:05:49 evgen@stripped +8 -0
    Added test case for bug#15962:CONCAT() in UNION may lead to a data trucation.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	evgen
# Host:	moonbone.local
# Root:	/work/15962-bug-5.0-opt-mysql

--- 1.266/sql/item_strfunc.cc	2006-05-12 11:15:11 +04:00
+++ 1.267/sql/item_strfunc.cc	2006-06-07 01:07:31 +04:00
@@ -389,7 +389,14 @@
     return;
 
   for (uint i=0 ; i < arg_count ; i++)
-    max_result_length+= args[i]->max_length;
+  {
+    if (args[i]->collation.collation->mbmaxlen != collation.collation->mbmaxlen)
+      max_result_length+= (args[i]->max_length /
+                           args[i]->collation.collation->mbmaxlen) *
+                           collation.collation->mbmaxlen;
+    else
+      max_result_length+= args[i]->max_length;
+  }
 
   if (max_result_length >= MAX_BLOB_WIDTH)
   {

--- 1.8/mysql-test/r/func_concat.result	2005-01-04 14:46:42 +03:00
+++ 1.9/mysql-test/r/func_concat.result	2006-06-07 01:06:30 +04:00
@@ -68,3 +68,10 @@
 a
 a
 a0.0000
+create table t1(f1 varchar(6)) charset=utf8;
+insert into t1 values ("123456");
+select concat(f1, 2) a from t1 union select 'x' a from t1;
+a
+1234562
+x
+drop table t1;

--- 1.10/mysql-test/t/func_concat.test	2005-09-15 23:17:37 +04:00
+++ 1.11/mysql-test/t/func_concat.test	2006-06-07 01:05:49 +04:00
@@ -53,3 +53,11 @@
 select 'a' union select concat('a', -0.0000);
 
 # End of 4.1 tests
+
+#
+# Bug#15962: CONCAT() in UNION may lead to a data trucation.
+#
+create table t1(f1 varchar(6)) charset=utf8;
+insert into t1 values ("123456");
+select concat(f1, 2) a from t1 union select 'x' a from t1;
+drop table t1;
Thread
bk commit into 5.0 tree (evgen:1.2162) BUG#15962eugene6 Jun